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 /plugins/Goals/tests | |
parent | f28c7fa6cb6c63c8f459206448c7dcb93568099e (diff) |
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5
* submodule updates
* fixes
Diffstat (limited to 'plugins/Goals/tests')
-rw-r--r-- | plugins/Goals/tests/Integration/APITest.php | 58 | ||||
-rw-r--r-- | plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php | 2 |
2 files changed, 26 insertions, 34 deletions
diff --git a/plugins/Goals/tests/Integration/APITest.php b/plugins/Goals/tests/Integration/APITest.php index 2314cc5db2..f0e2ff6d79 100644 --- a/plugins/Goals/tests/Integration/APITest.php +++ b/plugins/Goals/tests/Integration/APITest.php @@ -29,7 +29,7 @@ class APITest extends IntegrationTestCase private $idSite = 1; - public function setUp() + public function setUp(): void { parent::setUp(); $this->api = API::getInstance(); @@ -100,39 +100,35 @@ class APITest extends IntegrationTestCase $this->assertGoal($idGoal, 'MyName', '', 'title', 'rere(.*)', 'regex', 1, 50, 1); } - /** - * @expectedException \Exception - * @expectedExceptionMessage General_ValidatorErrorXNotWhitelisted - */ public function test_addGoal_shouldThrowException_IfPatternTypeIsInvalid() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('General_ValidatorErrorXNotWhitelisted'); + $this->api->addGoal($this->idSite, 'MyName', 'external_website', 'www.test.de', 'invalid'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage General_ValidatorErrorNoValidRegex - */ public function test_addGoal_shouldThrowException_IfPatternRegexIsInvalid() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('General_ValidatorErrorNoValidRegex'); + $this->api->addGoal($this->idSite, 'MyName', 'url', '/(%$f', 'regex'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Goals_ExceptionInvalidMatchingString - */ public function test_addGoal_shouldThrowException_IfPatternTypeIsExactAndMatchAttributeNotEvent() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Goals_ExceptionInvalidMatchingString'); + $this->api->addGoal($this->idSite, 'MyName', 'url', 'www.test.de', 'exact'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Goals_ExceptionInvalidMatchingString - */ public function test_addGoal_shouldThrowException_IfPatternTypeIsExactAndMatchAttributeNotEvent2() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Goals_ExceptionInvalidMatchingString'); + $this->api->addGoal($this->idSite, 'MyName', 'external_website', 'www.test.de', 'exact'); } @@ -145,34 +141,31 @@ class APITest extends IntegrationTestCase $this->assertSame('3', (string)$idGoal); } - /** - * @expectedException \Exception - * @expectedExceptionMessage checkUserHasWriteAccess Fake exception - */ public function test_addGoal_shouldThrowException_IfNotEnoughPermission() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('checkUserHasWriteAccess Fake exception'); + $this->setNonAdminUser(); $this->createAnyGoal(); } - /** - * @expectedException \Exception - * @expectedExceptionMessage checkUserHasWriteAccess Fake exception - */ public function test_updateGoal_shouldThrowException_IfNotEnoughPermission() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('checkUserHasWriteAccess Fake exception'); + $idGoal = $this->createAnyGoal(); $this->assertSame(1, $idGoal); // make sure goal is created and does not already fail here $this->setNonAdminUser(); $this->api->updateGoal($this->idSite, $idGoal, 'MyName', 'url', 'www.test.de', 'exact'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Goals_ExceptionInvalidMatchingString - */ public function test_updateGoal_shouldThrowException_IfPatternTypeIsExactAndMatchAttributeNotEvent() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Goals_ExceptionInvalidMatchingString'); + $idGoal = $this->createAnyGoal(); $this->api->updateGoal($this->idSite, $idGoal, 'MyName', 'url', 'www.test.de', 'exact'); } @@ -236,12 +229,11 @@ class APITest extends IntegrationTestCase $this->assertHasNoGoals(); } - /** - * @expectedException \Exception - * @expectedExceptionMessage checkUserHasViewAccess Fake exception - */ public function test_getGoal_shouldThrowException_IfNotEnoughPermission() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('heckUserHasViewAccess Fake exception'); + $idGoal = $this->createAnyGoal(); $this->assertSame(1, $idGoal); $this->setNonAdminUser(); diff --git a/plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php b/plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php index 118b30ac4e..71bc3ef571 100644 --- a/plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php +++ b/plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php @@ -26,7 +26,7 @@ class AppendNameToColumnNamesTest extends \PHPUnit\Framework\TestCase */ private $table; - public function setUp() + public function setUp(): void { $this->table = new DataTable\Simple(); $this->addRow(array('nb_visits' => 1, 'nb_conversions' => 5, 'revenue' => 10, 'conversion_rate' => 20)); |