Skip to content

Commit

Permalink
Merge pull request #188 from wp-cli/fix/unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored May 22, 2024
2 parents afa90e9 + 7652a58 commit 3370dd8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ composer.lock
phpunit.xml
phpcs.xml
.phpcs.xml
.phpunit.cache
.phpunit.result.cache
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<exclude-pattern>*/src/WP_CLI/JsonManipulator\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_1_10/NullIOMethodsTrait\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_2_3/NullIOMethodsTrait\.php$</exclude-pattern>
<exclude-pattern>*/tests/test-json-manipulator\.php$</exclude-pattern>
<exclude-pattern>*/tests/JsonManipulatorTest\.php$</exclude-pattern>

<!-- Show progress. -->
<arg value="p"/>
Expand Down
29 changes: 19 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<phpunit
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite>
<directory prefix="spec-" suffix=".php">tests/</directory>
<directory prefix="test-" suffix=".php">tests/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
verbose="true">
<testsuite name="wp-cli/package-command tests">
<directory suffix="Test.php">tests</directory>
</testsuite>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
6 changes: 3 additions & 3 deletions tests/test-composer-json.php → tests/ComposerJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function set_up() {
WP_CLI::set_logger( $this->logger );

// Enable exit exception.

$class_wp_cli_capture_exit = new \ReflectionProperty( 'WP_CLI', 'capture_exit' );
$class_wp_cli_capture_exit->setAccessible( true );
$this->prev_capture_exit = $class_wp_cli_capture_exit->getValue();
$class_wp_cli_capture_exit->setValue( true );
$class_wp_cli_capture_exit->setValue( null, true );

$this->temp_dir = Utils\get_temp_dir() . uniqid( 'wp-cli-test-package-composer-json-', true ) . '/';
mkdir( $this->temp_dir );
Expand All @@ -44,7 +44,7 @@ public function tear_down() {
// Restore exit exception.
$class_wp_cli_capture_exit = new \ReflectionProperty( 'WP_CLI', 'capture_exit' );
$class_wp_cli_capture_exit->setAccessible( true );
$class_wp_cli_capture_exit->setValue( $this->prev_capture_exit );
$class_wp_cli_capture_exit->setValue( null, $this->prev_capture_exit );

rmdir( $this->temp_dir );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testAddLink($json, $type, $package, $constraint, $expected)
$this->assertEquals($expected, $manipulator->getContents());
}

public function linkProvider()
public static function linkProvider()
{
return array(
array(
Expand Down Expand Up @@ -1297,7 +1297,7 @@ public function testAddLinkAndSortPackages($json, $type, $package, $constraint,
$this->assertEquals($expected, $manipulator->getContents());
}

public function providerAddLinkAndSortPackages()
public static function providerAddLinkAndSortPackages()
{
return array(
array(
Expand Down Expand Up @@ -1380,7 +1380,7 @@ public function testRemoveSubNode($json, $name, $expected, $expectedContent = nu
}
}

public function removeSubNodeProvider()
public static function removeSubNodeProvider()
{
return array(
'works on simple ones first' => array(
Expand Down Expand Up @@ -2374,7 +2374,7 @@ public function testAddLinkCaseInsensitive($json, $type, $package, $constraint,
$this->assertEquals($expected, $manipulator->getContents());
}

public function providerAddLinkCaseInsensitive()
public static function providerAddLinkCaseInsensitive()
{
return array(
array(
Expand Down Expand Up @@ -2441,7 +2441,7 @@ public function testAddSubNodeCase($json, $mainNode, $name, $caseInsensitive, $e
$this->assertSame($expected, $manipulator->getContents());
}

public function providerAddSubNodeCase()
public static function providerAddSubNodeCase()
{
return array(
array(
Expand Down Expand Up @@ -2504,7 +2504,7 @@ public function testRemoveSubNodeCaseInsensitive($json, $mainNode, $name, $expec
}
}

public function providerRemoveSubNodeCaseInsensitive()
public static function providerRemoveSubNodeCaseInsensitive()
{
return array(
array(
Expand Down

0 comments on commit 3370dd8

Please sign in to comment.