Skip to content

Commit 3370dd8

Browse files
authored
Merge pull request #188 from wp-cli/fix/unit-tests
2 parents afa90e9 + 7652a58 commit 3370dd8

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ composer.lock
99
phpunit.xml
1010
phpcs.xml
1111
.phpcs.xml
12+
.phpunit.cache
13+
.phpunit.result.cache

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<exclude-pattern>*/src/WP_CLI/JsonManipulator\.php$</exclude-pattern>
1919
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_1_10/NullIOMethodsTrait\.php$</exclude-pattern>
2020
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_2_3/NullIOMethodsTrait\.php$</exclude-pattern>
21-
<exclude-pattern>*/tests/test-json-manipulator\.php$</exclude-pattern>
21+
<exclude-pattern>*/tests/JsonManipulatorTest\.php$</exclude-pattern>
2222

2323
<!-- Show progress. -->
2424
<arg value="p"/>

phpunit.xml.dist

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
<phpunit
2-
bootstrap="vendor/autoload.php"
3-
colors="true"
4-
>
5-
<testsuites>
6-
<testsuite>
7-
<directory prefix="spec-" suffix=".php">tests/</directory>
8-
<directory prefix="test-" suffix=".php">tests/</directory>
9-
</testsuite>
10-
</testsuites>
1+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
3+
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
beStrictAboutCoversAnnotation="true"
6+
beStrictAboutOutputDuringTests="true"
7+
beStrictAboutTestsThatDoNotTestAnything="true"
8+
beStrictAboutTodoAnnotatedTests="true"
9+
colors="true"
10+
verbose="true">
11+
<testsuite name="wp-cli/package-command tests">
12+
<directory suffix="Test.php">tests</directory>
13+
</testsuite>
14+
15+
<filter>
16+
<whitelist processUncoveredFilesFromWhitelist="true">
17+
<directory suffix=".php">src</directory>
18+
</whitelist>
19+
</filter>
1120
</phpunit>

tests/test-composer-json.php renamed to tests/ComposerJsonTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function set_up() {
2828
WP_CLI::set_logger( $this->logger );
2929

3030
// Enable exit exception.
31+
3132
$class_wp_cli_capture_exit = new \ReflectionProperty( 'WP_CLI', 'capture_exit' );
3233
$class_wp_cli_capture_exit->setAccessible( true );
33-
$this->prev_capture_exit = $class_wp_cli_capture_exit->getValue();
34-
$class_wp_cli_capture_exit->setValue( true );
34+
$class_wp_cli_capture_exit->setValue( null, true );
3535

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

4949
rmdir( $this->temp_dir );
5050

tests/test-json-manipulator.php renamed to tests/JsonManipulatorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testAddLink($json, $type, $package, $constraint, $expected)
2626
$this->assertEquals($expected, $manipulator->getContents());
2727
}
2828

29-
public function linkProvider()
29+
public static function linkProvider()
3030
{
3131
return array(
3232
array(
@@ -1297,7 +1297,7 @@ public function testAddLinkAndSortPackages($json, $type, $package, $constraint,
12971297
$this->assertEquals($expected, $manipulator->getContents());
12981298
}
12991299

1300-
public function providerAddLinkAndSortPackages()
1300+
public static function providerAddLinkAndSortPackages()
13011301
{
13021302
return array(
13031303
array(
@@ -1380,7 +1380,7 @@ public function testRemoveSubNode($json, $name, $expected, $expectedContent = nu
13801380
}
13811381
}
13821382

1383-
public function removeSubNodeProvider()
1383+
public static function removeSubNodeProvider()
13841384
{
13851385
return array(
13861386
'works on simple ones first' => array(
@@ -2374,7 +2374,7 @@ public function testAddLinkCaseInsensitive($json, $type, $package, $constraint,
23742374
$this->assertEquals($expected, $manipulator->getContents());
23752375
}
23762376

2377-
public function providerAddLinkCaseInsensitive()
2377+
public static function providerAddLinkCaseInsensitive()
23782378
{
23792379
return array(
23802380
array(
@@ -2441,7 +2441,7 @@ public function testAddSubNodeCase($json, $mainNode, $name, $caseInsensitive, $e
24412441
$this->assertSame($expected, $manipulator->getContents());
24422442
}
24432443

2444-
public function providerAddSubNodeCase()
2444+
public static function providerAddSubNodeCase()
24452445
{
24462446
return array(
24472447
array(
@@ -2504,7 +2504,7 @@ public function testRemoveSubNodeCaseInsensitive($json, $mainNode, $name, $expec
25042504
}
25052505
}
25062506

2507-
public function providerRemoveSubNodeCaseInsensitive()
2507+
public static function providerRemoveSubNodeCaseInsensitive()
25082508
{
25092509
return array(
25102510
array(

0 commit comments

Comments
 (0)