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:
authorStefan Giehl <stefan@matomo.org>2020-02-27 13:08:45 +0300
committerGitHub <noreply@github.com>2020-02-27 13:08:45 +0300
commit93aef4865cfdee9fcfa5acc9ff1950459a0af42e (patch)
treeaa8ad643d8ad233ffb2b033a437bcd2b71274877 /plugins/CustomVariables/tests
parentf28c7fa6cb6c63c8f459206448c7dcb93568099e (diff)
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5 * submodule updates * fixes
Diffstat (limited to 'plugins/CustomVariables/tests')
-rw-r--r--plugins/CustomVariables/tests/Commands/InfoTest.php4
-rw-r--r--plugins/CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php51
-rw-r--r--plugins/CustomVariables/tests/Fixtures/VisitWithManyCustomVariables.php4
-rw-r--r--plugins/CustomVariables/tests/Integration/ModelTest.php14
4 files changed, 34 insertions, 39 deletions
diff --git a/plugins/CustomVariables/tests/Commands/InfoTest.php b/plugins/CustomVariables/tests/Commands/InfoTest.php
index 64335fcb3b..64851f277e 100644
--- a/plugins/CustomVariables/tests/Commands/InfoTest.php
+++ b/plugins/CustomVariables/tests/Commands/InfoTest.php
@@ -25,7 +25,7 @@ class InfoTest extends IntegrationTestCase
{
public function testExecute_ShouldOutputInfoSuccess_IfEverythingIsOk()
{
- $this->assertContains('Your Piwik is configured for 5 custom variables.', $this->executeCommand());
+ self::assertStringContainsString('Your Piwik is configured for 5 custom variables.', $this->executeCommand());
}
public function testExecute_ShouldOutputErrorMessage_IfColumnsDoNotMatch()
@@ -33,7 +33,7 @@ class InfoTest extends IntegrationTestCase
$model = new Model(Model::SCOPE_PAGE);
$model->removeCustomVariable();
- $this->assertContains('There is a problem with your custom variables configuration', $this->executeCommand());
+ self::assertStringContainsString('There is a problem with your custom variables configuration', $this->executeCommand());
}
private function executeCommand()
diff --git a/plugins/CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php b/plugins/CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php
index 10f2f3f5d9..f4d6f49548 100644
--- a/plugins/CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php
+++ b/plugins/CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php
@@ -23,30 +23,27 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class SetNumberOfCustomVariablesTest extends IntegrationTestCase
{
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Not enough arguments
- */
public function testExecute_ShouldThrowException_IfArgumentIsMissing()
{
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('Not enough arguments');
+
$this->executeCommand(null);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The number of available custom variables has to be a number
- */
public function testExecute_ShouldThrowException_HasToBeANumber()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('The number of available custom variables has to be a number');
+
$this->executeCommand('a');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage There has to be at least five custom variables
- */
public function testExecute_ShouldThrowException_Minimum2CustomVarsRequired()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('There has to be at least five custom variables');
+
$this->executeCommand(4);
}
@@ -60,7 +57,7 @@ class SetNumberOfCustomVariablesTest extends IntegrationTestCase
{
$result = $this->executeCommand(5);
- $this->assertContains('Your Piwik is already configured for 5 custom variables', $result);
+ self::assertStringContainsString('Your Piwik is already configured for 5 custom variables', $result);
}
public function testExecute_ShouldAddMaxCustomVars_IfNumberIsHigherThanActual()
@@ -69,13 +66,13 @@ class SetNumberOfCustomVariablesTest extends IntegrationTestCase
$result = $this->executeCommand(6);
- $this->assertContains('Configuring Piwik for 6 custom variables', $result);
- $this->assertContains('1 new custom variables having the index(es) 6 will be ADDED', $result);
- $this->assertContains('Starting to apply changes', $result);
- $this->assertContains('Added a variable in scope "Page" having the index 6', $result);
- $this->assertContains('Added a variable in scope "Visit" having the index 6', $result);
- $this->assertContains('Added a variable in scope "Conversion" having the index 6', $result);
- $this->assertContains('Your Piwik is now configured for 6 custom variables.', $result);
+ self::assertStringContainsString('Configuring Piwik for 6 custom variables', $result);
+ self::assertStringContainsString('1 new custom variables having the index(es) 6 will be ADDED', $result);
+ self::assertStringContainsString('Starting to apply changes', $result);
+ self::assertStringContainsString('Added a variable in scope "Page" having the index 6', $result);
+ self::assertStringContainsString('Added a variable in scope "Visit" having the index 6', $result);
+ self::assertStringContainsString('Added a variable in scope "Conversion" having the index 6', $result);
+ self::assertStringContainsString('Your Piwik is now configured for 6 custom variables.', $result);
$this->assertEquals(6, CustomVariables::getNumUsableCustomVariables());
}
@@ -87,13 +84,13 @@ class SetNumberOfCustomVariablesTest extends IntegrationTestCase
$result = $this->executeCommand(5);
- $this->assertContains('Configuring Piwik for 5 custom variables', $result);
- $this->assertContains('1 existing custom variables having the index(es) 6 will be REMOVED.', $result);
- $this->assertContains('Starting to apply changes', $result);
- $this->assertContains('Removed a variable in scope "Page" having the index 6', $result);
- $this->assertContains('Removed a variable in scope "Visit" having the index 6', $result);
- $this->assertContains('Removed a variable in scope "Conversion" having the index 6', $result);
- $this->assertContains('Your Piwik is now configured for 5 custom variables.', $result);
+ self::assertStringContainsString('Configuring Piwik for 5 custom variables', $result);
+ self::assertStringContainsString('1 existing custom variables having the index(es) 6 will be REMOVED.', $result);
+ self::assertStringContainsString('Starting to apply changes', $result);
+ self::assertStringContainsString('Removed a variable in scope "Page" having the index 6', $result);
+ self::assertStringContainsString('Removed a variable in scope "Visit" having the index 6', $result);
+ self::assertStringContainsString('Removed a variable in scope "Conversion" having the index 6', $result);
+ self::assertStringContainsString('Your Piwik is now configured for 5 custom variables.', $result);
$this->assertEquals(5, CustomVariables::getNumUsableCustomVariables());
}
diff --git a/plugins/CustomVariables/tests/Fixtures/VisitWithManyCustomVariables.php b/plugins/CustomVariables/tests/Fixtures/VisitWithManyCustomVariables.php
index 5cf92e75c8..594fa45b78 100644
--- a/plugins/CustomVariables/tests/Fixtures/VisitWithManyCustomVariables.php
+++ b/plugins/CustomVariables/tests/Fixtures/VisitWithManyCustomVariables.php
@@ -22,14 +22,14 @@ class VisitWithManyCustomVariables extends Fixture
public $visitorId = '61e8cc2d51fea26d';
private $numCustomVars = 8;
- public function setUp()
+ public function setUp(): void
{
$this->setUpCustomVars();
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/CustomVariables/tests/Integration/ModelTest.php b/plugins/CustomVariables/tests/Integration/ModelTest.php
index 5324cfdf22..5e8bff8deb 100644
--- a/plugins/CustomVariables/tests/Integration/ModelTest.php
+++ b/plugins/CustomVariables/tests/Integration/ModelTest.php
@@ -21,7 +21,7 @@ class ModelTest extends IntegrationTestCase
{
private static $cvarScopes = array('page', 'visit', 'conversion');
- public function setUp()
+ public function setUp(): void
{
// do not call parent::setUp() since it expects database to be created,
// but DB for this test is removed in tearDown
@@ -29,26 +29,24 @@ class ModelTest extends IntegrationTestCase
self::$fixture->performSetUp();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
self::$fixture->performTearDown();
}
- /**
- * @expectedException \Exception
- */
public function test_construct_shouldFailInCaseOfEmptyScope()
{
+ $this->expectException(\Exception::class);
+
new Model(null);
}
- /**
- * @expectedException \Exception
- */
public function test_construct_shouldFailInCaseOfInvalidScope()
{
+ $this->expectException(\Exception::class);
+
new Model('inValId');
}