From 4f9ecb74d2ded9aa9e1c2a3fc98596ac4727fc55 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 22 May 2024 19:48:19 +0200 Subject: [PATCH 1/8] Rename class files --- phpunit.xml.dist | 32 +++++++++++-------- ...{test-arguments.php => Test_Arguments.php} | 7 ++-- tests/{test-cli.php => Test_Cli.php} | 4 +-- tests/{test-colors.php => Test_Colors.php} | 5 ++- tests/{test-shell.php => Test_Shell.php} | 7 ++-- tests/{test-table.php => Test_Table.php} | 5 +-- ...t-table-ascii.php => Test_Table_Ascii.php} | 3 +- 7 files changed, 30 insertions(+), 33 deletions(-) rename tests/{test-arguments.php => Test_Arguments.php} (98%) rename tests/{test-cli.php => Test_Cli.php} (99%) rename tests/{test-colors.php => Test_Colors.php} (89%) rename tests/{test-shell.php => Test_Shell.php} (93%) rename tests/{test-table.php => Test_Table.php} (99%) rename tests/{test-table-ascii.php => Test_Table_Ascii.php} (99%) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8b04e40..43a1822 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,20 @@ - - - tests/ - tests/ - tests/ - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd" + bootstrap="tests/bootstrap.php" + backupGlobals="false" + beStrictAboutCoversAnnotation="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutTestsThatDoNotTestAnything="true" + beStrictAboutTodoAnnotatedTests="true" + colors="true" + verbose="true"> + + tests/ + + + + + lib/ + + diff --git a/tests/test-arguments.php b/tests/Test_Arguments.php similarity index 98% rename from tests/test-arguments.php rename to tests/Test_Arguments.php index 6a69ba3..cd5d94d 100644 --- a/tests/test-arguments.php +++ b/tests/Test_Arguments.php @@ -1,15 +1,12 @@ Date: Wed, 22 May 2024 19:48:27 +0200 Subject: [PATCH 2/8] Remove Travis config --- .travis.yml | 26 -------------------------- README.md | 4 +--- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c72594f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -sudo: false -dist: trusty - -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - -matrix: - include: - - dist: precise - php: 5.3 - -before_script: - - php -m - - php --info | grep -i 'intl\|icu\|pcre' - -script: phpunit --debug - -notifications: - email: - on_success: never diff --git a/README.md b/README.md index 866a82c..0c9b5e3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ PHP Command Line Tools ====================== -[![Build Status](https://travis-ci.org/wp-cli/php-cli-tools.png?branch=master)](https://travis-ci.org/wp-cli/php-cli-tools) - A collection of functions and classes to assist with command line development. Requirements - * PHP >= 5.3 + * PHP >= 5.6 Suggested PHP extensions From 4aa8c54dc8c3dc1af76ed0b801e683e433f36737 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 22 May 2024 19:50:23 +0200 Subject: [PATCH 3/8] Bump PHP requirement --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4096d05..112217c 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": ">= 5.3.0" + "php": ">= 5.6.0" }, "require-dev": { "roave/security-advisories": "dev-latest", From 891d6ed7f3ff10a46e86096eb86f62ead31b41dd Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 22 May 2024 19:51:49 +0200 Subject: [PATCH 4/8] Add back `use` statements --- tests/Test_Arguments.php | 2 ++ tests/Test_Cli.php | 1 + tests/Test_Colors.php | 1 + tests/Test_Shell.php | 2 ++ tests/Test_Table.php | 1 + tests/Test_Table_Ascii.php | 1 + 6 files changed, 8 insertions(+) diff --git a/tests/Test_Arguments.php b/tests/Test_Arguments.php index cd5d94d..b5708c9 100644 --- a/tests/Test_Arguments.php +++ b/tests/Test_Arguments.php @@ -1,5 +1,7 @@ Date: Wed, 22 May 2024 19:52:37 +0200 Subject: [PATCH 5/8] Make data providers static --- tests/Test_Arguments.php | 8 ++++---- tests/Test_Colors.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Test_Arguments.php b/tests/Test_Arguments.php index b5708c9..64899e3 100644 --- a/tests/Test_Arguments.php +++ b/tests/Test_Arguments.php @@ -150,7 +150,7 @@ public function testAddOptions() * * @return array set of args and expected parsed values */ - public function settingsWithValidOptions() + public static function settingsWithValidOptions() { return array( array( @@ -173,7 +173,7 @@ public function settingsWithValidOptions() * * @return array set of args and expected parsed values */ - public function settingsWithMissingOptions() + public static function settingsWithMissingOptions() { return array( array( @@ -192,7 +192,7 @@ public function settingsWithMissingOptions() * * @return array set of args and expected parsed values */ - public function settingsWithMissingOptionsWithDefault() + public static function settingsWithMissingOptionsWithDefault() { return array( array( @@ -206,7 +206,7 @@ public function settingsWithMissingOptionsWithDefault() ); } - public function settingsWithNoOptionsWithDefault() + public static function settingsWithNoOptionsWithDefault() { return array( array( diff --git a/tests/Test_Colors.php b/tests/Test_Colors.php index 5c51553..bac23a4 100644 --- a/tests/Test_Colors.php +++ b/tests/Test_Colors.php @@ -8,7 +8,7 @@ class Test_Colors extends TestCase { /** * @dataProvider dataColors */ - function testColors( $str, $color ) { + public function testColors( $str, $color ) { // Colors enabled. Colors::enable( true ); @@ -21,7 +21,7 @@ function testColors( $str, $color ) { } } - function dataColors() { + public static function dataColors() { $ret = array(); foreach ( Colors::getColors() as $str => $color ) { $ret[] = array( $str, $color ); From 3a5cdd13d75ba094e5c35091e72d6334c0cbbbf3 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 22 May 2024 20:02:57 +0200 Subject: [PATCH 6/8] Fix `expectWarning` usage --- tests/Test_Arguments.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/Test_Arguments.php b/tests/Test_Arguments.php index 64899e3..52b81e9 100644 --- a/tests/Test_Arguments.php +++ b/tests/Test_Arguments.php @@ -90,6 +90,13 @@ public function set_up() 'flags' => $this->flags, 'options' => $this->options ); + + set_error_handler( + static function ( $errno, $errstr ) { + throw new \Exception( $errstr, $errno ); + }, + E_ALL + ); } /** @@ -101,6 +108,7 @@ public function tear_down() $this->options = null; $this->settings = null; self::clearArgv(); + restore_error_handler(); } /** @@ -258,8 +266,8 @@ public function testParseWithValidOptions($cliParams, $expectedValues) */ public function testParseWithMissingOptions($cliParams, $expectedValues) { - $this->expectWarning(); - $this->expectWarningMessage('no value given for --option1'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('no value given for --option1'); $this->_testParse($cliParams, $expectedValues); } From 6507ba299f2e918f47c29857ebfbf5f3254131e3 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 22 May 2024 20:11:13 +0200 Subject: [PATCH 7/8] Undo some changes --- tests/Test_Arguments.php | 1 + tests/Test_Shell.php | 1 + tests/bootstrap.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Test_Arguments.php b/tests/Test_Arguments.php index 52b81e9..9f89eda 100644 --- a/tests/Test_Arguments.php +++ b/tests/Test_Arguments.php @@ -1,5 +1,6 @@ Date: Wed, 22 May 2024 22:00:14 +0200 Subject: [PATCH 8/8] Use `strtolower` --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8dedfd7..1770859 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,7 +6,7 @@ function cli_autoload( $className ) { $fileName = ''; $namespace = ''; if ($lastNsPos = strrpos($className, '\\')) { - $namespace = substr($className, 0, $lastNsPos); + $namespace = strtolower(substr($className, 0, $lastNsPos)); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; }