Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PHPUnit/Unit/CommonTest.php')
-rw-r--r--tests/PHPUnit/Unit/CommonTest.php37
1 files changed, 12 insertions, 25 deletions
diff --git a/tests/PHPUnit/Unit/CommonTest.php b/tests/PHPUnit/Unit/CommonTest.php
index 8647dd00f6..a09c68aa73 100644
--- a/tests/PHPUnit/Unit/CommonTest.php
+++ b/tests/PHPUnit/Unit/CommonTest.php
@@ -120,13 +120,9 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarEmptyVarName()
{
- try {
- $_GET[''] = 1;
- Common::getRequestVar('');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+ $_GET[''] = 1;
+ Common::getRequestVar('');
}
/**
@@ -134,12 +130,8 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarNoDefaultNoTypeNoValue()
{
- try {
- Common::getRequestVar('test');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+ Common::getRequestVar('test');
}
/**
@@ -168,11 +160,11 @@ class CommonTest extends TestCase
/**
* nodefault Withtype WithValue => exception cos type not matching
- * @expectedException \Exception
- * @expectedExceptionMessage The parameter 'test' isn't set in the Request
*/
public function testGetRequestVarNoDefaultWithTypeWithValue()
{
+ $this->expectException(Exception::class);
+ $this->expectDeprecationMessage("The parameter 'test' isn't set in the Request");
$_GET['test'] = false;
Common::getRequestVar('test', null, 'string');
}
@@ -182,13 +174,8 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarNoDefaultWithTypeWithValue2()
{
- try {
- Common::getRequestVar('test', null, 'string');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
-
+ $this->expectException(Exception::class);
+ Common::getRequestVar('test', null, 'string');
}
/**
@@ -285,7 +272,7 @@ class CommonTest extends TestCase
"WHITE SPACE",
);
foreach ($notvalid as $toTest) {
- $this->assertFalse(Filesystem::isValidFilename($toTest), $toTest . " valid but shouldn't!");
+ self::assertFalse(Filesystem::isValidFilename($toTest), $toTest . " valid but shouldn't!");
}
}
@@ -299,8 +286,8 @@ class CommonTest extends TestCase
// strings not unserializable should return false and trigger a debug log
$logger = $this->createFakeLogger();
- $this->assertFalse(Common::safe_unserialize('{1:somebroken}'));
- $this->assertContains('Unable to unserialize a string: unserialize(): Error at offset 0 of 14 bytes', $logger->output);
+ self::assertFalse(Common::safe_unserialize('{1:somebroken}'));
+ self::assertStringContainsString('Unable to unserialize a string: unserialize(): Error at offset 0 of 14 bytes', $logger->output);
}
private function createFakeLogger()