diff --git a/.travis.yml b/.travis.yml index 407b464..9420cce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,29 +14,9 @@ matrix: env: - CS_CHECK=true - name: "Build Phar" - php: 7.1 + php: 7.3 env: - BUILD_PHAR=true - - name: "Tests PHP 7.1 Lowest Dependencies" - php: 7.1 - env: - - DEPS=lowest - - name: "Tests PHP 7.1 PHPUnit Dev Version" - php: 7.1 - env: - - PHPUNIT_DEV=true - - name: "Tests PHP 7.1" - php: 7.1 - - name: "Tests PHP 7.2 Lowest Dependencies" - php: 7.2 - env: - - DEPS=lowest - - name: "Tests PHP 7.2 PHPUnit Dev Version" - php: 7.2 - env: - - PHPUNIT_DEV=true - - name: "Tests PHP 7.2" - php: 7.2 - php: 7.3 name: "Tests PHP 7.3 Lowest Dependencies" env: diff --git a/composer.json b/composer.json index 4271a96..bcf53d6 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { "name": "mamitech/paratest", "require": { - "php": "^7.1", + "php": "^7.3", "ext-pcre": "*", "ext-reflection": "*", "ext-simplexml": "*", "brianium/habitat": "1.0.0", - "phpunit/php-timer": "^2.0|^3.0|^4.0|^5.0", - "phpunit/phpunit": "^7.5.8|^8.0|^9.0", + "phpunit/php-timer": "^5.0", + "phpunit/phpunit": "^9.2", "symfony/console": "^3.4||^4.0||^5.0", "symfony/process": "^3.4||^4.0||^5.0", - "phpunit/php-code-coverage": "^6.1.4|^7.0.2|^8.0" + "phpunit/php-code-coverage": "^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", diff --git a/src/Runners/PHPUnit/ResultPrinter.php b/src/Runners/PHPUnit/ResultPrinter.php index 61d87fe..a9605eb 100644 --- a/src/Runners/PHPUnit/ResultPrinter.php +++ b/src/Runners/PHPUnit/ResultPrinter.php @@ -7,7 +7,6 @@ use ParaTest\Logging\JUnit\Reader; use ParaTest\Logging\LogInterpreter; use SebastianBergmann\Timer\ResourceUsageFormatter; -use SebastianBergmann\Timer\Timer; /** * Class ResultPrinter. @@ -209,11 +208,7 @@ public function printFeedback(ExecutableTest $test) */ public function getHeader(): string { - if (class_exists(ResourceUsageFormatter::class)) { - $resourceUsage = (new ResourceUsageFormatter())->resourceUsageSinceStartOfRequest(); - } else { - $resourceUsage = Timer::resourceUsage(); - } + $resourceUsage = (new ResourceUsageFormatter())->resourceUsageSinceStartOfRequest(); return "\n\n" . $resourceUsage . "\n\n"; } diff --git a/test/Functional/Coverage/CoverageMergerTest.php b/test/Functional/Coverage/CoverageMergerTest.php index 5eefd94..b117114 100644 --- a/test/Functional/Coverage/CoverageMergerTest.php +++ b/test/Functional/Coverage/CoverageMergerTest.php @@ -53,7 +53,7 @@ public function testCoverageFromFileIsDeletedAfterAdd(array $coverageFiles) $coverageMerger = new CoverageMerger(); $coverageMerger->addCoverageFromFile($filename); - static::assertFileNotExists($filename); + static::assertFileDoesNotExist($filename); } /** diff --git a/test/Functional/Coverage/CoverageReporterTest.php b/test/Functional/Coverage/CoverageReporterTest.php index aab2786..ad93951 100644 --- a/test/Functional/Coverage/CoverageReporterTest.php +++ b/test/Functional/Coverage/CoverageReporterTest.php @@ -77,7 +77,7 @@ public function testGeneratePhp(array $coverageFiles) $target = $this->targetDir . '/coverage.php'; - static::assertFileNotExists($target); + static::assertFileDoesNotExist($target); $coverageMerger->getReporter()->php($target); @@ -100,7 +100,7 @@ public function testGenerateClover(array $coverageFiles) $target = $this->targetDir . '/coverage.xml'; - static::assertFileNotExists($target); + static::assertFileDoesNotExist($target); $coverageMerger->getReporter()->clover($target); @@ -126,7 +126,7 @@ public function testGenerateCrap4J(array $coverageFiles) $target = $this->targetDir . '/coverage.xml'; - static::assertFileNotExists($target); + static::assertFileDoesNotExist($target); $coverageMerger->getReporter()->crap4j($target); @@ -153,7 +153,7 @@ public function testGenerateHtml(array $coverageFiles) $target = $this->targetDir . '/coverage'; - static::assertFileNotExists($target); + static::assertFileDoesNotExist($target); $coverageMerger->getReporter()->html($target); diff --git a/test/Functional/DataProviderTest.php b/test/Functional/DataProviderTest.php index b58be78..2bb552f 100644 --- a/test/Functional/DataProviderTest.php +++ b/test/Functional/DataProviderTest.php @@ -24,7 +24,7 @@ public function testFunctionalMode() 'functional' => null, 'max-batch-size' => 50, ]); - $this->assertRegExp('/OK \(1150 tests, 1150 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(1150 tests, 1150 assertions\)/', $proc->getOutput()); } public function testNumericDataSetInFunctionalModeWithMethodFilter() @@ -34,7 +34,7 @@ public function testNumericDataSetInFunctionalModeWithMethodFilter() 'max-batch-size' => 50, 'filter' => 'testNumericDataProvider50', ]); - $this->assertRegExp('/OK \(50 tests, 50 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(50 tests, 50 assertions\)/', $proc->getOutput()); } public function testNumericDataSetInFunctionalModeWithCustomFilter() @@ -44,7 +44,7 @@ public function testNumericDataSetInFunctionalModeWithCustomFilter() 'max-batch-size' => 50, 'filter' => 'testNumericDataProvider50.*1', ]); - $this->assertRegExp('/OK \(14 tests, 14 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(14 tests, 14 assertions\)/', $proc->getOutput()); } public function testNamedDataSetInFunctionalModeWithMethodFilter() @@ -54,7 +54,7 @@ public function testNamedDataSetInFunctionalModeWithMethodFilter() 'max-batch-size' => 50, 'filter' => 'testNamedDataProvider50', ]); - $this->assertRegExp('/OK \(50 tests, 50 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(50 tests, 50 assertions\)/', $proc->getOutput()); } public function testNamedDataSetInFunctionalModeWithCustomFilter() @@ -64,7 +64,7 @@ public function testNamedDataSetInFunctionalModeWithCustomFilter() 'max-batch-size' => 50, 'filter' => 'testNamedDataProvider50.*name_of_test_.*1', ]); - $this->assertRegExp('/OK \(14 tests, 14 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(14 tests, 14 assertions\)/', $proc->getOutput()); } public function testNumericDataSet1000InFunctionalModeWithFilterAndMaxBatchSize() @@ -74,6 +74,6 @@ public function testNumericDataSet1000InFunctionalModeWithFilterAndMaxBatchSize( 'max-batch-size' => 50, 'filter' => 'testNumericDataProvider1000', ]); - $this->assertRegExp('/OK \(1000 tests, 1000 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(1000 tests, 1000 assertions\)/', $proc->getOutput()); } } diff --git a/test/Functional/FunctionalTestBase.php b/test/Functional/FunctionalTestBase.php index efd268d..188c715 100644 --- a/test/Functional/FunctionalTestBase.php +++ b/test/Functional/FunctionalTestBase.php @@ -29,7 +29,7 @@ protected function invokeParatest($path, $options = [], $callback = null) protected function assertTestsPassed(Process $proc, $testPattern = '\d+', $assertionPattern = '\d+') { - $this->assertRegExp( + $this->assertMatchesRegularExpression( "/OK \($testPattern tests?, $assertionPattern assertions?\)/", $proc->getOutput() ); diff --git a/test/Functional/GroupTest.php b/test/Functional/GroupTest.php index 2c4e733..4fb4540 100644 --- a/test/Functional/GroupTest.php +++ b/test/Functional/GroupTest.php @@ -21,37 +21,37 @@ public function setUp(): void public function testGroupSwitchOnlyExecutesThoseGroups() { $proc = $this->invoker->execute(['group' => 'group1']); - $this->assertRegExp('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); } public function testExcludeGroupSwitchDontExecuteThatGroup() { $proc = $this->invoker->execute(['exclude-group' => 'group1']); - $this->assertRegExp('/OK \(3 tests, 3 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(3 tests, 3 assertions\)/', $proc->getOutput()); } public function testGroupSwitchExecutesGroupsUsingShortOption() { $proc = $this->invoker->execute(['g' => 'group1']); - $this->assertRegExp('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); } public function testGroupSwitchOnlyExecutesThoseGroupsInFunctionalMode() { $proc = $this->invoker->execute(['functional', 'g' => 'group1']); - $this->assertRegExp('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(2 tests, 2 assertions\)/', $proc->getOutput()); } public function testGroupSwitchOnlyExecutesThoseGroupsWhereTestHasMultipleGroups() { $proc = $this->invoker->execute(['functional', 'group' => 'group3']); - $this->assertRegExp('/OK \(1 test, 1 assertion\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(1 test, 1 assertion\)/', $proc->getOutput()); } public function testGroupsSwitchExecutesMultipleGroups() { $proc = $this->invoker->execute(['functional', 'group' => 'group1,group3']); - $this->assertRegExp('/OK \(3 tests, 3 assertions\)/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/OK \(3 tests, 3 assertions\)/', $proc->getOutput()); } } diff --git a/test/Functional/OutputTest.php b/test/Functional/OutputTest.php index 88c9c6c..b396ef0 100644 --- a/test/Functional/OutputTest.php +++ b/test/Functional/OutputTest.php @@ -25,7 +25,7 @@ public function testDefaultMessagesDisplayed() $output = $this->paratest->execute(['p' => 5])->getOutput(); $this->assertStringContainsString('Running phpunit in 5 processes with ' . PHPUNIT, $output); $this->assertStringContainsString('Configuration read from ' . getcwd() . DS . 'phpunit.xml.dist', $output); - $this->assertRegExp('/[.F]{4}/', $output); + $this->assertMatchesRegularExpression('/[.F]{4}/', $output); } public function testMessagePrintedWhenInvalidConfigFileSupplied() @@ -43,7 +43,7 @@ public function testMessagePrintedWhenFunctionalModeIsOn() ->getOutput(); $this->assertStringContainsString('Running phpunit in 5 processes with ' . PHPUNIT, $output); $this->assertStringContainsString('Functional mode is ON.', $output); - $this->assertRegExp('/[.F]{4}/', $output); + $this->assertMatchesRegularExpression('/[.F]{4}/', $output); } public function testProcCountIsReportedWithProcOption() @@ -51,6 +51,6 @@ public function testProcCountIsReportedWithProcOption() $output = $this->paratest->execute(['p' => 1]) ->getOutput(); $this->assertStringContainsString('Running phpunit in 1 process with ' . PHPUNIT, $output); - $this->assertRegExp('/[.F]{4}/', $output); + $this->assertMatchesRegularExpression('/[.F]{4}/', $output); } } diff --git a/test/Functional/PHPUnitTest.php b/test/Functional/PHPUnitTest.php index b8c7ecb..b578f0f 100644 --- a/test/Functional/PHPUnitTest.php +++ b/test/Functional/PHPUnitTest.php @@ -25,7 +25,7 @@ public function testWithBootstrapThatDoesNotExist() $this->assertEquals(1, $proc->getExitCode(), 'Unexpected exit code'); // The [RuntimeException] message appears only on lower 6.x versions of Phpunit - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/(\[RuntimeException\]|Bootstrap specified but could not be found)/', $errors, 'Expected exception name not found in output' @@ -118,7 +118,7 @@ public function testParatestEnvironmentVariableWithWrapperRunnerWithoutTestToken 'paratest-only-tests/EnvironmentTest.php', ['bootstrap' => BOOTSTRAP, 'runner' => 'WrapperRunner', 'no-test-tokens' => 0] ); - $this->assertRegexp('/Failures: 1/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/Failures: 1/', $proc->getOutput()); } public function testParatestEnvironmentVariableWithSqliteRunner() @@ -142,7 +142,7 @@ public function testWithConfigurationThatDoesNotExist() 'passing-tests', ['configuration' => FIXTURES . DS . 'phpunit.xml.disto'] ); // dist"o" does not exist - $this->assertRegExp('/Could not read ".*phpunit.xml.disto"./', $proc->getOutput()); + $this->assertMatchesRegularExpression('/Could not read ".*phpunit.xml.disto"./', $proc->getOutput()); } public function testFunctionalWithBootstrap() @@ -167,7 +167,7 @@ public function testWithBootstrapAndProcessesSwitch() 'passing-tests', ['bootstrap' => BOOTSTRAP, 'processes' => 6] ); - $this->assertRegExp('/Running phpunit in 6 processes/', $proc->getOutput()); + $this->assertMatchesRegularExpression('/Running phpunit in 6 processes/', $proc->getOutput()); $this->assertTestsPassed($proc); } @@ -295,8 +295,8 @@ public function testFullyConfiguredRun() ]); $this->assertTestsPassed($proc); $results = $proc->getOutput(); - $this->assertRegExp('/Running phpunit in 6 processes/', $results); - $this->assertRegExp('/Functional mode is on/i', $results); + $this->assertMatchesRegularExpression('/Running phpunit in 6 processes/', $results); + $this->assertMatchesRegularExpression('/Functional mode is on/i', $results); $this->assertFileExists($output); if (file_exists($output)) { unlink($output); diff --git a/test/Unit/Console/VersionProviderTest.php b/test/Unit/Console/VersionProviderTest.php index bd513ff..4d65772 100644 --- a/test/Unit/Console/VersionProviderTest.php +++ b/test/Unit/Console/VersionProviderTest.php @@ -33,7 +33,7 @@ public function testComposerInstalledVersion() $this->assertIsString($actual, 'Version of phpunit package was found installed'); // dev-master is included here as the phpunit package is checked and there is a dev-master used on travis - $this->assertRegExp("~^dev-master|\d.\d.(.)+$~", $actual, 'Actual version number'); + $this->assertMatchesRegularExpression("~^dev-master|\d.\d.(.)+$~", $actual, 'Actual version number'); $actual = $provider->getComposerInstalledVersion('foooo/barazzoraz'); $this->assertNull($actual, 'No version for non-existent package'); @@ -44,6 +44,6 @@ public function testGitVersion() $provider = new VersionProvider(); $actual = $provider->getGitVersion(); $this->assertIsString($actual, 'Git is enabled and works'); - $this->assertRegExp("~^\d.\d(?:.\d+)?(?:-\d+-g[\da-f]+)?$~", $actual, 'Git gives a version'); + $this->assertMatchesRegularExpression("~^\d.\d(?:.\d+)?(?:-\d+-g[\da-f]+)?$~", $actual, 'Git gives a version'); } } diff --git a/test/Unit/Logging/JUnit/ReaderTest.php b/test/Unit/Logging/JUnit/ReaderTest.php index e0ed6e9..9c14c81 100644 --- a/test/Unit/Logging/JUnit/ReaderTest.php +++ b/test/Unit/Logging/JUnit/ReaderTest.php @@ -300,7 +300,7 @@ public function testRemoveLog() file_put_contents($tmp, $contents); $reader = new Reader($tmp); $reader->removeLog(); - $this->assertFileNotExists($tmp); + $this->assertFileDoesNotExist($tmp); } /** diff --git a/test/Unit/Runners/PHPUnit/ExecutableTestTest.php b/test/Unit/Runners/PHPUnit/ExecutableTestTest.php index c9aa457..e0364ba 100644 --- a/test/Unit/Runners/PHPUnit/ExecutableTestTest.php +++ b/test/Unit/Runners/PHPUnit/ExecutableTestTest.php @@ -74,7 +74,10 @@ public function testCommandRedirectsCoverage() $command = $this->executableTestChild->command($binary, $options); $coverageFileName = str_replace('/', '\/', $this->executableTestChild->getCoverageFileName()); - $this->assertRegExp("/^'\/usr\/bin\/phpunit' '--a' 'b' '--coverage-php' '$coverageFileName' '.*'/", $command); + $this->assertMatchesRegularExpression( + "/^'\/usr\/bin\/phpunit' '--a' 'b' '--coverage-php' '$coverageFileName' '.*'/", + $command + ); } public function testHandleEnvironmentVariablesAssignsToken() diff --git a/test/Unit/Runners/PHPUnit/ResultPrinterTest.php b/test/Unit/Runners/PHPUnit/ResultPrinterTest.php index 7151a46..0dae941 100644 --- a/test/Unit/Runners/PHPUnit/ResultPrinterTest.php +++ b/test/Unit/Runners/PHPUnit/ResultPrinterTest.php @@ -165,7 +165,7 @@ public function testGetHeader() $header = $this->printer->getHeader(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( "/\n\nTime: ([.:]?[0-9]{1,3})+ ?" . '(minute|minutes|second|seconds|ms|)?,' . " Memory:[\s][0-9]+([.][0-9]{1,2})? ?M[Bb]\n\n/",