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/UserCountry
parentf28c7fa6cb6c63c8f459206448c7dcb93568099e (diff)
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5 * submodule updates * fixes
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r--plugins/UserCountry/tests/Integration/APITest.php17
-rw-r--r--plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php11
-rw-r--r--plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php18
-rw-r--r--plugins/UserCountry/tests/Unit/UserCountryTest.php4
4 files changed, 22 insertions, 28 deletions
diff --git a/plugins/UserCountry/tests/Integration/APITest.php b/plugins/UserCountry/tests/Integration/APITest.php
index 22f15b89bb..89d976e81d 100644
--- a/plugins/UserCountry/tests/Integration/APITest.php
+++ b/plugins/UserCountry/tests/Integration/APITest.php
@@ -29,7 +29,7 @@ class APITest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -51,31 +51,28 @@ class APITest extends IntegrationTestCase
$this->assertEquals($locationProvider, Common::getCurrentLocationProviderId());
}
- /**
- * @expectedException \Exception
- */
public function test_setLocationProviderInvalid()
{
+ $this->expectException(\Exception::class);
+
$locationProvider = 'invalidProvider';
$this->api->setLocationProvider($locationProvider);
}
- /**
- * @expectedException \Exception
- */
public function test_setLocationProviderNoSuperUser()
{
+ $this->expectException(\Exception::class);
+
Access::getInstance()->setSuperUserAccess(false);
$locationProvider = GeoIp2\Php::ID;
$this->api->setLocationProvider($locationProvider);
}
- /**
- * @expectedException \Exception
- */
public function test_setLocationProviderDisabledInConfig()
{
+ $this->expectException(\Exception::class);
+
Config::getInstance()->General['enable_geolocation_admin'] = 0;
$locationProvider = GeoIp2\Php::ID;
diff --git a/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php b/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php
index f0b83490ef..0a30c38121 100644
--- a/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php
+++ b/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php
@@ -8,7 +8,6 @@
*/
namespace Piwik\Plugins\UserCountry\tests\Integration;
-use PHPUnit_Framework_MockObject_MockObject;
use Piwik\Common;
use Piwik\Db;
use Matomo\Network\IPUtils;
@@ -34,7 +33,7 @@ class VisitorGeolocatorTest extends IntegrationTestCase
*/
private $logInserter;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -236,13 +235,13 @@ class VisitorGeolocatorTest extends IntegrationTestCase
$geolocator = new VisitorGeolocator($mockLocationProvider);
$valuesUpdated = $geolocator->attributeExistingVisit($visit, $useCache = false);
- $this->assertEquals($expectedVisitProperties, $this->logInserter->getVisit($visit['idvisit']), $message = '', $delta = 0.001);
+ $this->assertEqualsWithDelta($expectedVisitProperties, $this->logInserter->getVisit($visit['idvisit']), $delta = 0.001);
$expectedUpdateValues = $expectedUpdateValues === null ? $expectedVisitProperties : $expectedUpdateValues;
- $this->assertEquals($expectedUpdateValues, $valuesUpdated, $message = '', $delta = 0.001);
+ $this->assertEqualsWithDelta($expectedUpdateValues, $valuesUpdated, $delta = 0.001);
$conversions = $this->getConversions($visit);
- $this->assertEquals(array($expectedVisitProperties, $expectedVisitProperties), $conversions, $message = '', $delta = 0.001);
+ $this->assertEqualsWithDelta(array($expectedVisitProperties, $expectedVisitProperties), $conversions, $delta = 0.001);
}
public function test_attributeExistingVisit_ReturnsNull_AndSkipsAttribution_IfIdVisitMissingFromInput()
@@ -359,7 +358,7 @@ class VisitorGeolocatorTest extends IntegrationTestCase
}
/**
- * @return PHPUnit_Framework_MockObject_MockObject|LocationProvider
+ * @return \PHPUnit\Framework\MockObject\MockObject|LocationProvider
*/
protected function getProviderMock()
{
diff --git a/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php b/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php
index e039502239..251a8e8db8 100644
--- a/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php
+++ b/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php
@@ -31,7 +31,7 @@ class AttributeHistoricalDataWithLocationsTest extends IntegrationTestCase
*/
public static $fixture = null;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -60,21 +60,19 @@ class AttributeHistoricalDataWithLocationsTest extends IntegrationTestCase
self::$fixture->setLocationProvider('GeoIP2-City.mmdb');
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Not enough arguments
- */
public function testExecute_ShouldThrowException_IfArgumentIsMissing()
{
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('Not enough arguments');
+
$this->executeCommand(null);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionInvalidDateFormat
- */
public function testExecute_ShouldReturnMessage_IfDatesAreInvalid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidDateFormat');
+
$this->executeCommand('test');
}
@@ -90,7 +88,7 @@ class AttributeHistoricalDataWithLocationsTest extends IntegrationTestCase
{
$result = $this->executeCommand('2010-01-03,2010-06-03');
- $this->assertContains(
+ self::assertStringContainsString(
'Re-attribution for date range: 2010-01-03 to 2010-06-03. 35 visits to process with provider "geoip2php".',
$result
);
diff --git a/plugins/UserCountry/tests/Unit/UserCountryTest.php b/plugins/UserCountry/tests/Unit/UserCountryTest.php
index 8f624c6ab4..cc38c0f2f7 100644
--- a/plugins/UserCountry/tests/Unit/UserCountryTest.php
+++ b/plugins/UserCountry/tests/Unit/UserCountryTest.php
@@ -51,10 +51,10 @@ class UserCountryTest extends \PHPUnit\Framework\TestCase
// Get list of countries
foreach ($countries as $country => $continent) {
// test continent
- $this->assertContains($continent, $continents);
+ self::assertTrue(in_array($continent, $continents));
// test flag
- $this->assertContains($country . '.png', $flags);
+ self::assertTrue(in_array($country . '.png', $flags));
}
foreach ($flags as $filename) {