diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-02-27 13:08:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 13:08:45 +0300 |
commit | 93aef4865cfdee9fcfa5acc9ff1950459a0af42e (patch) | |
tree | aa8ad643d8ad233ffb2b033a437bcd2b71274877 /tests/PHPUnit/Framework | |
parent | f28c7fa6cb6c63c8f459206448c7dcb93568099e (diff) |
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5
* submodule updates
* fixes
Diffstat (limited to 'tests/PHPUnit/Framework')
10 files changed, 35 insertions, 33 deletions
diff --git a/tests/PHPUnit/Framework/Constraint/HttpResponseText.php b/tests/PHPUnit/Framework/Constraint/HttpResponseText.php index 2225d9daf3..318a69ad8d 100644 --- a/tests/PHPUnit/Framework/Constraint/HttpResponseText.php +++ b/tests/PHPUnit/Framework/Constraint/HttpResponseText.php @@ -10,9 +10,10 @@ namespace Piwik\Tests\Framework\Constraint; /** * @deprecated */ -class HttpResponseText extends \PHPUnit_Framework_Constraint +class HttpResponseText extends \PHPUnit\Framework\Constraint\Constraint { private $actualCode; + private $value; /** * @param string $value Expected response text. @@ -47,7 +48,7 @@ class HttpResponseText extends \PHPUnit_Framework_Constraint * @param mixed $other Value or object to evaluate. * @return bool */ - public function matches($other) + public function matches($other): bool { $this->actualCode = $this->getResponse($other); @@ -59,8 +60,8 @@ class HttpResponseText extends \PHPUnit_Framework_Constraint * * @return string */ - public function toString() + public function toString(): string { - return 'does not return response text ' . $this->exporter->export($this->value) . ' it is ' . $this->actualCode; + return 'does not return response text ' . $this->exporter()->export($this->value) . ' it is ' . $this->actualCode; } -}?> +}
\ No newline at end of file diff --git a/tests/PHPUnit/Framework/Constraint/ResponseCode.php b/tests/PHPUnit/Framework/Constraint/ResponseCode.php index fc0cae2f97..a9977a097d 100644 --- a/tests/PHPUnit/Framework/Constraint/ResponseCode.php +++ b/tests/PHPUnit/Framework/Constraint/ResponseCode.php @@ -10,9 +10,10 @@ namespace Piwik\Tests\Framework\Constraint; /** * @deprecated */ -class ResponseCode extends \PHPUnit_Framework_Constraint +class ResponseCode extends \PHPUnit\Framework\Constraint\Constraint { private $actualCode; + private $value; /** * @param integer $value Expected response code @@ -30,7 +31,7 @@ class ResponseCode extends \PHPUnit_Framework_Constraint * @param mixed $other Value or object to evaluate. * @return bool */ - public function matches($other) + public function matches($other): bool { $options = array( CURLOPT_URL => $other, @@ -55,8 +56,8 @@ class ResponseCode extends \PHPUnit_Framework_Constraint * * @return string */ - public function toString() + public function toString(): string { - return 'does not return response code ' . $this->exporter->export($this->value) . ' it is ' . $this->actualCode; + return 'does not return response code ' . $this->exporter()->export($this->value) . ' it is ' . $this->actualCode; } -}?> +}
\ No newline at end of file diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index 6f9a54ed7c..307daa838c 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -72,7 +72,7 @@ use ReflectionClass; * merging some together. * @since 2.8.0 */ -class Fixture extends \PHPUnit_Framework_Assert +class Fixture extends \PHPUnit\Framework\Assert { const IMAGES_GENERATED_ONLY_FOR_OS = 'linux'; const IMAGES_GENERATED_FOR_PHP = '7.2'; @@ -174,13 +174,13 @@ class Fixture extends \PHPUnit_Framework_Assert } /** Adds data to Piwik. Creates sites, tracks visits, imports log files, etc. */ - public function setUp() + public function setUp(): void { // empty } /** Does any clean up. Most of the time there will be no need to clean up. */ - public function tearDown() + public function tearDown(): void { // empty } @@ -670,10 +670,10 @@ class Fixture extends \PHPUnit_Framework_Assert $trans_gif_64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="; $expectedResponse = base64_decode($trans_gif_64); - self::assertContains($expectedResponse, $response); - self::assertContains('This resource is part of Matomo.', $response); - self::assertNotContains('Error', $response); - self::assertNotContains('Fatal', $response); + self::assertStringContainsString($expectedResponse, $response); + self::assertStringContainsString('This resource is part of Matomo.', $response); + self::assertStringNotContainsString('Error', $response); + self::assertStringNotContainsString('Fatal', $response); } /** diff --git a/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php b/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php index 011d8aa8e0..c4802942c6 100644 --- a/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php @@ -27,7 +27,7 @@ abstract class BenchmarkTestCase extends SystemTestCase { public static $fixture; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $dbName = false; if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) { @@ -69,7 +69,7 @@ abstract class BenchmarkTestCase extends SystemTestCase } } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { // only drop the database if PIWIK_BENCHMARK_DATABASE isn't set $dropDatabase = empty($GLOBALS['PIWIK_BENCHMARK_DATABASE']); @@ -104,7 +104,7 @@ class Piwik_Test_Fixture_EmptyOneSite public $period = 'day'; public $idSite = 1; - public function setUp() + public function setUp(): void { // add one site Fixture::createWebsite( diff --git a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php index 91747847c2..46bd0546ff 100644 --- a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php @@ -71,7 +71,7 @@ class ConsoleCommandTestCase extends SystemTestCase */ protected $application; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php index 21d8d678a6..5e46659a8a 100644 --- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php @@ -46,18 +46,18 @@ abstract class IntegrationTestCase extends SystemTestCase * If your test modifies table columns, you will need to recreate the database * completely. This can be accomplished by: * - * public function setUp() + * public function setUp(): void * { * self::$fixture->performSetUp(); * } * - * public function tearDown() + * public function tearDown(): void * { * parent::tearDown(); * self::$fixture->performTearDown(); * } */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { static::configureFixture(static::$fixture); parent::setUpBeforeClass(); @@ -66,7 +66,7 @@ abstract class IntegrationTestCase extends SystemTestCase self::$tableData = self::getDbTablesWithData(); } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { self::$tableData = array(); } @@ -74,7 +74,7 @@ abstract class IntegrationTestCase extends SystemTestCase /** * Setup the database and create the base tables for all tests */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -98,7 +98,7 @@ abstract class IntegrationTestCase extends SystemTestCase /** * Resets all caches and drops the database */ - public function tearDown() + public function tearDown(): void { static::$fixture->clearInMemoryCaches(); static::$fixture->destroyEnvironment(); diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index ca97061c42..1cc27afef4 100644 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -58,7 +58,7 @@ abstract class SystemTestCase extends TestCase */ public static $fixture; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Log::debug("Setting up " . get_called_class()); @@ -83,7 +83,7 @@ abstract class SystemTestCase extends TestCase } } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { Log::debug("Tearing down " . get_called_class()); diff --git a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php index e61a6255db..8c0516c3d6 100644 --- a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php @@ -26,7 +26,7 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase */ protected $environment; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -35,7 +35,7 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase File::reset(); } - public function tearDown() + public function tearDown(): void { File::reset(); diff --git a/tests/PHPUnit/Framework/TestRequest/Response.php b/tests/PHPUnit/Framework/TestRequest/Response.php index 24ddae506d..0e6e062366 100644 --- a/tests/PHPUnit/Framework/TestRequest/Response.php +++ b/tests/PHPUnit/Framework/TestRequest/Response.php @@ -9,7 +9,7 @@ namespace Piwik\Tests\Framework\TestRequest; use Piwik\API\Request; -use PHPUnit_Framework_Assert as Asserts; +use PHPUnit\Framework\Assert as Asserts; use Exception; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; diff --git a/tests/PHPUnit/Framework/XssTesting.php b/tests/PHPUnit/Framework/XssTesting.php index 4e9160562a..ba2853a40e 100644 --- a/tests/PHPUnit/Framework/XssTesting.php +++ b/tests/PHPUnit/Framework/XssTesting.php @@ -170,7 +170,7 @@ JS; $actualEntries = array_values($actualEntries); try { - \PHPUnit_Framework_Assert::assertEquals($expectedEntries, $actualEntries); + \PHPUnit\Framework\Assert::assertEquals($expectedEntries, $actualEntries); } catch (\Exception $ex) { print "XssTesting::sanityCheck() failed, got: " . var_export($actualEntries, true) . "\nexpected: " . var_export($expectedEntries, true); |