Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
},
"require-dev": {
"wp-cli/scaffold-command": "^1 || ^2",
"wp-cli/wp-cli-tests": "^4"
"wp-cli/wp-cli-tests": "^5"
},
"config": {
"process-timeout": 7200,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"johnpbloch/wordpress-core-installer": true
"johnpbloch/wordpress-core-installer": true,
"phpstan/extension-installer": true
},
"lock": false
},
Expand Down Expand Up @@ -58,12 +59,14 @@
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpstan": "run-phpstan-tests",
"phpcbf": "run-phpcbf-cleanup",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
"test": [
"@lint",
"@phpcs",
"@phpstan",
"@phpunit",
"@behat"
]
Expand Down
15 changes: 7 additions & 8 deletions tests/JsonManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

use WP_CLI\JsonManipulator; // WP_CLI
use WP_CLI\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class JsonManipulatorTest extends TestCase
{

/**
* @dataProvider linkProvider
*/
#[DataProvider( 'linkProvider' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testAddLink($json, $type, $package, $constraint, $expected)
{
$manipulator = new JsonManipulator($json);
Expand Down Expand Up @@ -1290,6 +1292,7 @@ public static function linkProvider()
/**
* @dataProvider providerAddLinkAndSortPackages
*/
#[DataProvider( 'providerAddLinkAndSortPackages' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testAddLinkAndSortPackages($json, $type, $package, $constraint, $sortPackages, $expected)
{
$manipulator = new JsonManipulator($json);
Expand Down Expand Up @@ -1370,6 +1373,7 @@ public static function providerAddLinkAndSortPackages()
/**
* @dataProvider removeSubNodeProvider
*/
#[DataProvider( 'removeSubNodeProvider' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testRemoveSubNode($json, $name, $expected, $expectedContent = null)
{
$manipulator = new JsonManipulator($json);
Expand Down Expand Up @@ -1601,10 +1605,6 @@ public static function removeSubNodeProvider()
}
}
}
',

'{
}
',
),
'works on deep repos with borked texts2' => array(
Expand All @@ -1624,10 +1624,6 @@ public static function removeSubNodeProvider()
}
}
}
',

'{
}
',
),
'fails on deep arrays with borked texts' => array(
Expand Down Expand Up @@ -2367,6 +2363,7 @@ public function testRemoveMainKeyAtEndOfFile()
/**
* @dataProvider providerAddLinkCaseInsensitive
*/
#[DataProvider( 'providerAddLinkCaseInsensitive' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testAddLinkCaseInsensitive($json, $type, $package, $constraint, $sortPackages, $expected)
{
$manipulator = new JsonManipulator($json);
Expand Down Expand Up @@ -2433,6 +2430,7 @@ public static function providerAddLinkCaseInsensitive()
/**
* @dataProvider providerAddSubNodeCase
*/
#[DataProvider( 'providerAddSubNodeCase' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testAddSubNodeCase($json, $mainNode, $name, $caseInsensitive, $expected)
{
$manipulator = new JsonManipulator($json);
Expand Down Expand Up @@ -2494,6 +2492,7 @@ public static function providerAddSubNodeCase()
/**
* @dataProvider providerRemoveSubNodeCaseInsensitive
*/
#[DataProvider( 'providerRemoveSubNodeCaseInsensitive' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function testRemoveSubNodeCaseInsensitive($json, $mainNode, $name, $expected, $expectedContent = null)
{
$manipulator = new JsonManipulator($json);
Expand Down