From b43fc353423e8cb9202ac12f597ac23b9631aee7 Mon Sep 17 00:00:00 2001 From: Ivan Zykov Date: Mon, 25 May 2020 09:56:09 +0000 Subject: [PATCH] Updates PHPUnit up to version 7 in plugin-hacks --- .gitlab-ci.yml | 2 +- composer.json | 2 +- tests/phpunit/PrettyPrinter.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 158e8d5..c176396 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ Unit Test: - echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini - bin/install-wp-tests.sh wordpress_test root 'somepw' 127.0.0.1 latest - composer update - - phpunit --colors=always --coverage-text=1.txt + - vendor/bin/phpunit --colors=always --coverage-text=1.txt - grep "Lines:" 1.txt except: - /^v.*/ # do not unit test release tags diff --git a/composer.json b/composer.json index 6108e2e..fe820cd 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "friendsofphp/php-cs-fixer": "^2.11", "phpstan/phpstan": "^0.9.2", "phpstan/phpstan-phpunit": "^0.9.4", - "phpunit/phpunit": "^6.0", + "phpunit/phpunit": "7.*", "scrutinizer/ocular": "^1.5" } } diff --git a/tests/phpunit/PrettyPrinter.php b/tests/phpunit/PrettyPrinter.php index 57c1400..a55931a 100644 --- a/tests/phpunit/PrettyPrinter.php +++ b/tests/phpunit/PrettyPrinter.php @@ -8,7 +8,7 @@ class PrettyPrinter extends \PHPUnit\TextUI\ResultPrinter implements \PHPUnit\Fr * Function name is slightly deceiving because it is called at the beginning of the * unit test summary (after all tests have run) */ - protected function printHeader() + protected function printHeader(): void { parent::printHeader(); } @@ -23,7 +23,7 @@ protected function formatExceptionMsg($exceptionMessage) return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage); } - protected function printDefectTrace(\PHPUnit\Framework\TestFailure $defect) + protected function printDefectTrace(\PHPUnit\Framework\TestFailure $defect): void { $this->write($this->formatExceptionMsg($defect->getExceptionAsString())); $trace = \PHPUnit\Util\Filter::getFilteredStacktrace( @@ -54,7 +54,7 @@ private function out($message, $color='', $linebreak=false) /** * Fired prior to each individual test */ - public function startTest(\PHPUnit\Framework\Test $test) + public function startTest(\PHPUnit\Framework\Test $test): void { $this->out(">> RUN '".preg_replace("/^test/", "",$test->getName())."'..."); } @@ -63,7 +63,7 @@ public function startTest(\PHPUnit\Framework\Test $test) * @param PHPUnit\Framework\TestCase * @param int time of execution */ - public function endTest(\PHPUnit\Framework\Test $test, $time) + public function endTest(\PHPUnit\Framework\Test $test, $time): void { // copied from parent:endTest() if ($test instanceof \PHPUnit\Framework\TestCase) { @@ -93,7 +93,7 @@ public function endTest(\PHPUnit\Framework\Test $test, $time) public function prettySuiteName($s) { return preg_replace("/^Tests\\\/", "", $s); } - public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function startTestSuite(\PHPUnit\Framework\TestSuite $suite): void { parent::startTestSuite($suite); if (!$this->headerPrinted) { @@ -112,7 +112,7 @@ public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) $this->out("BEGIN SUITE '".$this->prettySuiteName($suite->getName())."'\n"); } } - public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function endTestSuite(\PHPUnit\Framework\TestSuite $suite): void { if ($suite->getName() != 'PHPUnit') { $this->out("END SUITE '".$this->prettySuiteName($suite->getName())."'\n\n"); @@ -123,7 +123,7 @@ public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) * result codes that PHPUnit sends to the console * @param string $progress */ - protected function writeProgress($progress) + protected function writeProgress($progress): void { // suppress output; }