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
parentf28c7fa6cb6c63c8f459206448c7dcb93568099e (diff)
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5 * submodule updates * fixes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/API/tests/Integration/APITest.php4
-rw-r--r--plugins/API/tests/Integration/RowEvolutionTest.php8
-rw-r--r--plugins/API/tests/Integration/RssRendererTest.php54
-rw-r--r--plugins/API/tests/System/AutoSuggestAPITest.php4
-rw-r--r--plugins/API/tests/Unit/ConsoleRendererTest.php9
-rw-r--r--plugins/API/tests/Unit/CsvRendererTest.php23
-rw-r--r--plugins/API/tests/Unit/DataTable/MergeDataTablesTest.php2
-rw-r--r--plugins/API/tests/Unit/HtmlRendererTest.php23
-rw-r--r--plugins/API/tests/Unit/JsonRendererTest.php2
-rw-r--r--plugins/API/tests/Unit/OriginalRendererTest.php9
-rw-r--r--plugins/API/tests/Unit/PhpRendererTest.php2
-rw-r--r--plugins/API/tests/Unit/WidgetMetadataTest.php2
-rw-r--r--plugins/API/tests/Unit/XmlRendererTest.php4
-rw-r--r--plugins/Actions/tests/Integration/ActionSiteSearchTest.php2
-rw-r--r--plugins/Actions/tests/Unit/ArchiverTest.php4
m---------plugins/AnonymousPiwikUsageMeasurement0
m---------plugins/Bandwidth0
-rw-r--r--plugins/BulkTracking/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/BulkTracking/tests/Framework/TestCase/BulkTrackingTestCase.php4
-rw-r--r--plugins/BulkTracking/tests/Integration/BulkTrackingTest.php7
-rw-r--r--plugins/BulkTracking/tests/Integration/HandlerTest.php2
-rw-r--r--plugins/BulkTracking/tests/Integration/RequestsTest.php25
-rw-r--r--plugins/BulkTracking/tests/Integration/TrackerTest.php2
-rw-r--r--plugins/BulkTracking/tests/System/TrackerTest.php2
-rw-r--r--plugins/BulkTracking/tests/Unit/RequestsTest.php2
-rw-r--r--plugins/BulkTracking/tests/Unit/ResponseTest.php2
-rw-r--r--plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php4
-rw-r--r--plugins/Contents/tests/System/ContentsTest.php6
-rw-r--r--plugins/CoreAdminHome/tests/Fixture/DuplicateActions.php2
-rw-r--r--plugins/CoreAdminHome/tests/Fixture/TrackingFailures.php2
-rw-r--r--plugins/CoreAdminHome/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/CoreAdminHome/tests/Integration/APITest.php30
-rw-r--r--plugins/CoreAdminHome/tests/Integration/Commands/DeleteLogsDataTest.php8
-rw-r--r--plugins/CoreAdminHome/tests/Integration/Commands/InvalidateReportDataTest.php38
-rw-r--r--plugins/CoreAdminHome/tests/Integration/Commands/OptimizeArchiveTablesTest.php2
-rw-r--r--plugins/CoreAdminHome/tests/Integration/Commands/PurgeOldArchiveDataTest.php10
-rw-r--r--plugins/CoreAdminHome/tests/Integration/FixDuplicateActionsTest.php6
-rw-r--r--plugins/CoreAdminHome/tests/Integration/Model/DuplicateActionRemoverTest.php2
-rw-r--r--plugins/CoreAdminHome/tests/Integration/SetConfigTest.php16
-rw-r--r--plugins/CoreAdminHome/tests/Integration/TasksTest.php4
-rw-r--r--plugins/CoreAdminHome/tests/Unit/SetConfig/ConfigSettingManipulationTest.php21
-rw-r--r--plugins/CoreConsole/tests/System/ArchiveCronTest.php2
-rw-r--r--plugins/CoreHome/tests/Integration/Column/UserIdTest.php4
-rw-r--r--plugins/CoreHome/tests/Integration/LoginWhitelistTest.php4
-rw-r--r--plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php5
-rw-r--r--plugins/CoreHome/tests/Unit/CoreHomeTest.php2
-rw-r--r--plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php2
-rw-r--r--plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php12
-rw-r--r--plugins/CoreUpdater/tests/Integration/ReleaseChannelTest.php2
-rw-r--r--plugins/CoreUpdater/tests/Integration/UpdateCommunicationTest.php2
-rw-r--r--plugins/CoreUpdater/tests/Unit/ModelTest.php18
-rw-r--r--plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php11
-rw-r--r--plugins/CoreVisualizations/tests/Unit/GraphTest.php8
-rw-r--r--plugins/CoreVisualizations/tests/Unit/SparklinesConfigTest.php2
m---------plugins/CustomAlerts0
m---------plugins/CustomDimensions0
-rw-r--r--plugins/CustomJsTracker/tests/Integration/ApiTest.php16
-rw-r--r--plugins/CustomJsTracker/tests/Integration/FileTest.php18
-rw-r--r--plugins/CustomJsTracker/tests/Integration/TrackerUpdaterTest.php11
-rw-r--r--plugins/CustomJsTracker/tests/System/PiwikJsContentTest.php2
-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
-rw-r--r--plugins/Dashboard/tests/Integration/APITest.php23
m---------plugins/DeviceDetectorCache0
-rw-r--r--plugins/DevicesDetection/tests/Fixtures/MultiDeviceGoalConversions.php4
-rw-r--r--plugins/Diagnostics/tests/Integration/Commands/AnalyzeArchiveTableTest.php2
-rw-r--r--plugins/Diagnostics/tests/Integration/ConfigReaderTest.php2
-rw-r--r--plugins/ExampleLogTables/tests/Fixtures/VisitsWithUserIdAndCustomData.php2
-rw-r--r--plugins/ExamplePlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/ExamplePlugin/tests/Integration/SimpleTest.php4
-rw-r--r--plugins/ExamplePlugin/tests/Unit/SimpleTest.php4
-rw-r--r--plugins/Feedback/tests/Fixtures/FeedbackPopupFixture.php4
-rw-r--r--plugins/Feedback/tests/Integration/ControllerTest.php8
-rw-r--r--plugins/Feedback/tests/Integration/FeedbackTest.php6
-rw-r--r--plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php6
-rw-r--r--plugins/GeoIp2/tests/Unit/GeoIp2Test.php6
-rw-r--r--plugins/Goals/tests/Integration/APITest.php58
-rw-r--r--plugins/Goals/tests/Unit/AppendNameToColumnNamesTest.php2
-rw-r--r--plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php4
-rw-r--r--plugins/Insights/tests/Integration/ApiTest.php6
-rw-r--r--plugins/Insights/tests/Integration/ModelTest.php10
-rw-r--r--plugins/Insights/tests/Unit/FilterExcludeLowValueTest.php2
-rw-r--r--plugins/Insights/tests/Unit/FilterInsightTest.php2
-rw-r--r--plugins/Insights/tests/Unit/FilterLimitTest.php2
-rw-r--r--plugins/Insights/tests/Unit/FilterMinGrowthTest.php2
-rw-r--r--plugins/Insights/tests/Unit/FilterOrderByTest.php2
-rw-r--r--plugins/Insights/tests/Unit/InsightReportTest.php11
-rw-r--r--plugins/Installation/tests/System/APITest.php6
-rw-r--r--plugins/IntranetMeasurable/tests/Fixtures/IntranetSitesWithVisits.php4
-rw-r--r--plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php7
-rw-r--r--plugins/LanguagesManager/tests/Integration/ModelTest.php6
-rw-r--r--plugins/LanguagesManager/tests/Unit/TranslationWriter/WriterTest.php15
-rw-r--r--plugins/Live/tests/Fixtures/ManyVisitsOfSameVisitor.php4
-rw-r--r--plugins/Live/tests/Fixtures/VisitsWithAllActionsAndDevices.php4
-rw-r--r--plugins/Live/tests/Integration/ModelTest.php20
-rw-r--r--plugins/Live/tests/System/ApiCounterTest.php11
m---------plugins/LogViewer0
-rw-r--r--plugins/Login/tests/Integration/APITest.php9
-rw-r--r--plugins/Login/tests/Integration/LoginTest.php2
-rw-r--r--plugins/Login/tests/Integration/PasswordResetterTest.php23
-rw-r--r--plugins/Login/tests/Integration/PasswordVerifierTest.php2
-rw-r--r--plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php2
-rw-r--r--plugins/Login/tests/Integration/SessionInitializerTest.php4
-rw-r--r--plugins/Login/tests/Integration/SystemSettingsTest.php16
m---------plugins/LoginLdap0
m---------plugins/MarketingCampaignsReporting0
-rw-r--r--plugins/Marketplace/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/Marketplace/tests/Integration/ApiTest.php44
-rw-r--r--plugins/Marketplace/tests/Integration/ClientTest.php9
-rw-r--r--plugins/Marketplace/tests/Integration/EnvironmentTest.php2
-rw-r--r--plugins/Marketplace/tests/Integration/Input/PluginNameTest.php9
-rw-r--r--plugins/Marketplace/tests/Integration/LicenseKeyTest.php2
-rw-r--r--plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php4
-rw-r--r--plugins/Marketplace/tests/Integration/PluginsTest.php8
-rw-r--r--plugins/Marketplace/tests/Integration/ServiceTest.php20
-rw-r--r--plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php2
-rw-r--r--plugins/Marketplace/tests/System/Api/ClientTest.php15
-rw-r--r--plugins/Marketplace/tests/System/Api/ServiceTest.php22
-rw-r--r--plugins/Marketplace/tests/Unit/ConsumerTest.php2
-rw-r--r--plugins/MobileMessaging/tests/Integration/MobileMessagingTest.php2
-rw-r--r--plugins/Monolog/tests/Integration/LogTest.php4
-rw-r--r--plugins/Monolog/tests/System/TrackerLoggingTest.php2
-rw-r--r--plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php8
-rw-r--r--plugins/MultiSites/tests/Fixtures/ManySitesWithVisits.php4
-rw-r--r--plugins/MultiSites/tests/Integration/DashboardTest.php2
-rw-r--r--plugins/MultiSites/tests/Integration/MultiSitesTest.php8
-rw-r--r--plugins/PrivacyManager/tests/Fixtures/FewVisitsAnonymizedFixture.php4
-rw-r--r--plugins/PrivacyManager/tests/Fixtures/MultipleSitesMultipleVisitsFixture.php4
-rw-r--r--plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php39
-rw-r--r--plugins/PrivacyManager/tests/Integration/DataPurgingTest.php4
-rw-r--r--plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php4
-rw-r--r--plugins/PrivacyManager/tests/Integration/Model/LogDataAnonymizationsTest.php51
-rw-r--r--plugins/PrivacyManager/tests/Integration/PrivacyManagerConfigTest.php2
-rw-r--r--plugins/PrivacyManager/tests/Integration/PrivacyManagerTest.php4
-rw-r--r--plugins/PrivacyManager/tests/Integration/Tracker/RequestProcessorTest.php2
-rw-r--r--plugins/PrivacyManager/tests/System/APITest.php16
-rw-r--r--plugins/PrivacyManager/tests/System/AnonymizationTest.php2
-rw-r--r--plugins/PrivacyManager/tests/System/PurgeDataTest.php6
-rw-r--r--plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php4
m---------plugins/QueuedTracking0
-rw-r--r--plugins/Referrers/tests/Integration/Columns/ReferrerKeywordTest.php2
-rw-r--r--plugins/Referrers/tests/Integration/Columns/ReferrerNameTest.php4
-rw-r--r--plugins/Referrers/tests/Integration/Columns/ReferrerTypeTest.php4
-rw-r--r--plugins/Referrers/tests/Unit/SearchEngineTest.php4
-rw-r--r--plugins/Referrers/tests/Unit/SocialTest.php4
-rw-r--r--plugins/SEO/tests/Integration/SEOTest.php2
-rw-r--r--plugins/ScheduledReports/tests/Fixtures/ReportSubscription.php2
-rw-r--r--plugins/ScheduledReports/tests/Integration/ApiTest.php57
-rw-r--r--plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/AttachedFileReportEmailGeneratorTest.php14
-rw-r--r--plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/HtmlReportEmailGeneratorTest.php2
-rw-r--r--plugins/ScheduledReports/tests/Integration/ReportEmailGeneratorTest.php2
-rw-r--r--plugins/ScheduledReports/tests/Integration/ScheduledReportsTest.php4
-rw-r--r--plugins/SegmentEditor/tests/Integration/ApiTest.php2
-rw-r--r--plugins/SegmentEditor/tests/Integration/ModelTest.php4
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php2
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php18
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentListTest.php11
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php2
-rw-r--r--plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php18
-rw-r--r--plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php9
-rw-r--r--plugins/SitesManager/tests/Fixtures/ManySites.php2
-rw-r--r--plugins/SitesManager/tests/Integration/ApiTest.php71
-rw-r--r--plugins/SitesManager/tests/Integration/ModelTest.php2
-rw-r--r--plugins/SitesManager/tests/Integration/SiteUrlsTest.php2
-rw-r--r--plugins/SitesManager/tests/Integration/SitesManagerTest.php2
-rw-r--r--plugins/SitesManager/tests/Unit/APITest.php4
m---------plugins/TagManager0
m---------plugins/TasksTimetable0
-rw-r--r--plugins/Tour/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/Tour/tests/Integration/ChallengeTest.php4
-rw-r--r--plugins/Tour/tests/System/APITest.php14
-rw-r--r--plugins/Tour/tests/System/DataFinderTest.php2
-rw-r--r--plugins/Tour/tests/System/TourTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php4
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/APITest.php9
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php2
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php18
-rw-r--r--plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php16
-rw-r--r--plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php2
-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
-rw-r--r--plugins/UserId/tests/Fixtures/TrackFewVisitsAndCreateUsers.php2
-rw-r--r--plugins/UserLanguage/tests/Fixtures/LanguageFixture.php4
-rw-r--r--plugins/UsersManager/tests/Fixtures/ManyUsers.php4
-rw-r--r--plugins/UsersManager/tests/Integration/APITest.php121
-rw-r--r--plugins/UsersManager/tests/Integration/ModelTest.php2
-rw-r--r--plugins/UsersManager/tests/Integration/UserAccessFilterTest.php2
-rw-r--r--plugins/UsersManager/tests/Integration/UserPreferencesTest.php2
-rw-r--r--plugins/UsersManager/tests/Integration/UsersManagerTest.php243
-rw-r--r--plugins/VisitFrequency/tests/Integration/APITest.php2
-rw-r--r--plugins/VisitTime/tests/Unit/AddSegmentByLabelInUTCTest.php2
m---------plugins/VisitorGenerator0
-rw-r--r--plugins/VisitsSummary/tests/Integration/VisitsSummaryTest.php4
-rw-r--r--plugins/VisitsSummary/tests/Unit/Reports/GetTest.php2
-rw-r--r--plugins/Widgetize/tests/Fixtures/WidgetizeFixture.php4
-rw-r--r--plugins/Widgetize/tests/System/WidgetTest.php4
206 files changed, 908 insertions, 1058 deletions
diff --git a/plugins/API/tests/Integration/APITest.php b/plugins/API/tests/Integration/APITest.php
index 3b3d235ac5..e8f4e050b6 100644
--- a/plugins/API/tests/Integration/APITest.php
+++ b/plugins/API/tests/Integration/APITest.php
@@ -30,7 +30,7 @@ class APITest extends IntegrationTestCase
private $hasSuperUserAccess = false;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -45,7 +45,7 @@ class APITest extends IntegrationTestCase
$this->makeSureTestRunsInContextOfAnonymousUser();
}
- public function tearDown()
+ public function tearDown(): void
{
Access::getInstance()->hasSuperUserAccess($this->hasSuperUserAccess);
parent::tearDown();
diff --git a/plugins/API/tests/Integration/RowEvolutionTest.php b/plugins/API/tests/Integration/RowEvolutionTest.php
index d7354a3d8d..36675bcd39 100644
--- a/plugins/API/tests/Integration/RowEvolutionTest.php
+++ b/plugins/API/tests/Integration/RowEvolutionTest.php
@@ -20,18 +20,16 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
class RowEvolutionTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Reports like VisitsSummary.get which do not have a dimension are not supported by row evolution
- */
public function test_getRowEvolution_shouldTriggerAnException_IfReportHasNoDimension()
{
+ $this->expectException(\Exception::class);
+ $this->expectDeprecationMessage("Reports like VisitsSummary.get which do not have a dimension are not supported by row evolution");
$rowEvolution = new RowEvolution();
$rowEvolution->getRowEvolution(1, 'day', 'last7', 'VisitsSummary', 'get');
}
diff --git a/plugins/API/tests/Integration/RssRendererTest.php b/plugins/API/tests/Integration/RssRendererTest.php
index 8210919118..850a63226f 100644
--- a/plugins/API/tests/Integration/RssRendererTest.php
+++ b/plugins/API/tests/Integration/RssRendererTest.php
@@ -25,7 +25,7 @@ class RssRendererTest extends IntegrationTestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -64,51 +64,42 @@ class RssRendererTest extends IntegrationTestCase
$this->assertEquals('Error: The API cannot handle this data structure.', $response);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderScalar_shouldFailForBooleanScalar()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar(true);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderScalar_shouldFailForIntegerScalar()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar(5);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderScalar_shouldFailForStringScalar()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar('string');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderDataTable_shouldFailForDataTable()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$dataTable = new DataTable();
$dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
$this->builder->renderDataTable($dataTable);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderDataTable_shouldFailForSubtables()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
+
$subtable = new DataTable();
$subtable->addRowFromSimpleArray(array('nb_visits' => 2, 'nb_random' => 6));
@@ -119,12 +110,11 @@ class RssRendererTest extends IntegrationTestCase
$this->builder->renderDataTable($dataTable);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderDataTable_shouldFail_IfKeynameIsNotDate()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
+
$map = new DataTable\Map();
$dataTable = new DataTable();
@@ -161,24 +151,22 @@ class RssRendererTest extends IntegrationTestCase
</rss>', $response);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderDataTable_shouldFailForSimpleDataTable()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
+
$dataTable = new DataTable\Simple();
$dataTable->addRowsFromArray(array('nb_visits' => 3, 'nb_random' => 6));
$this->builder->renderDataTable($dataTable);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage RSS feeds can be generated for one specific website
- */
public function test_renderArray_ShouldFailForArrays()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('RSS feeds can be generated for one specific website');
+
$input = array(1, 2, 5, 'string', 10);
$this->builder->renderArray($input);
diff --git a/plugins/API/tests/System/AutoSuggestAPITest.php b/plugins/API/tests/System/AutoSuggestAPITest.php
index 006f780424..4d956d19a4 100644
--- a/plugins/API/tests/System/AutoSuggestAPITest.php
+++ b/plugins/API/tests/System/AutoSuggestAPITest.php
@@ -51,14 +51,14 @@ class AutoSuggestAPITest extends SystemTestCase
protected static $processed = 0;
protected static $skipped = array();
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
API::setSingletonInstance(CachedAPI::getInstance());
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
diff --git a/plugins/API/tests/Unit/ConsoleRendererTest.php b/plugins/API/tests/Unit/ConsoleRendererTest.php
index 3f3c4890d4..9aae115b56 100644
--- a/plugins/API/tests/Unit/ConsoleRendererTest.php
+++ b/plugins/API/tests/Unit/ConsoleRendererTest.php
@@ -24,7 +24,7 @@ class ConsoleRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array());
DataTable\Manager::getInstance()->deleteAll();
@@ -114,12 +114,11 @@ class ConsoleRendererTest extends \PHPUnit\Framework\TestCase
", $response);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalAssociativeArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(
"firstElement" => "isFirst",
"secondElement" => array(
diff --git a/plugins/API/tests/Unit/CsvRendererTest.php b/plugins/API/tests/Unit/CsvRendererTest.php
index 2ec5bcdebf..1ecc7d314f 100644
--- a/plugins/API/tests/Unit/CsvRendererTest.php
+++ b/plugins/API/tests/Unit/CsvRendererTest.php
@@ -22,7 +22,7 @@ class CsvRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'convertToUnicode' => 0));
}
@@ -285,12 +285,11 @@ firstElement,secondElement,
,,thirdElement', $actual);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalAssociativeArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(
"firstElement" => "isFirst",
"secondElement" => array(
@@ -302,12 +301,11 @@ firstElement,secondElement,
$this->builder->renderArray($input);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalIndexArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(array("firstElement",
array(
"firstElement",
@@ -318,12 +316,11 @@ firstElement,secondElement,
$this->builder->renderArray($input);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalMixedArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(
"firstElement" => "isFirst",
array(
diff --git a/plugins/API/tests/Unit/DataTable/MergeDataTablesTest.php b/plugins/API/tests/Unit/DataTable/MergeDataTablesTest.php
index 5eeeabac2b..3e5bc6e5c8 100644
--- a/plugins/API/tests/Unit/DataTable/MergeDataTablesTest.php
+++ b/plugins/API/tests/Unit/DataTable/MergeDataTablesTest.php
@@ -20,7 +20,7 @@ class MergeDataTablesTest extends \PHPUnit\Framework\TestCase
*/
private $instance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->instance = new MergeDataTables();
diff --git a/plugins/API/tests/Unit/HtmlRendererTest.php b/plugins/API/tests/Unit/HtmlRendererTest.php
index 9de3afd02d..3f1dc480c2 100644
--- a/plugins/API/tests/Unit/HtmlRendererTest.php
+++ b/plugins/API/tests/Unit/HtmlRendererTest.php
@@ -24,7 +24,7 @@ class HtmlRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll'));
DataTable\Manager::getInstance()->deleteAll();
@@ -449,12 +449,11 @@ message', $response);
', $actual);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalAssociativeArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(
"firstElement" => "isFirst",
"secondElement" => array(
@@ -466,12 +465,11 @@ message', $response);
$this->builder->renderArray($input);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalIndexArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(array("firstElement",
array(
"firstElement",
@@ -482,12 +480,11 @@ message', $response);
$this->builder->renderArray($input);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Data structure returned is not convertible in the requested format
- */
public function test_renderArray_ShouldConvertMultiDimensionalMixedArrayToJson()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
+
$input = array(
"firstElement" => "isFirst",
array(
diff --git a/plugins/API/tests/Unit/JsonRendererTest.php b/plugins/API/tests/Unit/JsonRendererTest.php
index 2e3ddab820..34fbed0364 100644
--- a/plugins/API/tests/Unit/JsonRendererTest.php
+++ b/plugins/API/tests/Unit/JsonRendererTest.php
@@ -25,7 +25,7 @@ class JsonRendererTest extends \PHPUnit\Framework\TestCase
*/
private $jsonBuilder;
- public function setUp()
+ public function setUp(): void
{
$this->jsonBuilder = $this->makeBuilder(array());
DataTable\Manager::getInstance()->deleteAll();
diff --git a/plugins/API/tests/Unit/OriginalRendererTest.php b/plugins/API/tests/Unit/OriginalRendererTest.php
index d9977fd3a5..4543836f07 100644
--- a/plugins/API/tests/Unit/OriginalRendererTest.php
+++ b/plugins/API/tests/Unit/OriginalRendererTest.php
@@ -22,7 +22,7 @@ class OriginalRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array());
}
@@ -34,12 +34,11 @@ class OriginalRendererTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($response);
}
- /**
- * @expectedException \BadMethodCallException
- * @expectedExceptionMessage The other message
- */
public function test_renderException_shouldThrowTheException()
{
+ $this->expectException(\BadMethodCallException::class);
+ $this->expectExceptionMessage('The other message');
+
$this->builder->renderException('This message should be ignored', new \BadMethodCallException('The other message'));
}
diff --git a/plugins/API/tests/Unit/PhpRendererTest.php b/plugins/API/tests/Unit/PhpRendererTest.php
index ea28790ff2..64d2d4cde9 100644
--- a/plugins/API/tests/Unit/PhpRendererTest.php
+++ b/plugins/API/tests/Unit/PhpRendererTest.php
@@ -23,7 +23,7 @@ class PhpRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array('serialize' => 0));
DataTable\Manager::getInstance()->deleteAll();
diff --git a/plugins/API/tests/Unit/WidgetMetadataTest.php b/plugins/API/tests/Unit/WidgetMetadataTest.php
index 5c0cdf4eeb..1e4cb40adc 100644
--- a/plugins/API/tests/Unit/WidgetMetadataTest.php
+++ b/plugins/API/tests/Unit/WidgetMetadataTest.php
@@ -32,7 +32,7 @@ class WidgetMetadataTest extends \PHPUnit\Framework\TestCase
*/
private $metadata;
- public function setUp()
+ public function setUp(): void
{
$this->metadata = new WidgetMetadata();
}
diff --git a/plugins/API/tests/Unit/XmlRendererTest.php b/plugins/API/tests/Unit/XmlRendererTest.php
index 064c06100d..f6d72513f3 100644
--- a/plugins/API/tests/Unit/XmlRendererTest.php
+++ b/plugins/API/tests/Unit/XmlRendererTest.php
@@ -22,13 +22,13 @@ class XmlRendererTest extends \PHPUnit\Framework\TestCase
*/
private $builder;
- public function setUp()
+ public function setUp(): void
{
$this->builder = $this->makeBuilder(array());
DataTable\Manager::getInstance()->deleteAll();
}
- public function tearDown()
+ public function tearDown(): void
{
DataTable\Manager::getInstance()->deleteAll();
}
diff --git a/plugins/Actions/tests/Integration/ActionSiteSearchTest.php b/plugins/Actions/tests/Integration/ActionSiteSearchTest.php
index 27011a30cd..0c22da0643 100644
--- a/plugins/Actions/tests/Integration/ActionSiteSearchTest.php
+++ b/plugins/Actions/tests/Integration/ActionSiteSearchTest.php
@@ -20,7 +20,7 @@ use Piwik\Tracker\Request;
*/
class ActionSiteSearchTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Actions/tests/Unit/ArchiverTest.php b/plugins/Actions/tests/Unit/ArchiverTest.php
index 9c7cae8f7e..79d61a016c 100644
--- a/plugins/Actions/tests/Unit/ArchiverTest.php
+++ b/plugins/Actions/tests/Unit/ArchiverTest.php
@@ -21,12 +21,12 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/Actions/Actions.php';
*/
class ArchiverTests extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
}
diff --git a/plugins/AnonymousPiwikUsageMeasurement b/plugins/AnonymousPiwikUsageMeasurement
-Subproject c7cca45f448b0a997661fa8397c21c56398b103
+Subproject 550367e85dd095e90db15c62eb23b3eed811d24
diff --git a/plugins/Bandwidth b/plugins/Bandwidth
-Subproject 9c4f2cab95220553348ec2b151c9e4417414407
+Subproject 14d2b4e3f53e28a856e216c99f60e03a1fd5747
diff --git a/plugins/BulkTracking/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/BulkTracking/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index aac9c14a2a..b5545269a6 100644
--- a/plugins/BulkTracking/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/BulkTracking/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -20,14 +20,14 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackFirstVisit();
$this->trackSecondVisit();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/BulkTracking/tests/Framework/TestCase/BulkTrackingTestCase.php b/plugins/BulkTracking/tests/Framework/TestCase/BulkTrackingTestCase.php
index 54eec6e57d..262efd7026 100644
--- a/plugins/BulkTracking/tests/Framework/TestCase/BulkTrackingTestCase.php
+++ b/plugins/BulkTracking/tests/Framework/TestCase/BulkTrackingTestCase.php
@@ -31,7 +31,7 @@ class BulkTrackingTestCase extends IntegrationTestCase
private $pluginBackup;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -41,7 +41,7 @@ class BulkTrackingTestCase extends IntegrationTestCase
Plugin\Manager::getInstance()->addLoadedPlugin('BulkTracking', $this->bulk);
}
- public function tearDown()
+ public function tearDown(): void
{
Plugin\Manager::getInstance()->addLoadedPlugin('BulkTracking', $this->pluginBackup);
parent::tearDown();
diff --git a/plugins/BulkTracking/tests/Integration/BulkTrackingTest.php b/plugins/BulkTracking/tests/Integration/BulkTrackingTest.php
index 58c1e0e89e..af265ba63a 100644
--- a/plugins/BulkTracking/tests/Integration/BulkTrackingTest.php
+++ b/plugins/BulkTracking/tests/Integration/BulkTrackingTest.php
@@ -74,12 +74,11 @@ class BulkTrackingTest extends BulkTrackingTestCase
$this->assertCount(2, $requests);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage token_auth must be specified when using Bulk Tracking Import
- */
public function test_initRequestSet_shouldTriggerException_InCaseNoValidTokenProvidedAndAuthenticationIsRequired()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('token_auth must be specified when using Bulk Tracking Import');
+
$request = $this->getDummyRequest(false);
$this->initRequestSet($request, true);
diff --git a/plugins/BulkTracking/tests/Integration/HandlerTest.php b/plugins/BulkTracking/tests/Integration/HandlerTest.php
index 69aed7a910..0a963e8672 100644
--- a/plugins/BulkTracking/tests/Integration/HandlerTest.php
+++ b/plugins/BulkTracking/tests/Integration/HandlerTest.php
@@ -46,7 +46,7 @@ class HandlerTest extends IntegrationTestCase
*/
private $requestSet;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/BulkTracking/tests/Integration/RequestsTest.php b/plugins/BulkTracking/tests/Integration/RequestsTest.php
index 3f7e9672c1..3e4e0fbc7e 100644
--- a/plugins/BulkTracking/tests/Integration/RequestsTest.php
+++ b/plugins/BulkTracking/tests/Integration/RequestsTest.php
@@ -29,7 +29,7 @@ class RequestsTest extends IntegrationTestCase
*/
private $requests;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -38,7 +38,7 @@ class RequestsTest extends IntegrationTestCase
$this->requests = new Requests();
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
@@ -65,32 +65,29 @@ class RequestsTest extends IntegrationTestCase
TrackerConfig::setConfigValue('bulk_requests_require_authentication', $oldConfig);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage token_auth must be specified when using Bulk Tracking Import
- */
public function test_authenticateRequests_shouldThrowAnException_IfTokenAuthIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('token_auth must be specified when using Bulk Tracking Import');
+
$requests = array($this->buildDummyRequest());
$this->requests->authenticateRequests($requests);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage token_auth must be specified when using Bulk Tracking Import
- */
public function test_authenticateRequests_shouldThrowAnException_IfAnyTokenAuthIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('token_auth must be specified when using Bulk Tracking Import');
+
$requests = array($this->buildDummyRequest($this->getSuperUserToken()), $this->buildDummyRequest());
$this->requests->authenticateRequests($requests);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage token_auth specified does not have Admin permission for idsite=1
- */
public function test_authenticateRequests_shouldThrowAnException_IfTokenIsNotValid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('token_auth specified does not have Admin permission for idsite=1');
+
$dummyToken = API::getInstance()->createTokenAuth('test');
$superUserToken = $this->getSuperUserToken();
diff --git a/plugins/BulkTracking/tests/Integration/TrackerTest.php b/plugins/BulkTracking/tests/Integration/TrackerTest.php
index 1f2b25a0b4..4eaafa7088 100644
--- a/plugins/BulkTracking/tests/Integration/TrackerTest.php
+++ b/plugins/BulkTracking/tests/Integration/TrackerTest.php
@@ -36,7 +36,7 @@ class TrackerTest extends BulkTrackingTestCase
*/
private $tracker;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/BulkTracking/tests/System/TrackerTest.php b/plugins/BulkTracking/tests/System/TrackerTest.php
index 3be6fd139e..83365c86b5 100644
--- a/plugins/BulkTracking/tests/System/TrackerTest.php
+++ b/plugins/BulkTracking/tests/System/TrackerTest.php
@@ -26,7 +26,7 @@ class TrackerTest extends SystemTestCase
*/
private $tracker;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/BulkTracking/tests/Unit/RequestsTest.php b/plugins/BulkTracking/tests/Unit/RequestsTest.php
index 8c5bcbe395..1fbc9c793d 100644
--- a/plugins/BulkTracking/tests/Unit/RequestsTest.php
+++ b/plugins/BulkTracking/tests/Unit/RequestsTest.php
@@ -23,7 +23,7 @@ class RequestsTest extends \PHPUnit\Framework\TestCase
*/
private $requests;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->requests = new Requests();
diff --git a/plugins/BulkTracking/tests/Unit/ResponseTest.php b/plugins/BulkTracking/tests/Unit/ResponseTest.php
index 5cf26225b6..f6f182b740 100644
--- a/plugins/BulkTracking/tests/Unit/ResponseTest.php
+++ b/plugins/BulkTracking/tests/Unit/ResponseTest.php
@@ -33,7 +33,7 @@ class ResponseTest extends UnitTestCase
*/
private $response;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php b/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php
index aea0a68c51..0898578b18 100644
--- a/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php
+++ b/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php
@@ -21,7 +21,7 @@ class TwoVisitsWithContents extends Fixture
public $idSite = 1;
public $idGoal1 = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
@@ -91,7 +91,7 @@ class TwoVisitsWithContents extends Fixture
self::checkResponse($vis->doTrackContentImpression('Video Ad', 'movie.mov'));
}
- public function tearDown()
+ public function tearDown(): void
{
}
} \ No newline at end of file
diff --git a/plugins/Contents/tests/System/ContentsTest.php b/plugins/Contents/tests/System/ContentsTest.php
index 363463b4da..d7a4b350a7 100644
--- a/plugins/Contents/tests/System/ContentsTest.php
+++ b/plugins/Contents/tests/System/ContentsTest.php
@@ -45,13 +45,13 @@ class ContentsTest extends SystemTestCase
);
}
- protected function setup()
+ public function setUp(): void
{
- parent::setup();
+ parent::setUp();
Fixture::loadAllTranslations();
}
- protected function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
Fixture::resetTranslations();
diff --git a/plugins/CoreAdminHome/tests/Fixture/DuplicateActions.php b/plugins/CoreAdminHome/tests/Fixture/DuplicateActions.php
index be2bcf4ca9..1038c90f34 100644
--- a/plugins/CoreAdminHome/tests/Fixture/DuplicateActions.php
+++ b/plugins/CoreAdminHome/tests/Fixture/DuplicateActions.php
@@ -142,7 +142,7 @@ class DuplicateActions extends Fixture
)
);
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CoreAdminHome/tests/Fixture/TrackingFailures.php b/plugins/CoreAdminHome/tests/Fixture/TrackingFailures.php
index f8ab0cb808..39b7dc683a 100644
--- a/plugins/CoreAdminHome/tests/Fixture/TrackingFailures.php
+++ b/plugins/CoreAdminHome/tests/Fixture/TrackingFailures.php
@@ -15,7 +15,7 @@ class TrackingFailures extends Fixture
public $idSite = 1;
public $dateTime = '2013-01-02 03:04:05';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CoreAdminHome/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/CoreAdminHome/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index b5c7fcf711..71324f6303 100644
--- a/plugins/CoreAdminHome/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/CoreAdminHome/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -20,14 +20,14 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackFirstVisit();
$this->trackSecondVisit();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/CoreAdminHome/tests/Integration/APITest.php b/plugins/CoreAdminHome/tests/Integration/APITest.php
index a3ddf2a182..ba7e246349 100644
--- a/plugins/CoreAdminHome/tests/Integration/APITest.php
+++ b/plugins/CoreAdminHome/tests/Integration/APITest.php
@@ -30,7 +30,7 @@ class APITest extends \Piwik\Tests\Framework\TestCase\IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->api = API::getInstance();
@@ -39,12 +39,11 @@ class APITest extends \Piwik\Tests\Framework\TestCase\IntegrationTestCase
}
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasSomeAdminAccess
- */
public function test_getTrackingFailures_failsForViewUser()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess');
+
$this->setUser();
$this->api->getTrackingFailures();
}
@@ -58,12 +57,11 @@ class APITest extends \Piwik\Tests\Framework\TestCase\IntegrationTestCase
$this->assertSame(array(), $this->api->getTrackingFailures());
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasSomeAdminAccess
- */
public function test_deleteAllTrackingFailures_failsForViewUser()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess');
+
$this->setUser();
$this->api->deleteAllTrackingFailures();
}
@@ -76,22 +74,20 @@ class APITest extends \Piwik\Tests\Framework\TestCase\IntegrationTestCase
$this->api->deleteAllTrackingFailures();
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasAdminAccess
- */
public function test_deleteTrackingFailure_failsForViewUser()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasAdminAccess');
+
$this->setUser();
$this->api->deleteTrackingFailure(1, 2);
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasAdminAccess
- */
public function test_deleteTrackingFailure_failsForAdminUserIfNotAdminAccessToThatSite()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasAdminAccess');
+
$this->setAdminUser();
$this->api->deleteTrackingFailure(2, 2);
}
diff --git a/plugins/CoreAdminHome/tests/Integration/Commands/DeleteLogsDataTest.php b/plugins/CoreAdminHome/tests/Integration/Commands/DeleteLogsDataTest.php
index 452b20c036..aeb4071324 100644
--- a/plugins/CoreAdminHome/tests/Integration/Commands/DeleteLogsDataTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/Commands/DeleteLogsDataTest.php
@@ -38,7 +38,7 @@ class DeleteLogsDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains('Invalid date range supplied', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('Invalid date range supplied', $this->applicationTester->getDisplay());
}
public function getTestDataForInvalidDateRangeTest()
@@ -64,7 +64,7 @@ class DeleteLogsDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains('Invalid site ID', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('Invalid site ID', $this->applicationTester->getDisplay());
}
/**
@@ -83,7 +83,7 @@ class DeleteLogsDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains('Invalid row limit supplied', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('Invalid row limit supplied', $this->applicationTester->getDisplay());
}
public function getTestDataForInvalidIterationStepTest()
@@ -128,7 +128,7 @@ class DeleteLogsDataTest extends ConsoleCommandTestCase
), $options);
$this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Successfully deleted 19 visits", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Successfully deleted 19 visits", $this->applicationTester->getDisplay());
}
private function setCommandInput($value)
diff --git a/plugins/CoreAdminHome/tests/Integration/Commands/InvalidateReportDataTest.php b/plugins/CoreAdminHome/tests/Integration/Commands/InvalidateReportDataTest.php
index ccbbba8d4d..8b4fefe46c 100644
--- a/plugins/CoreAdminHome/tests/Integration/Commands/InvalidateReportDataTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/Commands/InvalidateReportDataTest.php
@@ -17,7 +17,7 @@ use Piwik\Tests\Framework\TestCase\ConsoleCommandTestCase;
*/
class InvalidateReportDataTest extends ConsoleCommandTestCase
{
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -41,7 +41,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalid date or date range specifier", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalid date or date range specifier", $this->applicationTester->getDisplay());
}
public function getInvalidDateRanges()
@@ -67,7 +67,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalid period type", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalid period type", $this->applicationTester->getDisplay());
}
public function getInvalidPeriodTypes()
@@ -92,7 +92,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalid --sites value", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalid --sites value", $this->applicationTester->getDisplay());
}
public function getInvalidSiteLists()
@@ -117,7 +117,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("The segment condition 'ablksdjfdslkjf' is not valid", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("The segment condition 'ablksdjfdslkjf' is not valid", $this->applicationTester->getDisplay());
}
/**
@@ -139,7 +139,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
foreach ($expectedOutputs as $output) {
- $this->assertContains($output, $this->applicationTester->getDisplay());
+ self::assertStringContainsString($output, $this->applicationTester->getDisplay());
}
}
@@ -155,7 +155,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalidating range periods overlapping 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating range periods overlapping 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_invalidDate()
@@ -170,7 +170,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("The date '2019-01-01,2019-01--09' is not a correct date range", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("The date '2019-01-01,2019-01--09' is not a correct date range", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_onlyOneDate()
@@ -185,7 +185,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("The date '2019-01-01' is not a correct date range", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("The date '2019-01-01' is not a correct date range", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_tooManyDatesInRange()
@@ -200,7 +200,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("The date '2019-01-01,2019-01-09,2019-01-12,2019-01-15' is not a correct date range", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("The date '2019-01-01,2019-01-09,2019-01-12,2019-01-15' is not a correct date range", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_multipleDateRanges()
@@ -215,7 +215,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalidating range periods overlapping 2019-01-01,2019-01-09;2019-01-12,2019-01-15", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating range periods overlapping 2019-01-01,2019-01-09;2019-01-12,2019-01-15", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_invalidateAllPeriodTypesSkipsRangeWhenNotRangeDAte()
@@ -230,8 +230,8 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertNotContains("range", $this->applicationTester->getDisplay());
- $this->assertNotContains("Range", $this->applicationTester->getDisplay());
+ self::assertStringNotContainsString("range", $this->applicationTester->getDisplay());
+ self::assertStringNotContainsString("Range", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateDateRange_invalidateAllPeriodTypes()
@@ -246,11 +246,11 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalidating day periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
- $this->assertContains("Invalidating week periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
- $this->assertContains("Invalidating month periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
- $this->assertContains("Invalidating year periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
- $this->assertContains("Invalidating range periods overlapping 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating day periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating week periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating month periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating year periods in 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating range periods overlapping 2019-01-01,2019-01-09 [segment = ]", $this->applicationTester->getDisplay());
}
public function test_Command_InvalidateAll_multipleDateRanges()
@@ -265,7 +265,7 @@ class InvalidateReportDataTest extends ConsoleCommandTestCase
));
$this->assertEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Invalidating range periods overlapping 2019-01-01,2019-01-09;2019-01-12,2019-01-13 [segment = ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Invalidating range periods overlapping 2019-01-01,2019-01-09;2019-01-12,2019-01-13 [segment = ]", $this->applicationTester->getDisplay());
}
public function getTestDataForSuccessTests()
diff --git a/plugins/CoreAdminHome/tests/Integration/Commands/OptimizeArchiveTablesTest.php b/plugins/CoreAdminHome/tests/Integration/Commands/OptimizeArchiveTablesTest.php
index e6eca03727..cac3f180af 100644
--- a/plugins/CoreAdminHome/tests/Integration/Commands/OptimizeArchiveTablesTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/Commands/OptimizeArchiveTablesTest.php
@@ -18,7 +18,7 @@ use Piwik\Tests\Framework\TestCase\ConsoleCommandTestCase;
*/
class OptimizeArchiveTablesTest extends ConsoleCommandTestCase
{
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/plugins/CoreAdminHome/tests/Integration/Commands/PurgeOldArchiveDataTest.php b/plugins/CoreAdminHome/tests/Integration/Commands/PurgeOldArchiveDataTest.php
index 63d8bfa527..2d5d29c127 100644
--- a/plugins/CoreAdminHome/tests/Integration/Commands/PurgeOldArchiveDataTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/Commands/PurgeOldArchiveDataTest.php
@@ -35,7 +35,7 @@ class PurgeOldArchiveDataTest extends IntegrationTestCase
*/
protected $application;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -57,7 +57,7 @@ class PurgeOldArchiveDataTest extends IntegrationTestCase
self::$fixture->assertInvalidatedArchivesNotPurged(self::$fixture->february);
}
- public function tearDown()
+ public function tearDown(): void
{
PurgeOldArchiveData::$todayOverride = null;
@@ -138,9 +138,9 @@ class PurgeOldArchiveDataTest extends IntegrationTestCase
self::$fixture->assertTemporaryArchivesNotPurged(self::$fixture->january);
self::$fixture->assertCustomRangesNotPurged(self::$fixture->january);
- $this->assertContains("Skipping purge outdated archive data.", $this->applicationTester->getDisplay());
- $this->assertContains("Skipping purge invalidated archive data.", $this->applicationTester->getDisplay());
- $this->assertContains("Skipping OPTIMIZE TABLES.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Skipping purge outdated archive data.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Skipping purge invalidated archive data.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Skipping OPTIMIZE TABLES.", $this->applicationTester->getDisplay());
}
protected function getCommandDisplayOutputErrorMessage()
diff --git a/plugins/CoreAdminHome/tests/Integration/FixDuplicateActionsTest.php b/plugins/CoreAdminHome/tests/Integration/FixDuplicateActionsTest.php
index a17b709f03..6e16c7d867 100644
--- a/plugins/CoreAdminHome/tests/Integration/FixDuplicateActionsTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/FixDuplicateActionsTest.php
@@ -29,7 +29,7 @@ class FixDuplicateActionsTest extends IntegrationTestCase
*/
protected $applicationTester = null;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -54,7 +54,7 @@ class FixDuplicateActionsTest extends IntegrationTestCase
$this->assertDuplicatesFixedInLogConversionTable();
$this->assertDuplicatesFixedInLogConversionItemTable();
- $this->assertContains("Found and deleted 7 duplicate action entries", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Found and deleted 7 duplicate action entries", $this->applicationTester->getDisplay());
$expectedAffectedArchives = array(
array('idsite' => '1', 'server_time' => '2012-01-01'),
@@ -64,7 +64,7 @@ class FixDuplicateActionsTest extends IntegrationTestCase
array('idsite' => '2', 'server_time' => '2012-03-01'),
);
foreach ($expectedAffectedArchives as $archive) {
- $this->assertContains("[ idSite = {$archive['idsite']}, date = {$archive['server_time']} ]", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("[ idSite = {$archive['idsite']}, date = {$archive['server_time']} ]", $this->applicationTester->getDisplay());
}
}
diff --git a/plugins/CoreAdminHome/tests/Integration/Model/DuplicateActionRemoverTest.php b/plugins/CoreAdminHome/tests/Integration/Model/DuplicateActionRemoverTest.php
index 0c3a89c6a4..7add6d6247 100644
--- a/plugins/CoreAdminHome/tests/Integration/Model/DuplicateActionRemoverTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/Model/DuplicateActionRemoverTest.php
@@ -28,7 +28,7 @@ class DuplicateActionRemoverTest extends IntegrationTestCase
*/
private $duplicateActionRemover;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php b/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php
index e849ddafa3..5f5d1c3a02 100644
--- a/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php
@@ -22,21 +22,21 @@ class SetConfigTest extends ConsoleCommandTestCase
{
const TEST_CONFIG_PATH = '/tmp/test.config.ini.php';
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
self::removeTestConfigFile();
parent::setUpBeforeClass();
}
- public function setUp()
+ public function setUp(): void
{
self::removeTestConfigFile();
parent::setUp();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
$this->makeLocalConfigWritable();
@@ -57,7 +57,7 @@ class SetConfigTest extends ConsoleCommandTestCase
$config = $this->makeNewConfig();
$this->assertEquals(array('setting' => 'myvalue'), $config->MySection);
- $this->assertContains('Setting [MySection] setting = "myvalue"', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('Setting [MySection] setting = "myvalue"', $this->applicationTester->getDisplay());
}
/**
@@ -72,7 +72,7 @@ class SetConfigTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains('Invalid assignment string', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('Invalid assignment string', $this->applicationTester->getDisplay());
}
public function getInvalidArgumentsForTest()
@@ -99,7 +99,7 @@ class SetConfigTest extends ConsoleCommandTestCase
));
$this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains('[Piwik\Exception\MissingFilePermissionException]', $this->applicationTester->getDisplay());
+ self::assertStringContainsString('[Piwik\Exception\MissingFilePermissionException]', $this->applicationTester->getDisplay());
}
public function test_Command_SucceedsWhenArgumentsUsed()
@@ -131,7 +131,7 @@ class SetConfigTest extends ConsoleCommandTestCase
$this->assertEquals(array('def'), $config->MySection['object_value']);
$this->assertArrayNotHasKey('other_array_value', $config->MySection);
- $this->assertContains("done.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("done.", $this->applicationTester->getDisplay());
}
/**
@@ -150,7 +150,7 @@ class SetConfigTest extends ConsoleCommandTestCase
$config = self::makeNewConfig();
$this->assertEquals(0, $config->Tracker['debug']);
- $this->assertContains("done.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("done.", $this->applicationTester->getDisplay());
}
public function getOptionsForSettingValueToZeroTests()
diff --git a/plugins/CoreAdminHome/tests/Integration/TasksTest.php b/plugins/CoreAdminHome/tests/Integration/TasksTest.php
index a23d368de4..431ab833f9 100644
--- a/plugins/CoreAdminHome/tests/Integration/TasksTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/TasksTest.php
@@ -58,7 +58,7 @@ class TasksTest extends IntegrationTestCase
*/
private $mail;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -77,7 +77,7 @@ class TasksTest extends IntegrationTestCase
$this->mail = null;
}
- public function tearDown()
+ public function tearDown(): void
{
unset($_GET['trigger']);
diff --git a/plugins/CoreAdminHome/tests/Unit/SetConfig/ConfigSettingManipulationTest.php b/plugins/CoreAdminHome/tests/Unit/SetConfig/ConfigSettingManipulationTest.php
index c50178cc11..b382ec39d8 100644
--- a/plugins/CoreAdminHome/tests/Unit/SetConfig/ConfigSettingManipulationTest.php
+++ b/plugins/CoreAdminHome/tests/Unit/SetConfig/ConfigSettingManipulationTest.php
@@ -51,7 +51,7 @@ class ConfigSettingManipulationTest extends \PHPUnit\Framework\TestCase
*/
private $mockConfig;
- protected function setUp()
+ public function setUp(): void
{
$this->mockConfig = new DumbMockConfig();
$this->mockConfigData = array();
@@ -94,11 +94,12 @@ class ConfigSettingManipulationTest extends \PHPUnit\Framework\TestCase
/**
* @dataProvider getFailureTestDataForMake
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Invalid assignment string
*/
public function test_make_ThrowsWhenInvalidAssignmentStringSupplied($assignmentString)
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Invalid assignment string');
+
ConfigSettingManipulation::make($assignmentString);
}
@@ -113,24 +114,22 @@ class ConfigSettingManipulationTest extends \PHPUnit\Framework\TestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Trying to append to non-array setting value
- */
public function test_manipulate_ThrowsIfAppendingNonArraySetting()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Trying to append to non-array setting value');
+
$this->mockConfig->mockConfigData['General']['config'] = "5";
$manipulation = new ConfigSettingManipulation("General", "config", "10", true);
$manipulation->manipulate($this->mockConfig);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Trying to set non-array value to array setting
- */
public function test_manipulate_ThrowsIfAssigningNonArrayValue_ToArraySetting()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Trying to set non-array value to array setting');
+
$this->mockConfig->mockConfigData['General']['config'] = array("5");
$manipulation = new ConfigSettingManipulation("General", "config", "10", false);
diff --git a/plugins/CoreConsole/tests/System/ArchiveCronTest.php b/plugins/CoreConsole/tests/System/ArchiveCronTest.php
index a40218b669..9cfd47fabb 100644
--- a/plugins/CoreConsole/tests/System/ArchiveCronTest.php
+++ b/plugins/CoreConsole/tests/System/ArchiveCronTest.php
@@ -142,7 +142,7 @@ class ArchiveCronTest extends SystemTestCase
$output = implode("\n", $output);
$this->assertRegExp('/Usage:\s*core:archive/', $output);
- $this->assertNotContains("Starting Piwik reports archiving...", $output);
+ self::assertStringNotContainsString("Starting Piwik reports archiving...", $output);
}
private function setLastRunArchiveOptions()
diff --git a/plugins/CoreHome/tests/Integration/Column/UserIdTest.php b/plugins/CoreHome/tests/Integration/Column/UserIdTest.php
index ef41206d23..a2141bdf84 100644
--- a/plugins/CoreHome/tests/Integration/Column/UserIdTest.php
+++ b/plugins/CoreHome/tests/Integration/Column/UserIdTest.php
@@ -33,7 +33,7 @@ class UserIdTest extends IntegrationTestCase
protected $date = '2014-04-04';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->userId = new UserId();
@@ -45,7 +45,7 @@ class UserIdTest extends IntegrationTestCase
Fixture::createWebsite('2014-01-01 00:00:00');
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
$tables = ArchiveTableCreator::getTablesArchivesInstalled();
diff --git a/plugins/CoreHome/tests/Integration/LoginWhitelistTest.php b/plugins/CoreHome/tests/Integration/LoginWhitelistTest.php
index 0d394fa84f..84bbfe15fd 100644
--- a/plugins/CoreHome/tests/Integration/LoginWhitelistTest.php
+++ b/plugins/CoreHome/tests/Integration/LoginWhitelistTest.php
@@ -42,7 +42,7 @@ class LoginWhitelistTest extends IntegrationTestCase
private $cliMode;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -52,7 +52,7 @@ class LoginWhitelistTest extends IntegrationTestCase
$this->whitelist = new CustomLoginWhitelist();
}
- public function tearDown()
+ public function tearDown(): void
{
Common::$isCliMode = $this->cliMode;
parent::tearDown();
diff --git a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php
index 3883904a2b..93eb87b1d4 100644
--- a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php
+++ b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\CoreHome\tests\Integration\Tracker;
use Piwik\Cache;
use Piwik\CacheId;
use Piwik\Date;
+use Piwik\Plugin\Dimension\VisitDimension;
use Piwik\Plugins\CoreHome\Tracker\VisitRequestProcessor;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\Plugins\SitesManager\API;
@@ -140,8 +141,8 @@ class VisitRequestProcessorTest extends IntegrationTestCase
{
$dimensions = array();
foreach ($dimensionOnNewVisitResults as $onNewVisitResult) {
- $dim = $this->getMockBuilder('Piwik\\Plugin\\Dimension')
- ->setMethods(array('shouldForceNewVisit', 'getColumnName'))
+ $dim = $this->getMockBuilder(VisitDimension::class)
+ ->onlyMethods(array('shouldForceNewVisit', 'getColumnName'))
->getMock();
$dim->expects($this->any())->method('shouldForceNewVisit')->will($this->returnValue($onNewVisitResult));
$dimensions[] = $dim;
diff --git a/plugins/CoreHome/tests/Unit/CoreHomeTest.php b/plugins/CoreHome/tests/Unit/CoreHomeTest.php
index 2811a8f636..11a14c8155 100644
--- a/plugins/CoreHome/tests/Unit/CoreHomeTest.php
+++ b/plugins/CoreHome/tests/Unit/CoreHomeTest.php
@@ -22,7 +22,7 @@ class CoreHomeTest extends \PHPUnit\Framework\TestCase
*/
private $coreHome;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
index 7b28bf339e..6103a23b80 100644
--- a/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
+++ b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
@@ -25,7 +25,7 @@ class TagManagerTeaserTest extends IntegrationTestCase
*/
private $teaser;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php b/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php
index 08cba25cb4..4a2b5faa02 100644
--- a/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php
+++ b/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php
@@ -30,7 +30,7 @@ class UpdateTest extends ConsoleCommandTestCase
private $oldScriptName = null;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -44,7 +44,7 @@ class UpdateTest extends ConsoleCommandTestCase
Updates_2_10_0_b5::$archiveBlobTables = null;
}
- public function tearDown()
+ public function tearDown(): void
{
$_SERVER['SCRIPT_NAME'] = $this->oldScriptName;
@@ -96,7 +96,7 @@ class UpdateTest extends ConsoleCommandTestCase
$this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
// check no update occurred
- $this->assertContains("Everything is already up to date.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Everything is already up to date.", $this->applicationTester->getDisplay());
$this->assertEquals(Version::VERSION, Option::get('version_core'));
}
@@ -112,12 +112,12 @@ class UpdateTest extends ConsoleCommandTestCase
));
$this->assertEquals(1, $result, $this->getCommandDisplayOutputErrorMessage());
- $this->assertContains("Matomo could not be updated! See above for more information.", $this->applicationTester->getDisplay());
+ self::assertStringContainsString("Matomo could not be updated! See above for more information.", $this->applicationTester->getDisplay());
}
private function assertDryRunExecuted($output)
{
- $this->assertContains("Note: this is a Dry Run", $output);
- $this->assertContains(self::EXPECTED_SQL_FROM_2_10, $output);
+ self::assertStringContainsString("Note: this is a Dry Run", $output);
+ self::assertStringContainsString(self::EXPECTED_SQL_FROM_2_10, $output);
}
}
diff --git a/plugins/CoreUpdater/tests/Integration/ReleaseChannelTest.php b/plugins/CoreUpdater/tests/Integration/ReleaseChannelTest.php
index 4e89187926..b133831099 100644
--- a/plugins/CoreUpdater/tests/Integration/ReleaseChannelTest.php
+++ b/plugins/CoreUpdater/tests/Integration/ReleaseChannelTest.php
@@ -41,7 +41,7 @@ class ReleaseChannelTest extends IntegrationTestCase
*/
private $channel;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/CoreUpdater/tests/Integration/UpdateCommunicationTest.php b/plugins/CoreUpdater/tests/Integration/UpdateCommunicationTest.php
index 2e2b883982..a65473414f 100644
--- a/plugins/CoreUpdater/tests/Integration/UpdateCommunicationTest.php
+++ b/plugins/CoreUpdater/tests/Integration/UpdateCommunicationTest.php
@@ -22,7 +22,7 @@ use Piwik\View;
*/
class UpdateCommunicationTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
}
diff --git a/plugins/CoreUpdater/tests/Unit/ModelTest.php b/plugins/CoreUpdater/tests/Unit/ModelTest.php
index 147db69155..d14beb7399 100644
--- a/plugins/CoreUpdater/tests/Unit/ModelTest.php
+++ b/plugins/CoreUpdater/tests/Unit/ModelTest.php
@@ -23,7 +23,7 @@ class ModelTest extends \PHPUnit\Framework\TestCase
*/
private $model;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -42,14 +42,14 @@ class ModelTest extends \PHPUnit\Framework\TestCase
$plugins = $this->model->getPluginsFromDirectoy(PIWIK_INCLUDE_PATH);
$this->assertGreaterThan(40, count($plugins));
- $this->assertContains('/plugins/API', $plugins);
- $this->assertContains('/plugins/Actions', $plugins);
- $this->assertContains('/plugins/Annotations', $plugins);
-
- $this->assertNotContains('/plugins/.', $plugins);
- $this->assertNotContains('/plugins/..', $plugins);
- $this->assertNotContains('/plugins', $plugins);
- $this->assertNotContains('/plugins/', $plugins);
+ self::assertTrue(in_array('/plugins/API', $plugins));
+ self::assertTrue(in_array('/plugins/Actions', $plugins));
+ self::assertTrue(in_array('/plugins/Annotations', $plugins));
+
+ self::assertTrue(!in_array('/plugins/.', $plugins));
+ self::assertTrue(!in_array('/plugins/..', $plugins));
+ self::assertTrue(!in_array('/plugins', $plugins));
+ self::assertTrue(!in_array('/plugins/', $plugins));
foreach ($plugins as $plugin) {
$this->assertTrue(is_dir(PIWIK_INCLUDE_PATH . $plugin));
diff --git a/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php b/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php
index 5ab9f88296..cbcef4b43e 100644
--- a/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php
+++ b/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php
@@ -25,7 +25,7 @@ class SparklinesConfigTest extends IntegrationTestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
FakeAccess::$superUser = true;
@@ -39,7 +39,7 @@ class SparklinesConfigTest extends IntegrationTestCase
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
@@ -118,12 +118,11 @@ class SparklinesConfigTest extends IntegrationTestCase
$this->assertSame($expectedSparkline, $sparklines[''][0]['metrics']['']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Values: 10, 20, 30 Descriptions: Visits, Actions
- */
public function test_addSparkline_shouldThrowAnException_IfValuesDoesNotMatchAmountOfDescriptions()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Values: 10, 20, 30 Descriptions: Visits, Actions');
+
$this->config->addSparkline($this->sparklineParams(), $values = array(10, 20, 30), $description = array('Visits', 'Actions'));
}
diff --git a/plugins/CoreVisualizations/tests/Unit/GraphTest.php b/plugins/CoreVisualizations/tests/Unit/GraphTest.php
index 34c98f7268..2d61fa7f8d 100644
--- a/plugins/CoreVisualizations/tests/Unit/GraphTest.php
+++ b/plugins/CoreVisualizations/tests/Unit/GraphTest.php
@@ -139,10 +139,10 @@ class GraphTest extends \PHPUnit\Framework\TestCase
$dataTable = new DataTable();
$dataTable->setRows(array($row));
- $bar = $this->getMock('Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar',
- array('getDataTable'),
- array('', '')
- );
+ $bar = $this->getMockBuilder('Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar')
+ ->setMethods(['getDataTable'])
+ ->setConstructorArgs(['', ''])
+ ->getMock();
$bar->expects($this->any())
->method('getDataTable')
->will($this->returnValue($dataTable));
diff --git a/plugins/CoreVisualizations/tests/Unit/SparklinesConfigTest.php b/plugins/CoreVisualizations/tests/Unit/SparklinesConfigTest.php
index 27862d31e6..ff709a7fd0 100644
--- a/plugins/CoreVisualizations/tests/Unit/SparklinesConfigTest.php
+++ b/plugins/CoreVisualizations/tests/Unit/SparklinesConfigTest.php
@@ -22,7 +22,7 @@ class SparklinesConfigTest extends \PHPUnit\Framework\TestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
$this->config = new Config();
}
diff --git a/plugins/CustomAlerts b/plugins/CustomAlerts
-Subproject 5633bb4bb70d1c3fd99bef6ecd7cb32b52f7a92
+Subproject afc8bffe283066b04a5a7aa6be1f54b7e94cc70
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
-Subproject b410ab4d5c2e8e3f0a5236a887627f49198554e
+Subproject 3ca3d7f2239a3fc9f44b195eaf7d560992aa7fd
diff --git a/plugins/CustomJsTracker/tests/Integration/ApiTest.php b/plugins/CustomJsTracker/tests/Integration/ApiTest.php
index b8ffa36602..6bd2fc753e 100644
--- a/plugins/CustomJsTracker/tests/Integration/ApiTest.php
+++ b/plugins/CustomJsTracker/tests/Integration/ApiTest.php
@@ -26,7 +26,7 @@ class ApiTest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -35,22 +35,20 @@ class ApiTest extends IntegrationTestCase
$this->api = API::getInstance();
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasSomeAdminAccess
- */
public function test_doesIncludePluginTrackersAutomatically_failsIfNotEnoughPermission()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess');
+
$this->setUser();
$this->api->doesIncludePluginTrackersAutomatically();
}
- /**
- * @expectedException \Piwik\NoAccessException
- * @expectedExceptionMessage checkUserHasSomeAdminAccess
- */
public function test_doesIncludePluginTrackersAutomatically_failsIfNotEnoughPermissionAnonymous()
{
+ $this->expectException(\Piwik\NoAccessException::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess');
+
$this->setAnonymousUser();
$this->api->doesIncludePluginTrackersAutomatically();
}
diff --git a/plugins/CustomJsTracker/tests/Integration/FileTest.php b/plugins/CustomJsTracker/tests/Integration/FileTest.php
index 1457de0336..d64d5d413a 100644
--- a/plugins/CustomJsTracker/tests/Integration/FileTest.php
+++ b/plugins/CustomJsTracker/tests/Integration/FileTest.php
@@ -31,7 +31,7 @@ class FileTest extends IntegrationTestCase
*/
private $dir = '';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->dir = PIWIK_DOCUMENT_ROOT . '/plugins/CustomJsTracker/tests/resources/';
@@ -44,7 +44,7 @@ class FileTest extends IntegrationTestCase
}
}
- public function tearDown()
+ public function tearDown(): void
{
// restore permissions changed by makeNotWritableFile()
chmod($this->dir, 0777);
@@ -152,21 +152,19 @@ class FileTest extends IntegrationTestCase
$this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException
- * @expectedExceptionMessage not readable
- */
public function test_checkReadable_shouldThrowException_IfNotIsReadable()
{
+ $this->expectException(\Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException::class);
+ $this->expectExceptionMessage('not readable');
+
$this->makeNotReadableFile()->checkReadable();
}
- /**
- * @expectedException \Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException
- * @expectedExceptionMessage not writable
- */
public function test_checkWritable_shouldThrowException_IfNotIsWritable()
{
+ $this->expectException(\Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException::class);
+ $this->expectExceptionMessage('not writable');
+
$this->makeNotReadableFile_inNonWritableDirectory()->checkWritable();
}
diff --git a/plugins/CustomJsTracker/tests/Integration/TrackerUpdaterTest.php b/plugins/CustomJsTracker/tests/Integration/TrackerUpdaterTest.php
index 0c0130e5b6..4977037c72 100644
--- a/plugins/CustomJsTracker/tests/Integration/TrackerUpdaterTest.php
+++ b/plugins/CustomJsTracker/tests/Integration/TrackerUpdaterTest.php
@@ -24,7 +24,7 @@ class TrackerUpdaterTest extends IntegrationTestCase
private $dir;
private $trackerJsChangedEventPath = null;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->dir = PIWIK_DOCUMENT_ROOT . '/plugins/CustomJsTracker/tests/resources/';
@@ -33,7 +33,7 @@ class TrackerUpdaterTest extends IntegrationTestCase
$this->cleanUp();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
@@ -112,12 +112,11 @@ class TrackerUpdaterTest extends IntegrationTestCase
$this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException
- * @expectedExceptionMessage not writable
- */
public function test_checkWillSucceed_shouldNotThrowExceptionIfTargetIsNotWritable()
{
+ $this->expectException(\Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException::class);
+ $this->expectExceptionMessage('not writable');
+
$updater = $this->makeUpdater(null, $this->dir . 'not-writable/MyNotExisIngFilessss.js');
$updater->checkWillSucceed();
}
diff --git a/plugins/CustomJsTracker/tests/System/PiwikJsContentTest.php b/plugins/CustomJsTracker/tests/System/PiwikJsContentTest.php
index 300c312984..26bbede5a8 100644
--- a/plugins/CustomJsTracker/tests/System/PiwikJsContentTest.php
+++ b/plugins/CustomJsTracker/tests/System/PiwikJsContentTest.php
@@ -33,7 +33,7 @@ class PiwikJsContentTest extends SystemTestCase
$piwikMin = PIWIK_DOCUMENT_ROOT . '/js/piwik.min.js';
$content = file_get_contents($piwikMin);
- $this->assertContains(PiwikJsManipulator::HOOK, $content);
+ self::assertStringContainsString(PiwikJsManipulator::HOOK, $content);
}
} \ No newline at end of file
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');
}
diff --git a/plugins/Dashboard/tests/Integration/APITest.php b/plugins/Dashboard/tests/Integration/APITest.php
index 42e6a4b0db..ece366f224 100644
--- a/plugins/Dashboard/tests/Integration/APITest.php
+++ b/plugins/Dashboard/tests/Integration/APITest.php
@@ -33,7 +33,7 @@ class APITest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -103,24 +103,22 @@ class APITest extends IntegrationTestCase
$this->assertCount(1, $result);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser
- */
public function testGetDashboardsShouldNotReturnForeignDashboardsForNonSuperUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser');
+
FakeAccess::$superUser = false;
FakeAccess::$identity = 'eva';
$this->api->getDashboards('peter', false);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser
- */
public function testCreateNewDashboardForOtherUserDoesNotWorkForNonSuperUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser');
+
FakeAccess::$superUser = false;
$layout ='[[{"uniqueId":"widgetLivewidget","parameters":{"module":"Live","action":"widget"}}]]';
@@ -168,12 +166,11 @@ class APITest extends IntegrationTestCase
$this->assertEquals($dashboard['layout'], $layout);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Dashboard not found
- */
public function testCopyDashboardToUserFails()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Dashboard not found');
+
$this->api->copyDashboardToUser(5, 'eva', 'new name');
}
diff --git a/plugins/DeviceDetectorCache b/plugins/DeviceDetectorCache
-Subproject 9564937792966a0df33ed03fd6035bbac81e4d4
+Subproject c4066f9ff70a7fb4d1ae1cb1b485fba00506e16
diff --git a/plugins/DevicesDetection/tests/Fixtures/MultiDeviceGoalConversions.php b/plugins/DevicesDetection/tests/Fixtures/MultiDeviceGoalConversions.php
index a1de38c6d4..681476b565 100644
--- a/plugins/DevicesDetection/tests/Fixtures/MultiDeviceGoalConversions.php
+++ b/plugins/DevicesDetection/tests/Fixtures/MultiDeviceGoalConversions.php
@@ -20,7 +20,7 @@ class MultiDeviceGoalConversions extends Fixture
public $idSite = 1;
public $idGoal = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackSmartphoneVisits();
@@ -28,7 +28,7 @@ class MultiDeviceGoalConversions extends Fixture
$this->trackOtherVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Diagnostics/tests/Integration/Commands/AnalyzeArchiveTableTest.php b/plugins/Diagnostics/tests/Integration/Commands/AnalyzeArchiveTableTest.php
index 8402b9506c..168deb6e33 100644
--- a/plugins/Diagnostics/tests/Integration/Commands/AnalyzeArchiveTableTest.php
+++ b/plugins/Diagnostics/tests/Integration/Commands/AnalyzeArchiveTableTest.php
@@ -23,7 +23,7 @@ class AnalyzeArchiveTableTest extends ConsoleCommandTestCase
*/
public static $fixture = null;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/plugins/Diagnostics/tests/Integration/ConfigReaderTest.php b/plugins/Diagnostics/tests/Integration/ConfigReaderTest.php
index f5d78fb1c1..8e95691571 100644
--- a/plugins/Diagnostics/tests/Integration/ConfigReaderTest.php
+++ b/plugins/Diagnostics/tests/Integration/ConfigReaderTest.php
@@ -29,7 +29,7 @@ class ConfigReaderTest extends IntegrationTestCase
*/
private $configReader;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/ExampleLogTables/tests/Fixtures/VisitsWithUserIdAndCustomData.php b/plugins/ExampleLogTables/tests/Fixtures/VisitsWithUserIdAndCustomData.php
index 4324e58d54..22ea04120e 100644
--- a/plugins/ExampleLogTables/tests/Fixtures/VisitsWithUserIdAndCustomData.php
+++ b/plugins/ExampleLogTables/tests/Fixtures/VisitsWithUserIdAndCustomData.php
@@ -19,7 +19,7 @@ class VisitsWithUserIdAndCustomData extends Fixture
private static $countryCodes = ['CA', 'CN', 'DE', 'ES', 'FR', 'IE', 'IN', 'IT', 'MX', 'PT', 'RU', 'GB', 'US'];
- public function setUp()
+ public function setUp(): void
{
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime);
diff --git a/plugins/ExamplePlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/ExamplePlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index 89d99a7005..2d157a44e4 100644
--- a/plugins/ExamplePlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/ExamplePlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -20,14 +20,14 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackFirstVisit();
$this->trackSecondVisit();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/ExamplePlugin/tests/Integration/SimpleTest.php b/plugins/ExamplePlugin/tests/Integration/SimpleTest.php
index 1ccc775838..1612e30d6b 100644
--- a/plugins/ExamplePlugin/tests/Integration/SimpleTest.php
+++ b/plugins/ExamplePlugin/tests/Integration/SimpleTest.php
@@ -18,14 +18,14 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
class SimpleTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
// set up your test here if needed
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
diff --git a/plugins/ExamplePlugin/tests/Unit/SimpleTest.php b/plugins/ExamplePlugin/tests/Unit/SimpleTest.php
index 791d5704f6..0369d0316c 100644
--- a/plugins/ExamplePlugin/tests/Unit/SimpleTest.php
+++ b/plugins/ExamplePlugin/tests/Unit/SimpleTest.php
@@ -15,12 +15,12 @@ namespace Piwik\Plugins\ExamplePlugin\tests\Unit;
*/
class SimpleTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
// set up here if needed
}
- public function tearDown()
+ public function tearDown(): void
{
// tear down here if needed
}
diff --git a/plugins/Feedback/tests/Fixtures/FeedbackPopupFixture.php b/plugins/Feedback/tests/Fixtures/FeedbackPopupFixture.php
index e2ceaeb164..182582034c 100644
--- a/plugins/Feedback/tests/Fixtures/FeedbackPopupFixture.php
+++ b/plugins/Feedback/tests/Fixtures/FeedbackPopupFixture.php
@@ -9,14 +9,14 @@ use Piwik\Tests\Fixtures\UITestFixture;
class FeedbackPopupFixture extends UITestFixture
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$yesterday = Date::yesterday();
Option::set('Feedback.nextFeedbackReminder.superUserLogin', $yesterday->toString('Y-m-d'));
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
Option::delete('Feedback.nextFeedbackReminder.superUserLogin');
diff --git a/plugins/Feedback/tests/Integration/ControllerTest.php b/plugins/Feedback/tests/Integration/ControllerTest.php
index fa39b28bfd..acd95512e3 100644
--- a/plugins/Feedback/tests/Integration/ControllerTest.php
+++ b/plugins/Feedback/tests/Integration/ControllerTest.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Plugins\Feedback\tests\Unit;
+namespace Piwik\Plugins\Feedback\tests\Integration;
use Piwik\Date;
use Piwik\NoAccessException;
@@ -26,7 +26,7 @@ class ControllerTest extends IntegrationTestCase
private $now;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->controller = new Controller();
@@ -47,7 +47,7 @@ class ControllerTest extends IntegrationTestCase
Date::$now = Date::factory('2019-05-31')->getTimestamp();
}
- public function tearDown()
+ public function tearDown(): void
{
Option::deleteLike('Feedback.nextFeedbackReminder.%');
$this->userModel->deleteUserOnly('user1');
@@ -84,9 +84,9 @@ class ControllerTest extends IntegrationTestCase
public function test_updateFeedbackReminder_notLoggedIn()
{
+ $this->expectException(NoAccessException::class);
FakeAccess::$identity = null;
FakeAccess::$superUser = false;
- $this->setExpectedException(NoAccessException::class);
$this->controller->updateFeedbackReminderDate();
}
} \ No newline at end of file
diff --git a/plugins/Feedback/tests/Integration/FeedbackTest.php b/plugins/Feedback/tests/Integration/FeedbackTest.php
index 02031e31f0..072a12186b 100644
--- a/plugins/Feedback/tests/Integration/FeedbackTest.php
+++ b/plugins/Feedback/tests/Integration/FeedbackTest.php
@@ -26,11 +26,11 @@ class FeedbackTest extends IntegrationTestCase
private $now;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
- $this->feedback = $this->getMock(Feedback::class, ['isDisabledInTestMode']);
+ $this->feedback = $this->createPartialMock(Feedback::class, ['isDisabledInTestMode']);
$this->feedback->method('isDisabledInTestMode')->willReturn(false);
$this->userModel = new Model();
@@ -48,7 +48,7 @@ class FeedbackTest extends IntegrationTestCase
$this->now = Date::$now;
}
- public function tearDown()
+ public function tearDown(): void
{
Option::deleteLike('Feedback.nextFeedbackReminder.%');
$this->userModel->deleteUserOnly('user1');
diff --git a/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php b/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php
index abf144ec40..09f207b4fd 100644
--- a/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php
+++ b/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php
@@ -30,7 +30,7 @@ class ConvertRegionCodesToIsoTest extends IntegrationTestCase
protected static $idSite;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -81,7 +81,7 @@ class ConvertRegionCodesToIsoTest extends IntegrationTestCase
Fixture::checkResponse($t->doTrackPageView('It\'s pitch black...'));
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
Option::delete(ConvertRegionCodesToIso::OPTION_NAME);
@@ -115,7 +115,7 @@ class ConvertRegionCodesToIsoTest extends IntegrationTestCase
$result = $this->executeCommand();
- $this->assertContains('All region codes converted', $result);
+ self::assertStringContainsString('All region codes converted', $result);
$queryParams = array(
'idSite' => self::$idSite,
diff --git a/plugins/GeoIp2/tests/Unit/GeoIp2Test.php b/plugins/GeoIp2/tests/Unit/GeoIp2Test.php
index 6b67150ef0..d40a3d1e95 100644
--- a/plugins/GeoIp2/tests/Unit/GeoIp2Test.php
+++ b/plugins/GeoIp2/tests/Unit/GeoIp2Test.php
@@ -14,7 +14,7 @@ use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2;
use Piwik\Plugins\UserCountry\LocationProvider;
use Exception;
-class GeoIp2Test extends \PHPUnit_Framework_TestCase
+class GeoIp2Test extends \PHPUnit\Framework\TestCase
{
/**
* Test that redundant checks work.
@@ -71,7 +71,7 @@ class GeoIp2Test extends \PHPUnit_Framework_TestCase
protected $backUpNames;
- public function setUp()
+ public function setUp(): void
{
$this->backUpNames = GeoIp2::$dbNames;
@@ -81,7 +81,7 @@ class GeoIp2Test extends \PHPUnit_Framework_TestCase
];
}
- public function tearDown()
+ public function tearDown(): void
{
GeoIp2::$dbNames = $this->backUpNames;
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));
diff --git a/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php b/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php
index b6d98eff4b..28c26c0bd2 100644
--- a/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php
+++ b/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php
@@ -21,13 +21,13 @@ class SomeVisitsDifferentPathsOnTwoDays extends Fixture
public $date1 = '2010-12-14';
public $date2 = '2010-12-13';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Insights/tests/Integration/ApiTest.php b/plugins/Insights/tests/Integration/ApiTest.php
index 774a9e54c5..31f3ddba73 100644
--- a/plugins/Insights/tests/Integration/ApiTest.php
+++ b/plugins/Insights/tests/Integration/ApiTest.php
@@ -35,7 +35,7 @@ class ApiTest extends SystemTestCase
private $api;
private $idSite;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -45,7 +45,7 @@ class ApiTest extends SystemTestCase
$this->api = API::getInstance();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
@@ -88,7 +88,7 @@ class ApiTest extends SystemTestCase
'evolutionDifference' => -9
);
- $this->assertInternalType('array', $metadata['report']);
+ self::assertIsArray($metadata['report']);
$this->assertEquals('Actions', $metadata['report']['module']);
$this->assertEquals('getPageUrls', $metadata['report']['action']);
unset($metadata['report']);
diff --git a/plugins/Insights/tests/Integration/ModelTest.php b/plugins/Insights/tests/Integration/ModelTest.php
index 01643700f8..9cde8a09cc 100644
--- a/plugins/Insights/tests/Integration/ModelTest.php
+++ b/plugins/Insights/tests/Integration/ModelTest.php
@@ -18,7 +18,6 @@ use Piwik\Tests\Framework\TestCase\SystemTestCase;
* @group Insights
* @group ModelTest
* @group Plugins
- * @group Plugins
*/
class ModelTest extends SystemTestCase
{
@@ -32,7 +31,7 @@ class ModelTest extends SystemTestCase
*/
private $model;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -101,7 +100,7 @@ class ModelTest extends SystemTestCase
$total = $this->model->getMetricTotalValue($table, 'nb_visits');
$this->assertEquals(17, $total);
- $this->assertInternalType('integer', $total);
+ self::assertIsInt($total);
}
public function test_getMetricTotalValue_shouldReturnZeroIfMetricHasNoTotal()
@@ -114,11 +113,10 @@ class ModelTest extends SystemTestCase
$this->assertEquals(0, $total);
}
- /**
- * @expectedException \Exception
- */
public function test_getLastDate_shouldThrowExceptionIfNotPossibleToGetLastDate()
{
+ $this->expectException(\Exception::class);
+
$this->model->getLastDate('last10', 'day', 1);
}
diff --git a/plugins/Insights/tests/Unit/FilterExcludeLowValueTest.php b/plugins/Insights/tests/Unit/FilterExcludeLowValueTest.php
index 7e9fba07c3..c63dac03b4 100644
--- a/plugins/Insights/tests/Unit/FilterExcludeLowValueTest.php
+++ b/plugins/Insights/tests/Unit/FilterExcludeLowValueTest.php
@@ -20,7 +20,7 @@ use Piwik\Plugins\Insights\DataTable\Filter\ExcludeLowValue;
*/
class FilterExcludeLowValueTest extends BaseUnitTest
{
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->table->addRowsFromArray(array(
diff --git a/plugins/Insights/tests/Unit/FilterInsightTest.php b/plugins/Insights/tests/Unit/FilterInsightTest.php
index bf98eab975..be5acb7324 100644
--- a/plugins/Insights/tests/Unit/FilterInsightTest.php
+++ b/plugins/Insights/tests/Unit/FilterInsightTest.php
@@ -30,7 +30,7 @@ class FilterInsightTest extends BaseUnitTest
*/
private $pastTable;
- public function setUp()
+ public function setUp(): void
{
$this->currentTable = new DataTable();
$this->currentTable->addRowsFromArray(array(
diff --git a/plugins/Insights/tests/Unit/FilterLimitTest.php b/plugins/Insights/tests/Unit/FilterLimitTest.php
index 0eec585b68..184b95467a 100644
--- a/plugins/Insights/tests/Unit/FilterLimitTest.php
+++ b/plugins/Insights/tests/Unit/FilterLimitTest.php
@@ -20,7 +20,7 @@ use Piwik\Plugins\Insights\DataTable\Filter\Limit;
*/
class FilterLimitTest extends BaseUnitTest
{
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->table->addRowsFromArray(array(
diff --git a/plugins/Insights/tests/Unit/FilterMinGrowthTest.php b/plugins/Insights/tests/Unit/FilterMinGrowthTest.php
index 76434ade21..d8740e4203 100644
--- a/plugins/Insights/tests/Unit/FilterMinGrowthTest.php
+++ b/plugins/Insights/tests/Unit/FilterMinGrowthTest.php
@@ -21,7 +21,7 @@ use Piwik\Plugins\Insights\DataTable\Filter\MinGrowth;
class FilterMinGrowthTest extends BaseUnitTest
{
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->table->addRowsFromArray(array(
diff --git a/plugins/Insights/tests/Unit/FilterOrderByTest.php b/plugins/Insights/tests/Unit/FilterOrderByTest.php
index 2b67f7aeb4..d18387eb4c 100644
--- a/plugins/Insights/tests/Unit/FilterOrderByTest.php
+++ b/plugins/Insights/tests/Unit/FilterOrderByTest.php
@@ -21,7 +21,7 @@ use Piwik\Tests\Framework\TestCase\SystemTestCase;
*/
class FilterOrderByTest extends BaseUnitTest
{
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
}
diff --git a/plugins/Insights/tests/Unit/InsightReportTest.php b/plugins/Insights/tests/Unit/InsightReportTest.php
index 34518321ba..98b54a100a 100644
--- a/plugins/Insights/tests/Unit/InsightReportTest.php
+++ b/plugins/Insights/tests/Unit/InsightReportTest.php
@@ -55,7 +55,7 @@ class InsightReportTest extends \PHPUnit\Framework\TestCase
*/
// TODO use data providers
- public function setUp()
+ public function setUp(): void
{
$this->currentTable = new DataTable();
$this->currentTable->addRowsFromArray(array(
@@ -110,12 +110,11 @@ class InsightReportTest extends \PHPUnit\Framework\TestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Unsupported orderBy
- */
public function test_generateInsight_Order_ShouldThrowException_IfInvalid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported orderBy');
+
$this->generateInsight(2, 2, 2, 17, -17, 'InvalidOrDeRbY');
}
@@ -270,7 +269,7 @@ class InsightReportTest extends \PHPUnit\Framework\TestCase
'minDisappearedPercent' => 8,
);
- $this->assertInternalType('array', $metadata['report']);
+ self::assertIsArray($metadata['report']);
$this->assertEquals('TestReport', $metadata['report']['name']);
unset($metadata['report']);
unset($metadata['totals']);
diff --git a/plugins/Installation/tests/System/APITest.php b/plugins/Installation/tests/System/APITest.php
index bd5d6e08f0..79e3fee480 100644
--- a/plugins/Installation/tests/System/APITest.php
+++ b/plugins/Installation/tests/System/APITest.php
@@ -25,7 +25,7 @@ class APITest extends SystemTestCase
*/
public static $fixture = null; // initialized below class definition
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -47,7 +47,7 @@ class APITest extends SystemTestCase
$data = str_replace("\n", "", $response['data']);
$this->assertStringStartsWith('<?xml version="1.0" encoding="utf-8" ?><result> <error message=', $data);
- $this->assertContains('Access denied', $data);
+ self::assertStringContainsString('Access denied', $data);
$this->assertStringEndsWith('</result>', $data);
}
@@ -58,7 +58,7 @@ class APITest extends SystemTestCase
$data = str_replace("\n", "", $response['data']);
$this->assertStringStartsWith('{"result":"error","message":"', $data);
- $this->assertContains('Access denied', $data);
+ self::assertStringContainsString('Access denied', $data);
}
public function test_shouldReturnEmptyResultWhenNotInstalledAndDispatchIsDisabled()
diff --git a/plugins/IntranetMeasurable/tests/Fixtures/IntranetSitesWithVisits.php b/plugins/IntranetMeasurable/tests/Fixtures/IntranetSitesWithVisits.php
index a842449a11..57c09f2f92 100644
--- a/plugins/IntranetMeasurable/tests/Fixtures/IntranetSitesWithVisits.php
+++ b/plugins/IntranetMeasurable/tests/Fixtures/IntranetSitesWithVisits.php
@@ -22,14 +22,14 @@ class IntranetSitesWithVisits extends Fixture
public $idSite = 1;
public $idSiteNotIntranet = 2;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsites();
$this->trackVisits($this->idSite);
$this->trackVisits($this->idSiteNotIntranet);
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php b/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php
index ec0900c0e1..4a58eb9a67 100644
--- a/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php
+++ b/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php
@@ -87,12 +87,13 @@ class LanguagesManagerTest extends \PHPUnit\Framework\TestCase
$translations = $translationWriter->getTranslations($language);
if (empty($translations)) {
+ self::assertTrue(true);
return; // skip language / plugin combinations that aren't present
}
$translationWriter->setTranslations($translations);
- $this->assertTrue($translationWriter->isValid(), $translationWriter->getValidationMessage());
+ $this->assertTrue($translationWriter->isValid(), $translationWriter->getValidationMessage() ?: '');
if ($translationWriter->wasFiltered()) {
@@ -116,11 +117,11 @@ class LanguagesManagerTest extends \PHPUnit\Framework\TestCase
* test language when it's not defined
*
* @group Plugins
- *
- * @expectedException Exception
*/
function testWriterInvalidPlugin()
{
+ $this->expectException(\Exception::class);
+
new Writer('de', 'iNvaLiDPluGin'); // invalid plugin throws exception
}
diff --git a/plugins/LanguagesManager/tests/Integration/ModelTest.php b/plugins/LanguagesManager/tests/Integration/ModelTest.php
index fb0cc94456..975e92021e 100644
--- a/plugins/LanguagesManager/tests/Integration/ModelTest.php
+++ b/plugins/LanguagesManager/tests/Integration/ModelTest.php
@@ -26,7 +26,7 @@ class ModelTest extends IntegrationTestCase
*/
protected $model;
- public function setUp()
+ public function setUp(): void
{
$this->model = new Model();
parent::setUp();
@@ -109,7 +109,7 @@ class ModelTest extends IntegrationTestCase
$tableNames = $this->getCurrentAvailableTableNames();
foreach ($expectedTables as $expectedTable) {
- $this->assertContains(Common::prefixTable($expectedTable), $tableNames);
+ self::assertTrue(in_array(Common::prefixTable($expectedTable), $tableNames));
}
}
@@ -118,7 +118,7 @@ class ModelTest extends IntegrationTestCase
$tableNames = $this->getCurrentAvailableTableNames();
foreach ($expectedTables as $expectedTable) {
- $this->assertNotContains(Common::prefixTable($expectedTable), $tableNames);
+ self::assertTrue(!in_array(Common::prefixTable($expectedTable), $tableNames));
}
}
diff --git a/plugins/LanguagesManager/tests/Unit/TranslationWriter/WriterTest.php b/plugins/LanguagesManager/tests/Unit/TranslationWriter/WriterTest.php
index 62fe32f417..dc2189a426 100644
--- a/plugins/LanguagesManager/tests/Unit/TranslationWriter/WriterTest.php
+++ b/plugins/LanguagesManager/tests/Unit/TranslationWriter/WriterTest.php
@@ -44,11 +44,11 @@ class WriterTest extends \PHPUnit\Framework\TestCase
/**
* @group Core
- *
- * @expectedException \Exception
*/
public function testConstructorInvalid()
{
+ $this->expectException(\Exception::class);
+
new Writer('en', 'InValIdPlUGin');
}
@@ -115,22 +115,22 @@ class WriterTest extends \PHPUnit\Framework\TestCase
/**
* @group Core
- *
- * @expectedException \Exception
*/
public function testSaveException()
{
+ $this->expectException(\Exception::class);
+
$writer = new Writer('it');
$writer->save();
}
/**
* @group Core
- *
- * @expectedException \Exception
*/
public function testSaveTemporaryException()
{
+ $this->expectException(\Exception::class);
+
$writer = new Writer('it');
$writer->saveTemporary();
}
@@ -241,11 +241,12 @@ class WriterTest extends \PHPUnit\Framework\TestCase
/**
* @group Core
*
- * @expectedException \Exception
* @dataProvider getInvalidLanguages
*/
public function testSetLanguageInvalid($language)
{
+ $this->expectException(\Exception::class);
+
$writer = new Writer('en', null);
$writer->setLanguage($language);
}
diff --git a/plugins/Live/tests/Fixtures/ManyVisitsOfSameVisitor.php b/plugins/Live/tests/Fixtures/ManyVisitsOfSameVisitor.php
index d2bcb9f302..a2d7db247f 100644
--- a/plugins/Live/tests/Fixtures/ManyVisitsOfSameVisitor.php
+++ b/plugins/Live/tests/Fixtures/ManyVisitsOfSameVisitor.php
@@ -19,7 +19,7 @@ class ManyVisitsOfSameVisitor extends Fixture
public $idSite = 1;
public $idSite2 = 2;
- public function setUp()
+ public function setUp(): void
{
if (!self::siteCreated($this->idSite)) {
self::createWebsite($this->dateTime);
@@ -32,7 +32,7 @@ class ManyVisitsOfSameVisitor extends Fixture
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Live/tests/Fixtures/VisitsWithAllActionsAndDevices.php b/plugins/Live/tests/Fixtures/VisitsWithAllActionsAndDevices.php
index d21bed8221..f61aa3b16f 100644
--- a/plugins/Live/tests/Fixtures/VisitsWithAllActionsAndDevices.php
+++ b/plugins/Live/tests/Fixtures/VisitsWithAllActionsAndDevices.php
@@ -20,7 +20,7 @@ class VisitsWithAllActionsAndDevices extends Fixture
public $dateTime = '2010-02-01 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime, 1);
@@ -64,7 +64,7 @@ class VisitsWithAllActionsAndDevices extends Fixture
$this->trackVisitTablet($t, Date::factory($this->dateTime)->addHour(156.9)->getDatetime());
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Live/tests/Integration/ModelTest.php b/plugins/Live/tests/Integration/ModelTest.php
index eeede80c97..ea2b104732 100644
--- a/plugins/Live/tests/Integration/ModelTest.php
+++ b/plugins/Live/tests/Integration/ModelTest.php
@@ -27,7 +27,7 @@ use Piwik\Tests\Integration\SegmentTest;
*/
class ModelTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -87,13 +87,12 @@ class ModelTest extends IntegrationTestCase
$this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException
- * @expectedExceptionMessage Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonUnknown
- */
public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_noReasonFound()
{
- $db = Db::get();
+ $this->expectException(\Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException::class);
+ $this->expectExceptionMessage('Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonUnknown');
+
+ $db = Db::get();
$e = new \Exception('[3024] Query execution was interrupted, maximum statement execution time exceeded');
$sql = 'SELECT 1';
$bind = array();
@@ -106,13 +105,12 @@ class ModelTest extends IntegrationTestCase
$model->handleMaxExecutionTimeError($db, $e, $sql, $bind, $segment, $dateStart, $dateEnd, $minTimestamp, $limit);
}
- /**
- * @expectedException \Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException
- * @expectedExceptionMessage Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonDateRange Live_QueryMaxExecutionTimeExceededReasonSegment Live_QueryMaxExecutionTimeExceededLimit
- */
public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_manyReasonsFound()
{
- $db = Db::get();
+ $this->expectException(\Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException::class);
+ $this->expectExceptionMessage('Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonDateRange Live_QueryMaxExecutionTimeExceededReasonSegment Live_QueryMaxExecutionTimeExceededLimit');
+
+ $db = Db::get();
$e = new \Exception('Query execution was interrupted, maximum statement execution time exceeded');
$sql = 'SELECT 1';
$bind = array();
diff --git a/plugins/Live/tests/System/ApiCounterTest.php b/plugins/Live/tests/System/ApiCounterTest.php
index c71a62a850..58cf83fbb1 100644
--- a/plugins/Live/tests/System/ApiCounterTest.php
+++ b/plugins/Live/tests/System/ApiCounterTest.php
@@ -35,14 +35,14 @@ class ApiCounterTest extends SystemTestCase
private $api;
private $idSite = 1;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
self::$testNow = strtotime('2018-02-03 04:45:40');
parent::setUpBeforeClass();
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -51,12 +51,11 @@ class ApiCounterTest extends SystemTestCase
$this->createSite();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasViewAccess Fake exception
- */
public function test_GetCounters_ShouldFail_IfUserHasNoPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasViewAccess Fake exception');
+
$this->setAnonymous();
$this->api->getCounters($this->idSite, 5);
}
diff --git a/plugins/LogViewer b/plugins/LogViewer
-Subproject 3eced789364b3762e8365805164c94d1255324a
+Subproject deb890ba053b8ee03f3c3a8b7228d333c39fed6
diff --git a/plugins/Login/tests/Integration/APITest.php b/plugins/Login/tests/Integration/APITest.php
index 9c09ccfa92..c250abfa46 100644
--- a/plugins/Login/tests/Integration/APITest.php
+++ b/plugins/Login/tests/Integration/APITest.php
@@ -24,19 +24,18 @@ class APITest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->api = API::getInstance();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess
- */
public function test_unblockBruteForceIPs_requiresSuperUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess');
+
FakeAccess::clearAccess(false, array(1,2,3));
$this->api->unblockBruteForceIPs();
}
diff --git a/plugins/Login/tests/Integration/LoginTest.php b/plugins/Login/tests/Integration/LoginTest.php
index ee76537ed3..a0351b5ea1 100644
--- a/plugins/Login/tests/Integration/LoginTest.php
+++ b/plugins/Login/tests/Integration/LoginTest.php
@@ -30,7 +30,7 @@ class LoginTest extends IntegrationTestCase
*/
private $auth;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Login/tests/Integration/PasswordResetterTest.php b/plugins/Login/tests/Integration/PasswordResetterTest.php
index f3603c7aca..89abe3ee8d 100644
--- a/plugins/Login/tests/Integration/PasswordResetterTest.php
+++ b/plugins/Login/tests/Integration/PasswordResetterTest.php
@@ -39,7 +39,7 @@ class PasswordResetterTest extends IntegrationTestCase
*/
private $passwordResetter;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->passwordResetter = new PasswordResetter();
@@ -83,12 +83,11 @@ class PasswordResetterTest extends IntegrationTestCase
$this->assertNotEquals($token, $this->capturedToken);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage You have requested too many password resets recently. A new request can be made in one hour. If you have problems resetting your password, please contact your administrator for help.
- */
public function test_passwordReset_notAllowedMoreThanThreeTimesInAnHour()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('You have requested too many password resets recently. A new request can be made in one hour. If you have problems resetting your password, please contact your administrator for help.');
+
$this->passwordResetter->initiatePasswordResetProcess('superUserLogin', self::NEWPASSWORD);
$this->assertNotEmpty($this->capturedToken);
@@ -124,12 +123,11 @@ class PasswordResetterTest extends IntegrationTestCase
$this->assertEquals(1, $data['requests']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Token is invalid or has expired
- */
public function test_passwordReset_shouldNotAllowTokenToBeUsedMoreThanOnce()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Token is invalid or has expired');
+
$this->passwordResetter->initiatePasswordResetProcess('superUserLogin', self::NEWPASSWORD);
$this->assertNotEmpty($this->capturedToken);
@@ -157,12 +155,11 @@ class PasswordResetterTest extends IntegrationTestCase
$this->assertNotEquals($oldCapturedToken, $this->capturedToken);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Token is invalid or has expired
- */
public function test_passwordReset_shouldNotAllowOldTokenToBeUsedAfterAnotherResetRequest()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Token is invalid or has expired');
+
$this->passwordResetter->initiatePasswordResetProcess('superUserLogin', self::NEWPASSWORD);
$this->assertNotEmpty($this->capturedToken);
diff --git a/plugins/Login/tests/Integration/PasswordVerifierTest.php b/plugins/Login/tests/Integration/PasswordVerifierTest.php
index a169e5e723..7a84f44e7e 100644
--- a/plugins/Login/tests/Integration/PasswordVerifierTest.php
+++ b/plugins/Login/tests/Integration/PasswordVerifierTest.php
@@ -27,7 +27,7 @@ class PasswordVerifierTest extends IntegrationTestCase
*/
private $verifier;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php b/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php
index d258d9d3d4..187a747fd9 100644
--- a/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php
+++ b/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php
@@ -50,7 +50,7 @@ class BruteForceDetectionTest extends IntegrationTestCase
*/
private $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Login/tests/Integration/SessionInitializerTest.php b/plugins/Login/tests/Integration/SessionInitializerTest.php
index c10c4d920d..c2215de7a9 100644
--- a/plugins/Login/tests/Integration/SessionInitializerTest.php
+++ b/plugins/Login/tests/Integration/SessionInitializerTest.php
@@ -22,7 +22,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class SessionInitializerTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -69,7 +69,7 @@ class SessionInitializerTest extends IntegrationTestCase
private function assertAuthCookieIsCreated(Cookie $cookie)
{
- $this->assertContains('login=czo5OiJ0ZXN0bG9naW4iOw==:token_auth=czozMjoiOWU5MDYxZjk2MDI0YTY3NWFmOGFkNWZmNmNiZGY2ZGMiOw==',
+ self::assertStringContainsString('login=czo5OiJ0ZXN0bG9naW4iOw==:token_auth=czozMjoiOWU5MDYxZjk2MDI0YTY3NWFmOGFkNWZmNmNiZGY2ZGMiOw==',
$cookie->generateContentString());
}
diff --git a/plugins/Login/tests/Integration/SystemSettingsTest.php b/plugins/Login/tests/Integration/SystemSettingsTest.php
index 8bf1a83afe..f1aa859b8c 100644
--- a/plugins/Login/tests/Integration/SystemSettingsTest.php
+++ b/plugins/Login/tests/Integration/SystemSettingsTest.php
@@ -30,7 +30,7 @@ class SystemSettingsTest extends IntegrationTestCase
'2001:0db8:85a3:0000:0000:8a2e:0370:7334'
);
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -63,12 +63,11 @@ class SystemSettingsTest extends IntegrationTestCase
$this->assertSame($this->exampleIps, $this->settings->whitelisteBruteForceIps->getValue());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage SitesManager_ExceptionInvalidIPFormat
- */
public function test_whitelisteBruteForceIps_failsWhenContainsInvalidValue()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('SitesManager_ExceptionInvalidIPFormat');
+
$this->settings->whitelisteBruteForceIps->setValue(array(
'127.0.0.1', 'foobar'
));
@@ -100,12 +99,11 @@ class SystemSettingsTest extends IntegrationTestCase
$this->assertSame($this->exampleIps, $this->settings->blacklistedBruteForceIps->getValue());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage SitesManager_ExceptionInvalidIPFormat
- */
public function test_blacklistedBruteForceIps_failsWhenContainsInvalidValue()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('SitesManager_ExceptionInvalidIPFormat');
+
$this->settings->blacklistedBruteForceIps->setValue(array(
'127.0.0.1', 'foobar'
));
diff --git a/plugins/LoginLdap b/plugins/LoginLdap
-Subproject 79c85ea17b40484454665d0a93e3dfd43fb2c63
+Subproject 7531f1eafb3963e5e42042cfc1a7182277e813c
diff --git a/plugins/MarketingCampaignsReporting b/plugins/MarketingCampaignsReporting
-Subproject 1ba5f4eb0169aaf0670f6ab3d4b1153b6114f31
+Subproject b87a943191646c15bebffddca252e6b5d5c8dde
diff --git a/plugins/Marketplace/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/Marketplace/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index 1da808af4e..dd16938ba9 100644
--- a/plugins/Marketplace/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/Marketplace/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -15,13 +15,13 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Marketplace/tests/Integration/ApiTest.php b/plugins/Marketplace/tests/Integration/ApiTest.php
index 86769daea5..15dc2a28fa 100644
--- a/plugins/Marketplace/tests/Integration/ApiTest.php
+++ b/plugins/Marketplace/tests/Integration/ApiTest.php
@@ -35,7 +35,7 @@ class ApiTest extends IntegrationTestCase
*/
private $service;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -50,22 +50,20 @@ class ApiTest extends IntegrationTestCase
$this->setSuperUser();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess
- */
public function test_deleteLicenseKey_requiresSuperUserAccess_IfUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess');
+
$this->setUser();
$this->api->deleteLicenseKey();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess
- */
public function test_deleteLicenseKey_requiresSuperUserAccess_IfAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess');
+
$this->setAnonymousUser();
$this->api->deleteLicenseKey();
}
@@ -80,32 +78,29 @@ class ApiTest extends IntegrationTestCase
$this->assertNotHasLicenseKey();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess
- */
public function test_saveLicenseKey_requiresSuperUserAccess_IfUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess');
+
$this->setUser();
$this->api->saveLicenseKey('key');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess
- */
public function test_saveLicenseKey_requiresSuperUserAccess_IfAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess');
+
$this->setAnonymousUser();
$this->api->saveLicenseKey('key');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Marketplace_ExceptionLinceseKeyIsNotValid
- */
public function test_saveLicenseKey_shouldThrowException_IfTokenIsNotValid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Marketplace_ExceptionLinceseKeyIsNotValid');
+
$this->service->returnFixture('v2.0_consumer_validate-access_token-notexistingtoken.json');
$this->api->saveLicenseKey('key');
}
@@ -137,12 +132,11 @@ class ApiTest extends IntegrationTestCase
$this->assertSame('123licensekey', $this->buildLicenseKey()->get());
}
- /**
- * @expectedExceptionMessage Host not reachable
- * @expectedException \Piwik\Plugins\Marketplace\Api\Service\Exception
- */
public function test_saveLicenseKey_shouldThrowException_IfConnectionToMarketplaceFailed()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class);
+ $this->expectExceptionMessage('Host not reachable');
+
$this->service->throwException(new ServiceException('Host not reachable', ServiceException::HTTP_ERROR));
$success = $this->api->saveLicenseKey('123licensekey');
$this->assertTrue($success);
diff --git a/plugins/Marketplace/tests/Integration/ClientTest.php b/plugins/Marketplace/tests/Integration/ClientTest.php
index 96f9cb1779..777ce4393b 100644
--- a/plugins/Marketplace/tests/Integration/ClientTest.php
+++ b/plugins/Marketplace/tests/Integration/ClientTest.php
@@ -32,7 +32,7 @@ class ClientTest extends IntegrationTestCase
*/
private $service;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -54,12 +54,11 @@ class ClientTest extends IntegrationTestCase
$this->assertStringEndsWith('.zip', $file);
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Exception
- * @expectedExceptionMessage Requested plugin does not exist.
- */
public function test_getPluginInfo_shouldThrowException_IfNotAllowedToRequestPlugin()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Exception::class);
+ $this->expectExceptionMessage('Requested plugin does not exist.');
+
$this->service->returnFixture('v2.0_plugins_CustomPlugin1_info-access_token-notexistingtoken.json');
$this->client->getPluginInfo('CustomPlugin1');
}
diff --git a/plugins/Marketplace/tests/Integration/EnvironmentTest.php b/plugins/Marketplace/tests/Integration/EnvironmentTest.php
index 677950fea6..d928f7b44a 100644
--- a/plugins/Marketplace/tests/Integration/EnvironmentTest.php
+++ b/plugins/Marketplace/tests/Integration/EnvironmentTest.php
@@ -28,7 +28,7 @@ class EnvironmentTest extends IntegrationTestCase
*/
private $environment;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php b/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php
index fe0e3a2fbc..24ad6b6c97 100644
--- a/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php
+++ b/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php
@@ -19,7 +19,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class PluginNameTest extends IntegrationTestCase
{
- public function tearDown()
+ public function tearDown(): void
{
unset($_GET['pluginName']);
}
@@ -32,12 +32,11 @@ class PluginNameTest extends IntegrationTestCase
$this->assertSame('CoreFooBar', $pluginName->getPluginName());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid plugin name given
- */
public function test_throws_exception_ifInvalidName()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid plugin name given');
+
$this->setPluginName('CoreFooBar-?4');
$pluginName = new PluginName();
diff --git a/plugins/Marketplace/tests/Integration/LicenseKeyTest.php b/plugins/Marketplace/tests/Integration/LicenseKeyTest.php
index ff7918aec5..c1e147165c 100644
--- a/plugins/Marketplace/tests/Integration/LicenseKeyTest.php
+++ b/plugins/Marketplace/tests/Integration/LicenseKeyTest.php
@@ -24,7 +24,7 @@ class LicenseKeyTest extends IntegrationTestCase
*/
private $licenseKey;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php
index 1508ba67eb..cbb94fd501 100644
--- a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php
+++ b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php
@@ -47,7 +47,7 @@ class InvalidLicensesTest extends IntegrationTestCase
private $cacheKey = 'Marketplace_ExpiredPlugins';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -56,7 +56,7 @@ class InvalidLicensesTest extends IntegrationTestCase
$this->cache = new Eager(new ArrayCache(), 'test');
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/plugins/Marketplace/tests/Integration/PluginsTest.php b/plugins/Marketplace/tests/Integration/PluginsTest.php
index aa1fe2a642..d3b0a73bb8 100644
--- a/plugins/Marketplace/tests/Integration/PluginsTest.php
+++ b/plugins/Marketplace/tests/Integration/PluginsTest.php
@@ -41,7 +41,7 @@ class PluginsTest extends IntegrationTestCase
*/
private $consumerService;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -87,7 +87,7 @@ class PluginsTest extends IntegrationTestCase
'TreemapVisualization',
);
foreach ($expected as $name) {
- $this->assertContains($name, $pluginNames);
+ self::assertTrue(in_array($name, $pluginNames));
}
}
@@ -398,9 +398,9 @@ class PluginsTest extends IntegrationTestCase
}
if ($plugin['owner'] === 'PiwikPRO') {
- $this->assertContains($piwikProCampaign, $plugin['homepage']);
+ self::assertStringContainsString($piwikProCampaign, $plugin['homepage']);
} else {
- $this->assertNotContains($piwikProCampaign, $plugin['homepage']);
+ self::assertStringNotContainsString($piwikProCampaign, $plugin['homepage']);
}
}
}
diff --git a/plugins/Marketplace/tests/Integration/ServiceTest.php b/plugins/Marketplace/tests/Integration/ServiceTest.php
index 4852e9ba07..6fea2f109b 100644
--- a/plugins/Marketplace/tests/Integration/ServiceTest.php
+++ b/plugins/Marketplace/tests/Integration/ServiceTest.php
@@ -25,31 +25,29 @@ class ServiceTest extends IntegrationTestCase
*/
private $service;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->service = new TestService();
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Service\Exception
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Requested plugin does not exist.
- */
public function test_fetch_throwsApiError_WhenMarketplaceReturnsAnError()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class);
+ $this->expectExceptionCode(101);
+ $this->expectExceptionMessage('Requested plugin does not exist.');
+
$this->service->returnFixture('v2.0_plugins_CustomPlugin1_info-access_token-notexistingtoken.json');
$this->service->fetch('plugins/CustomPlugin1/info', array());
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Service\Exception
- * @expectedExceptionCode 100
- * @expectedExceptionMessage There was an error reading the response from the Marketplace
- */
public function test_fetch_throwsHttpError_WhenMarketplaceReturnsNoResultWhichMeansHttpError()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class);
+ $this->expectExceptionCode(100);
+ $this->expectExceptionMessage('There was an error reading the response from the Marketplace');
+
$this->service->setOnDownloadCallback(function () {
return null;
});
diff --git a/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php b/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php
index d862a22cea..16ffe3e530 100644
--- a/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php
+++ b/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php
@@ -33,7 +33,7 @@ class UpdateCommunicationTest extends IntegrationTestCase
*/
private $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Marketplace/tests/System/Api/ClientTest.php b/plugins/Marketplace/tests/System/Api/ClientTest.php
index 230fcf2a3a..6673cef597 100644
--- a/plugins/Marketplace/tests/System/Api/ClientTest.php
+++ b/plugins/Marketplace/tests/System/Api/ClientTest.php
@@ -40,7 +40,7 @@ class ClientTest extends SystemTestCase
*/
private $environment;
- public function setUp()
+ public function setUp(): void
{
$releaseChannels = new Plugin\ReleaseChannels(Plugin\Manager::getInstance());
$this->environment = new Environment($releaseChannels);
@@ -108,12 +108,11 @@ class ClientTest extends SystemTestCase
$this->assertNotEmpty($lastVersion['download']);
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Exception
- * @expectedExceptionMessage Requested plugin does not exist.
- */
public function test_getPluginInfo_shouldThrowException_IfPluginDoesNotExistOnMarketplace()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Exception::class);
+ $this->expectExceptionMessage('Requested plugin does not exist.');
+
$this->client->getPluginInfo('NotExistingPlugIn');
}
@@ -176,7 +175,7 @@ class ClientTest extends SystemTestCase
$this->assertLessThan(30, count($plugins));
foreach ($plugins as $plugin) {
- $this->assertContains($keywords, $plugin['keywords']);
+ self::assertStringContainsString($keywords, $plugin['keywords']);
}
}
@@ -236,7 +235,7 @@ class ClientTest extends SystemTestCase
$this->assertTrue($cache->contains($id));
$cachedPlugins = $cache->fetch($id);
- $this->assertInternalType('array', $cachedPlugins);
+ self::assertIsArray($cachedPlugins);
$this->assertNotEmpty($cachedPlugins);
$this->assertGreaterThan(30, $cachedPlugins);
}
@@ -283,7 +282,7 @@ class ClientTest extends SystemTestCase
$this->assertSame(array('plugins', 'release_channel', 'prefer_stable', 'piwik', 'php', 'mysql', 'num_users', 'num_websites'), array_keys($service->params));
$plugins = $service->params['plugins'];
- $this->assertInternalType('string', $plugins);
+ self::assertIsString($plugins);
$this->assertJson($plugins);
$plugins = json_decode($plugins, true);
diff --git a/plugins/Marketplace/tests/System/Api/ServiceTest.php b/plugins/Marketplace/tests/System/Api/ServiceTest.php
index 262b4e6d7b..7725cacaa4 100644
--- a/plugins/Marketplace/tests/System/Api/ServiceTest.php
+++ b/plugins/Marketplace/tests/System/Api/ServiceTest.php
@@ -85,28 +85,26 @@ class ServiceTest extends SystemTestCase
$this->assertLessThan(20, count($response['plugins']));
foreach ($response['plugins'] as $plugin) {
- $this->assertContains($keyword, $plugin['keywords']);
+ self::assertTrue(in_array($keyword, $plugin['keywords']));
}
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Service\Exception
- * @expectedExceptionMessage Not authenticated
- * @expectedExceptionCode 101
- */
public function test_fetch_shouldThrowException_WhenNotBeingAuthenticated()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class);
+ $this->expectExceptionCode(101);
+ $this->expectExceptionMessage('Not authenticated');
+
$service = $this->buildService();
$service->fetch('consumer', array());
}
- /**
- * @expectedException \Piwik\Plugins\Marketplace\Api\Service\Exception
- * @expectedExceptionMessage Not authenticated
- * @expectedExceptionCode 101
- */
public function test_fetch_shouldThrowException_WhenBeingAuthenticatedWithInvalidTokens()
{
+ $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class);
+ $this->expectExceptionCode(101);
+ $this->expectExceptionMessage('Not authenticated');
+
$service = $this->buildService();
$service->authenticate('1234567890');
$service->fetch('consumer', array());
@@ -117,7 +115,7 @@ class ServiceTest extends SystemTestCase
$service = $this->buildService();
$response = $service->download($this->domain . '/api/2.0/plugins');
- $this->assertInternalType('string', $response);
+ self::assertIsString($response);
$this->assertNotEmpty($response);
$this->assertStringStartsWith('{"plugins"', $response);
}
diff --git a/plugins/Marketplace/tests/Unit/ConsumerTest.php b/plugins/Marketplace/tests/Unit/ConsumerTest.php
index 52e9cd063e..3d4a9189f7 100644
--- a/plugins/Marketplace/tests/Unit/ConsumerTest.php
+++ b/plugins/Marketplace/tests/Unit/ConsumerTest.php
@@ -24,7 +24,7 @@ class ConsumerTest extends \PHPUnit\Framework\TestCase
*/
private $service;
- public function setUp()
+ public function setUp(): void
{
$this->service = new Service();
}
diff --git a/plugins/MobileMessaging/tests/Integration/MobileMessagingTest.php b/plugins/MobileMessaging/tests/Integration/MobileMessagingTest.php
index 6eb8eed707..144fdcf449 100644
--- a/plugins/MobileMessaging/tests/Integration/MobileMessagingTest.php
+++ b/plugins/MobileMessaging/tests/Integration/MobileMessagingTest.php
@@ -25,7 +25,7 @@ class MobileMessagingTest extends IntegrationTestCase
{
protected $idSiteAccess;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Monolog/tests/Integration/LogTest.php b/plugins/Monolog/tests/Integration/LogTest.php
index 0f2c32ec84..b528fff1c9 100644
--- a/plugins/Monolog/tests/Integration/LogTest.php
+++ b/plugins/Monolog/tests/Integration/LogTest.php
@@ -34,7 +34,7 @@ class LogTest extends IntegrationTestCase
public static $expectedErrorOutput = '[Monolog] [%s] dummyerrorfile.php(145): Unknown error (102) - dummy error string
dummy backtrace';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -44,7 +44,7 @@ class LogTest extends IntegrationTestCase
Log::$debugBacktraceForTests = "dummy backtrace";
}
- public function tearDown()
+ public function tearDown(): void
{
Log::unsetInstance();
diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php
index f0281e47eb..f4ff5598db 100644
--- a/plugins/Monolog/tests/System/TrackerLoggingTest.php
+++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php
@@ -24,7 +24,7 @@ class TrackerLoggingTest extends SystemTestCase
{
private $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php
index 02246001c6..8dab6f9701 100644
--- a/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php
+++ b/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php
@@ -16,15 +16,15 @@ use Piwik\Plugins\Monolog\Processor\RequestIdProcessor;
* @group Log
* @covers \Piwik\Plugins\Monolog\Processor\RequestIdProcessor
*/
-class RequestIdProcessorTest extends \PHPUnit\Framework\TestCase
+class RequestIdProcessorTest extends TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Common::$isCliMode = false;
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
Common::$isCliMode = true;
@@ -40,7 +40,7 @@ class RequestIdProcessorTest extends \PHPUnit\Framework\TestCase
$result = $processor(array());
$this->assertArrayHasKey('request_id', $result['extra']);
- $this->assertInternalType('string', $result['extra']['request_id']);
+ self::assertIsString($result['extra']['request_id']);
$this->assertNotEmpty($result['extra']['request_id']);
}
diff --git a/plugins/MultiSites/tests/Fixtures/ManySitesWithVisits.php b/plugins/MultiSites/tests/Fixtures/ManySitesWithVisits.php
index 8305ad9b33..e8dc82b5cf 100644
--- a/plugins/MultiSites/tests/Fixtures/ManySitesWithVisits.php
+++ b/plugins/MultiSites/tests/Fixtures/ManySitesWithVisits.php
@@ -20,7 +20,7 @@ class ManySitesWithVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackFirstVisit($this->idSite);
@@ -31,7 +31,7 @@ class ManySitesWithVisits extends Fixture
$this->trackSecondVisit($siteId = 4);
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/MultiSites/tests/Integration/DashboardTest.php b/plugins/MultiSites/tests/Integration/DashboardTest.php
index b892e230e2..c382bc4790 100644
--- a/plugins/MultiSites/tests/Integration/DashboardTest.php
+++ b/plugins/MultiSites/tests/Integration/DashboardTest.php
@@ -29,7 +29,7 @@ class DashboardTest extends IntegrationTestCase
private $numSitesToCreate = 3;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/MultiSites/tests/Integration/MultiSitesTest.php b/plugins/MultiSites/tests/Integration/MultiSitesTest.php
index 38505af702..d3d1b5eb59 100644
--- a/plugins/MultiSites/tests/Integration/MultiSitesTest.php
+++ b/plugins/MultiSites/tests/Integration/MultiSitesTest.php
@@ -23,7 +23,7 @@ class MultiSitesTest extends IntegrationTestCase
{
protected $idSiteAccess;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -68,9 +68,9 @@ class MultiSitesTest extends IntegrationTestCase
$output = FrontController::getInstance()->fetchDispatch('API');
- $this->assertContains('<item>', $output);
- $this->assertContains('</rss>', $output);
- $this->assertNotContains('error', $output);
+ self::assertStringContainsString('<item>', $output);
+ self::assertStringContainsString('</rss>', $output);
+ self::assertStringNotContainsString('error', $output);
$_GET = array();
}
diff --git a/plugins/PrivacyManager/tests/Fixtures/FewVisitsAnonymizedFixture.php b/plugins/PrivacyManager/tests/Fixtures/FewVisitsAnonymizedFixture.php
index 9b11219ef0..19906d9560 100644
--- a/plugins/PrivacyManager/tests/Fixtures/FewVisitsAnonymizedFixture.php
+++ b/plugins/PrivacyManager/tests/Fixtures/FewVisitsAnonymizedFixture.php
@@ -20,7 +20,7 @@ class FewVisitsAnonymizedFixture extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
Option::set(PrivacyManager::OPTION_USERID_SALT, 'simpleuseridsalt1');
Cache::clearCacheGeneral();
@@ -30,7 +30,7 @@ class FewVisitsAnonymizedFixture extends Fixture
$this->trackAnonymizedOrderId();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/PrivacyManager/tests/Fixtures/MultipleSitesMultipleVisitsFixture.php b/plugins/PrivacyManager/tests/Fixtures/MultipleSitesMultipleVisitsFixture.php
index 37ba33c83b..69252ff65e 100644
--- a/plugins/PrivacyManager/tests/Fixtures/MultipleSitesMultipleVisitsFixture.php
+++ b/plugins/PrivacyManager/tests/Fixtures/MultipleSitesMultipleVisitsFixture.php
@@ -167,7 +167,7 @@ class MultipleSitesMultipleVisitsFixture extends Fixture
private $numSites = 5;
private $currentUserId;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->installLogTables();
@@ -176,7 +176,7 @@ class MultipleSitesMultipleVisitsFixture extends Fixture
$this->trackVisitsForMultipleSites();
}
- public function tearDown()
+ public function tearDown(): void
{
$this->tearDownLocation();
}
diff --git a/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php b/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php
index 56a4b251b5..c7a1e45679 100644
--- a/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php
+++ b/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php
@@ -36,7 +36,7 @@ class LogDataAnonymizerTest extends IntegrationTestCase
*/
private $theFixture;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -49,7 +49,7 @@ class LogDataAnonymizerTest extends IntegrationTestCase
$this->theFixture->setUpLocation();
}
- public function tearDown()
+ public function tearDown(): void
{
$this->theFixture->tearDownLocation();
}
@@ -64,30 +64,27 @@ class LogDataAnonymizerTest extends IntegrationTestCase
$this->assertNull($this->anonymizer->checkAllVisitColumns(array('visitor_localtime', 'location_region')));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "foobarbaz" seems to not exist in log_visit or cannot be unset
- */
public function test_checkAllVisitColumns_notExistingColumnGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "foobarbaz" seems to not exist in log_visit or cannot be unset');
+
$this->anonymizer->checkAllVisitColumns(array('visitor_localtime', 'foobarbaz'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "idsite" seems to not exist in log_visit or cannot be unset
- */
public function test_checkAllVisitColumns_blacklistedColumnGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "idsite" seems to not exist in log_visit or cannot be unset');
+
$this->anonymizer->checkAllVisitColumns(array('visitor_localtime', 'idsite'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "visit_total_time" seems to not exist in log_visit or cannot be unset
- */
public function test_checkAllVisitColumns_columnWithoutDefaultValueGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "visit_total_time" seems to not exist in log_visit or cannot be unset');
+
$this->anonymizer->checkAllVisitColumns(array('visitor_localtime', 'visit_total_time'));
}
@@ -101,21 +98,19 @@ class LogDataAnonymizerTest extends IntegrationTestCase
$this->assertNull($this->anonymizer->checkAllLinkVisitActionColumns(array('time_spent_ref_action', 'idaction_content_piece')));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "foobarbaz" seems to not exist in log_link_visit_action or cannot be unset
- */
public function test_checkAllLinkVisitActionColumns_notExistingColumnGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "foobarbaz" seems to not exist in log_link_visit_action or cannot be unset');
+
$this->anonymizer->checkAllLinkVisitActionColumns(array('time_spent_ref_action', 'foobarbaz'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "idsite" seems to not exist in log_link_visit_action or cannot be unset
- */
public function test_checkAllLinkVisitActionColumns_blacklistedColumnGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "idsite" seems to not exist in log_link_visit_action or cannot be unset');
+
$this->anonymizer->checkAllLinkVisitActionColumns(array('time_spent_ref_action', 'idsite'));
}
diff --git a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
index 12c1fc7298..076cf9989a 100644
--- a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
+++ b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
@@ -95,7 +95,7 @@ class DataPurgingTest extends IntegrationTestCase
$fixture->createSuperUser = true;
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -138,7 +138,7 @@ class DataPurgingTest extends IntegrationTestCase
$this->instance = new PrivacyManager();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php b/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
index a0e01fcef8..3cc563081f 100644
--- a/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
+++ b/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
@@ -43,7 +43,7 @@ class DataSubjectsTest extends IntegrationTestCase
private $originalTimezone;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -57,7 +57,7 @@ class DataSubjectsTest extends IntegrationTestCase
$this->originalTrackingTime = $this->theFixture->trackingTime;
}
- public function tearDown()
+ public function tearDown(): void
{
$this->theFixture->uninstallLogTables();
$this->theFixture->tearDownLocation();
diff --git a/plugins/PrivacyManager/tests/Integration/Model/LogDataAnonymizationsTest.php b/plugins/PrivacyManager/tests/Integration/Model/LogDataAnonymizationsTest.php
index a45f7a121e..d105df85e2 100644
--- a/plugins/PrivacyManager/tests/Integration/Model/LogDataAnonymizationsTest.php
+++ b/plugins/PrivacyManager/tests/Integration/Model/LogDataAnonymizationsTest.php
@@ -27,7 +27,7 @@ class LogDataAnonymizationsTest extends IntegrationTestCase
private $tableName;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -42,12 +42,11 @@ class LogDataAnonymizationsTest extends IntegrationTestCase
$this->assertEquals(array('idlogdata_anonymization', 'idsites', 'date_start', 'date_end', 'anonymize_ip', 'anonymize_location', 'anonymize_userid', 'unset_visit_columns', 'unset_link_visit_action_columns', 'output', 'scheduled_date', 'job_start_date', 'job_finish_date', 'requester'), $columns);
}
- /**
- * @expectedException \Zend_Db_Statement_Exception
- * @expectedExceptionMessage privacy_logdata_anonymizations
- */
public function test_shouldBeAbleToUninstallTable()
{
+ $this->expectException(\Zend_Db_Statement_Exception::class);
+ $this->expectExceptionMessage('privacy_logdata_anonymizations');
+
$this->dao->uninstall();
try {
@@ -61,48 +60,43 @@ class LogDataAnonymizationsTest extends IntegrationTestCase
$this->dao->install();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ValidatorErrorEmptyValue
- */
public function test_scheduleEntry_fails_whenNoDateGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorEmptyValue');
+
$this->scheduleEntry(null, null);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionInvalidDateFormat
- */
public function test_scheduleEntry_fails_whenInvalidDateGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidDateFormat');
+
$this->scheduleEntry(null, 'foobar');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "visitor_foobar_Baz" seems to not exist in log_visit
- */
public function test_scheduleEntry_fails_whenInvalidVisitColumnsGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "visitor_foobar_Baz" seems to not exist in log_visit');
+
$this->scheduleEntry(null, '2018-01-02', false, false, false, ['visitor_localtime', 'visitor_foobar_Baz', 'config_device_type']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The column "idaction_foobar_baz" seems to not exist in log_link_visit_action
- */
public function test_scheduleEntry_fails_whenInvalidLinkVisitActionColumnsGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The column "idaction_foobar_baz" seems to not exist in log_link_visit_action');
+
$this->scheduleEntry(null, '2018-01-02', false, false, false, [], ['idaction_event_category', 'idaction_foobar_baz']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Nothing is selected to be anonymized
- */
public function test_scheduleEntry_fails_whenNoWorkScheduled()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Nothing is selected to be anonymized');
+
$this->scheduleEntry(null, '2018-01-02', false, false, false, [], []);
}
@@ -159,12 +153,11 @@ class LogDataAnonymizationsTest extends IntegrationTestCase
), $entry);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Specified date range is invalid.
- */
public function test_scheduleEntry_failsInvalidDateRange()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Specified date range is invalid.');
+
$this->scheduleStartedEntry(null, '2018-04-06,2017-03-01', false, true, [], false, 'mylogin2');
}
diff --git a/plugins/PrivacyManager/tests/Integration/PrivacyManagerConfigTest.php b/plugins/PrivacyManager/tests/Integration/PrivacyManagerConfigTest.php
index 9e9810e9d7..bc01193698 100644
--- a/plugins/PrivacyManager/tests/Integration/PrivacyManagerConfigTest.php
+++ b/plugins/PrivacyManager/tests/Integration/PrivacyManagerConfigTest.php
@@ -22,7 +22,7 @@ class PrivacyManagerConfigTest extends IntegrationTestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/PrivacyManager/tests/Integration/PrivacyManagerTest.php b/plugins/PrivacyManager/tests/Integration/PrivacyManagerTest.php
index fb7f40afab..7e3f1bf46b 100644
--- a/plugins/PrivacyManager/tests/Integration/PrivacyManagerTest.php
+++ b/plugins/PrivacyManager/tests/Integration/PrivacyManagerTest.php
@@ -28,7 +28,7 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
private $manager;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -38,7 +38,7 @@ class PrivacyManagerTest extends IntegrationTestCase
\Piwik\Option::set('delete_reports_keep_week_reports', 1);
}
- public function tearDown()
+ public function tearDown(): void
{
unset($_GET['date']);
unset($_GET['period']);
diff --git a/plugins/PrivacyManager/tests/Integration/Tracker/RequestProcessorTest.php b/plugins/PrivacyManager/tests/Integration/Tracker/RequestProcessorTest.php
index ffb5fee0ea..13caa149a4 100644
--- a/plugins/PrivacyManager/tests/Integration/Tracker/RequestProcessorTest.php
+++ b/plugins/PrivacyManager/tests/Integration/Tracker/RequestProcessorTest.php
@@ -36,7 +36,7 @@ class RequestProcessorTest extends IntegrationTestCase
*/
private $requestProcessor;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/PrivacyManager/tests/System/APITest.php b/plugins/PrivacyManager/tests/System/APITest.php
index bcd05f829c..c46f7416cc 100644
--- a/plugins/PrivacyManager/tests/System/APITest.php
+++ b/plugins/PrivacyManager/tests/System/APITest.php
@@ -31,18 +31,17 @@ class APITest extends SystemTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->api = API::getInstance();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No list of visits given
- */
public function test_exportDataSubjects_failsWhenNoVisitsGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No list of visits given');
+
$this->assertNull($this->api->exportDataSubjects(false));
}
@@ -65,12 +64,11 @@ class APITest extends SystemTestCase
$this->assertJsonResponse('exportDataSubject_allVisits', $result);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No idsite key set for visit at index 1
- */
public function test_exportDataSubjects_failsWhenMissingIdSite()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No idsite key set for visit at index 1');
+
$this->assertNull($this->api->exportDataSubjects([['idsite' => '9999', 'idvisit' => '9999'], []]));
}
diff --git a/plugins/PrivacyManager/tests/System/AnonymizationTest.php b/plugins/PrivacyManager/tests/System/AnonymizationTest.php
index 3d839cf3df..03e3a6ea6e 100644
--- a/plugins/PrivacyManager/tests/System/AnonymizationTest.php
+++ b/plugins/PrivacyManager/tests/System/AnonymizationTest.php
@@ -31,7 +31,7 @@ class AnonymizationTest extends SystemTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->api = API::getInstance();
diff --git a/plugins/PrivacyManager/tests/System/PurgeDataTest.php b/plugins/PrivacyManager/tests/System/PurgeDataTest.php
index 1b48fdee99..efc536c09f 100644
--- a/plugins/PrivacyManager/tests/System/PurgeDataTest.php
+++ b/plugins/PrivacyManager/tests/System/PurgeDataTest.php
@@ -22,7 +22,7 @@ class PurgeDataTest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
}
@@ -31,12 +31,12 @@ class PurgeDataTest extends SystemTestCase
}
- public function setUp()
+ public function setUp(): void
{
parent::setUpBeforeClass();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDownAfterClass();
}
diff --git a/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php b/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
index fa27c8926c..9d8abac821 100644
--- a/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
+++ b/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
@@ -18,14 +18,14 @@ use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker;
*/
class DoNotTrackHeaderCheckerTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
$this->cleanupServerGlobals();
$this->setUserAgentToChrome();
}
- public function tearDown()
+ public function tearDown(): void
{
$this->cleanupServerGlobals();
}
diff --git a/plugins/QueuedTracking b/plugins/QueuedTracking
-Subproject 58a0d80f275d3f413ba25d0a5a6ec8856273346
+Subproject 5b9e72e42cf856c491bc8837f1787e0607bf3ca
diff --git a/plugins/Referrers/tests/Integration/Columns/ReferrerKeywordTest.php b/plugins/Referrers/tests/Integration/Columns/ReferrerKeywordTest.php
index 3977d25b9e..64fc503aff 100644
--- a/plugins/Referrers/tests/Integration/Columns/ReferrerKeywordTest.php
+++ b/plugins/Referrers/tests/Integration/Columns/ReferrerKeywordTest.php
@@ -32,7 +32,7 @@ class ReferrerKeywordTest extends IntegrationTestCase
private $idSite2 = 2;
private $idSite3 = 3;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/Referrers/tests/Integration/Columns/ReferrerNameTest.php b/plugins/Referrers/tests/Integration/Columns/ReferrerNameTest.php
index a42ffe91b9..ca39ec2632 100644
--- a/plugins/Referrers/tests/Integration/Columns/ReferrerNameTest.php
+++ b/plugins/Referrers/tests/Integration/Columns/ReferrerNameTest.php
@@ -35,7 +35,7 @@ class ReferrerNameTest extends IntegrationTestCase
private $idSite3 = 3;
private $idSite4 = 4;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -52,7 +52,7 @@ class ReferrerNameTest extends IntegrationTestCase
$this->referrerName = new ReferrerName();
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
Cache::clearCacheGeneral();
diff --git a/plugins/Referrers/tests/Integration/Columns/ReferrerTypeTest.php b/plugins/Referrers/tests/Integration/Columns/ReferrerTypeTest.php
index 6b75f8d027..b101ddc89c 100644
--- a/plugins/Referrers/tests/Integration/Columns/ReferrerTypeTest.php
+++ b/plugins/Referrers/tests/Integration/Columns/ReferrerTypeTest.php
@@ -35,7 +35,7 @@ class ReferrerTypeTest extends IntegrationTestCase
private $idSite4 = 4;
private $idSite5 = 5;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -53,7 +53,7 @@ class ReferrerTypeTest extends IntegrationTestCase
$this->referrerType = new ReferrerType();
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
Cache::clearCacheGeneral();
diff --git a/plugins/Referrers/tests/Unit/SearchEngineTest.php b/plugins/Referrers/tests/Unit/SearchEngineTest.php
index d48d3c9afc..d0ef508842 100644
--- a/plugins/Referrers/tests/Unit/SearchEngineTest.php
+++ b/plugins/Referrers/tests/Unit/SearchEngineTest.php
@@ -16,7 +16,7 @@ use Spyc;
*/
class SearchEngineTest extends \PHPUnit\Framework\TestCase
{
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
// inject definitions to avoid database usage
$yml = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . SearchEngine::DEFINITION_FILE);
@@ -143,6 +143,8 @@ class SearchEngineTest extends \PHPUnit\Framework\TestCase
$this->assertTrue(in_array($name['host'] . '.png', $favicons), $name['host']);
}
+
+ $this->assertTrue(true); // ensure there is an assertion, to prevent warning
}
/**
diff --git a/plugins/Referrers/tests/Unit/SocialTest.php b/plugins/Referrers/tests/Unit/SocialTest.php
index c25f150c83..0c86b24b0f 100644
--- a/plugins/Referrers/tests/Unit/SocialTest.php
+++ b/plugins/Referrers/tests/Unit/SocialTest.php
@@ -17,7 +17,7 @@ use Spyc;
*/
class SocialTest extends \PHPUnit\Framework\TestCase
{
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
// inject definitions to avoid database usage
$yml = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . Social::DEFINITION_FILE);
@@ -92,6 +92,6 @@ class SocialTest extends \PHPUnit\Framework\TestCase
*/
public function testGetLogoFromUrl($url, $expected)
{
- $this->assertContains($expected, Social::getInstance()->getLogoFromUrl($url));
+ self::assertStringContainsString($expected, Social::getInstance()->getLogoFromUrl($url));
}
} \ No newline at end of file
diff --git a/plugins/SEO/tests/Integration/SEOTest.php b/plugins/SEO/tests/Integration/SEOTest.php
index 374923f698..17914d1edf 100644
--- a/plugins/SEO/tests/Integration/SEOTest.php
+++ b/plugins/SEO/tests/Integration/SEOTest.php
@@ -21,7 +21,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class SEOTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/ScheduledReports/tests/Fixtures/ReportSubscription.php b/plugins/ScheduledReports/tests/Fixtures/ReportSubscription.php
index 81210754eb..d3fe73082c 100644
--- a/plugins/ScheduledReports/tests/Fixtures/ReportSubscription.php
+++ b/plugins/ScheduledReports/tests/Fixtures/ReportSubscription.php
@@ -18,7 +18,7 @@ class ReportSubscription extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2012-01-01 00:00:00');
diff --git a/plugins/ScheduledReports/tests/Integration/ApiTest.php b/plugins/ScheduledReports/tests/Integration/ApiTest.php
index 5d2a5f0832..893d3172f8 100644
--- a/plugins/ScheduledReports/tests/Integration/ApiTest.php
+++ b/plugins/ScheduledReports/tests/Integration/ApiTest.php
@@ -42,7 +42,7 @@ class ApiTest extends IntegrationTestCase
{
private $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -485,17 +485,16 @@ class ApiTest extends IntegrationTestCase
$language = false, $outputType = APIScheduledReports::OUTPUT_RETURN);
ob_end_clean();
- $this->assertContains('id="VisitsSummary_get"', $result);
- $this->assertContains('id="Referrers_getWebsites"', $result);
- $this->assertNotContains('id="UserCountry_getCountry"', $result);
+ self::assertStringContainsString('id="VisitsSummary_get"', $result);
+ self::assertStringContainsString('id="Referrers_getWebsites"', $result);
+ self::assertStringNotContainsString('id="UserCountry_getCountry"', $result);
}
- /**
- * @expectedException \Piwik\Http\BadRequestException
- * @expectedExceptionMessage This API method does not support multiple periods.
- */
public function test_generateReport_throwsIfMultiplePeriodsRequested()
{
+ $this->expectException(\Piwik\Http\BadRequestException::class);
+ $this->expectExceptionMessage('This API method does not support multiple periods.');
+
$idReport = APIScheduledReports::getInstance()->addReport(
1,
'',
@@ -515,12 +514,11 @@ class ApiTest extends IntegrationTestCase
$language = false, $outputType = APIScheduledReports::OUTPUT_RETURN);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid evolutionPeriodFor value
- */
public function test_addReport_validatesEvolutionPeriodForParam()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid evolutionPeriodFor value');
+
self::setSuperUser();
APIScheduledReports::getInstance()->addReport(
@@ -541,12 +539,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Evolution period amount must be a positive number
- */
public function test_addReport_validatesEvolutionPeriodNParam()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Evolution period amount must be a positive number');
+
self::setSuperUser();
APIScheduledReports::getInstance()->addReport(
@@ -568,12 +565,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The evolutionPeriodN param has no effect when evolutionPeriodFor is "each".
- */
public function test_addReport_throwsIfEvolutionPeriodNParamIsEach_AndLastNSupplied()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The evolutionPeriodN param has no effect when evolutionPeriodFor is "each".');
+
self::setSuperUser();
APIScheduledReports::getInstance()->addReport(
@@ -595,12 +591,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid evolutionPeriodFor value
- */
public function test_updateReport_validatesEvolutionPeriodForParam()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid evolutionPeriodFor value');
+
self::setSuperUser();
$idReport = APIScheduledReports::getInstance()->addReport(
@@ -635,12 +630,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Evolution period amount must be a positive number
- */
public function test_updateReport_validatesEvolutionPeriodNParam()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Evolution period amount must be a positive number');
+
self::setSuperUser();
$idReport = APIScheduledReports::getInstance()->addReport(
@@ -676,12 +670,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The evolutionPeriodN param has no effect when evolutionPeriodFor is "each".
- */
public function test_updateReport_throwsIfEvolutionPeriodNParamIsEach_AndLastNSupplied()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The evolutionPeriodN param has no effect when evolutionPeriodFor is "each".');
+
self::setSuperUser();
$idReport = APIScheduledReports::getInstance()->addReport(
diff --git a/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/AttachedFileReportEmailGeneratorTest.php b/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/AttachedFileReportEmailGeneratorTest.php
index 5e7d5225cc..97e448f580 100644
--- a/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/AttachedFileReportEmailGeneratorTest.php
+++ b/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/AttachedFileReportEmailGeneratorTest.php
@@ -24,7 +24,7 @@ class AttachedFileReportEmailGeneratorTest extends IntegrationTestCase
*/
private $testInstance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -54,8 +54,8 @@ class AttachedFileReportEmailGeneratorTest extends IntegrationTestCase
$this->assertStringStartsWith('<html', $mail->getBodyHtml()->getContent());
$this->assertEquals('General_Report report - pretty date', $mail->getSubject());
- $this->assertContains('ScheduledReports_PleaseFindAttachedFile', $mailContent);
- $this->assertContains('ScheduledReports_SentFromX', $mailContent);
+ self::assertStringContainsString('ScheduledReports_PleaseFindAttachedFile', $mailContent);
+ self::assertStringContainsString('ScheduledReports_SentFromX', $mailContent);
$this->assertEquals('Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
@@ -100,7 +100,7 @@ Content-Disposition: inline; filename="General_Report report - pretty date.thing
$mailContent = $this->getMailContent($mail);
$this->assertStringStartsWith('<html', $mailContent);
- $this->assertContains('ScheduledReports_PleaseFindAttachedFile', $mailContent);
+ self::assertStringContainsString('ScheduledReports_PleaseFindAttachedFile', $mailContent);
$this->assertEquals('Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
@@ -130,9 +130,9 @@ Content-Disposition: inline
$mailContent = $this->getMailContent($mail);
$this->assertStringStartsWith('<html', $mailContent);
- $this->assertContains("ScheduledReports_PleaseFindAttachedFile", $mailContent);
- $this->assertContains('ScheduledReports_SentFromX=', $mailContent);
- $this->assertContains('ScheduledReports_CustomVisitorSegment', $mailContent);
+ self::assertStringContainsString("ScheduledReports_PleaseFindAttachedFile", $mailContent);
+ self::assertStringContainsString('ScheduledReports_SentFromX=', $mailContent);
+ self::assertStringContainsString('ScheduledReports_CustomVisitorSegment', $mailContent);
$this->assertEquals('Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
diff --git a/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/HtmlReportEmailGeneratorTest.php b/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/HtmlReportEmailGeneratorTest.php
index 357306d6d3..15a56e0e0e 100644
--- a/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/HtmlReportEmailGeneratorTest.php
+++ b/plugins/ScheduledReports/tests/Integration/ReportEmailGenerator/HtmlReportEmailGeneratorTest.php
@@ -21,7 +21,7 @@ class HtmlReportEmailGeneratorTest extends IntegrationTestCase
*/
private $testInstance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->testInstance = new HtmlReportEmailGenerator();
diff --git a/plugins/ScheduledReports/tests/Integration/ReportEmailGeneratorTest.php b/plugins/ScheduledReports/tests/Integration/ReportEmailGeneratorTest.php
index d2c3be30d1..510ad74931 100644
--- a/plugins/ScheduledReports/tests/Integration/ReportEmailGeneratorTest.php
+++ b/plugins/ScheduledReports/tests/Integration/ReportEmailGeneratorTest.php
@@ -36,7 +36,7 @@ class ReportEmailGeneratorTest extends IntegrationTestCase
*/
private $testInstance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/ScheduledReports/tests/Integration/ScheduledReportsTest.php b/plugins/ScheduledReports/tests/Integration/ScheduledReportsTest.php
index ac194e5e36..97217e3f4d 100644
--- a/plugins/ScheduledReports/tests/Integration/ScheduledReportsTest.php
+++ b/plugins/ScheduledReports/tests/Integration/ScheduledReportsTest.php
@@ -29,7 +29,7 @@ class ScheduledReportsTest extends IntegrationTestCase
private $reports;
private $reportIds = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -130,7 +130,7 @@ class ScheduledReportsTest extends IntegrationTestCase
$this->getReport($login, $idSite);
$this->fail("Report for $login, $idSite should not exist but does");
} catch (\Exception $e) {
- $this->assertContains("Requested report couldn't be found", $e->getMessage());
+ self::assertStringContainsString("Requested report couldn't be found", $e->getMessage());
}
}
diff --git a/plugins/SegmentEditor/tests/Integration/ApiTest.php b/plugins/SegmentEditor/tests/Integration/ApiTest.php
index a7d8d82a59..4961866f03 100644
--- a/plugins/SegmentEditor/tests/Integration/ApiTest.php
+++ b/plugins/SegmentEditor/tests/Integration/ApiTest.php
@@ -25,7 +25,7 @@ class ApiTest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SegmentEditor/tests/Integration/ModelTest.php b/plugins/SegmentEditor/tests/Integration/ModelTest.php
index f309221c8f..a3b52beac1 100644
--- a/plugins/SegmentEditor/tests/Integration/ModelTest.php
+++ b/plugins/SegmentEditor/tests/Integration/ModelTest.php
@@ -27,7 +27,7 @@ class ModelTest extends IntegrationTestCase
private $idSegment4;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->model = new Model();
@@ -53,7 +53,7 @@ class ModelTest extends IntegrationTestCase
));
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
// Force a hard delete of segment
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
index 2054e07610..95ce4a6288 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
@@ -24,7 +24,7 @@ use Exception;
*/
class SegmentEditorTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php
index 8d03a23c38..a7db9f6666 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php
@@ -28,7 +28,7 @@ class SegmentFormatterTest extends IntegrationTestCase
private $idSite;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -38,7 +38,7 @@ class SegmentFormatterTest extends IntegrationTestCase
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
}
@@ -91,21 +91,19 @@ class SegmentFormatterTest extends IntegrationTestCase
$this->assertSame('Page URL contains "piwik" or Visit ID is not "1"', $readable);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The segment 'noTexisTinG' does not exist
- */
public function test_getHumanReadable_ShouldThrowAnException_IfTheGivenSegmentNameDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The segment \'noTexisTinG\' does not exist');
+
$this->formatter->getHumanReadable($segment = 'noTexisTinG==1.0', $this->idSite);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The segment condition 'pageUrl=!1.0' is not valid.
- */
public function test_getHumanReadable_ShouldThrowAnException_IfSegmentCannotBeParsedBecauseOfInvalidFormat()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The segment condition \'pageUrl=!1.0\' is not valid.');
+
$invalidOperator = '=!';
$this->formatter->getHumanReadable($segment = 'pageUrl' . $invalidOperator . '1.0', $this->idSite);
}
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentListTest.php b/plugins/SegmentEditor/tests/Integration/SegmentListTest.php
index 575e146e97..3a66a4bd4e 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentListTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentListTest.php
@@ -29,7 +29,7 @@ class SegmentListTest extends IntegrationTestCase
private $idSite;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -42,7 +42,7 @@ class SegmentListTest extends IntegrationTestCase
$segmentName = 'pageUrl';
$segment = $this->list->findSegment($segmentName, $this->idSite);
- $this->assertInternalType('array', $segment);
+ self::assertIsArray($segment);
$this->assertSame($segmentName, $segment['segment']);
}
@@ -52,12 +52,11 @@ class SegmentListTest extends IntegrationTestCase
$this->assertNull($segment);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasViewAccess
- */
public function test_findSegment_ShouldThrowException_IfNotEnoughPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasViewAccess');
+
FakeAccess::clearAccess($superUser = false, array(1));
$segment = $this->list->findSegment('pageUrl', 999);
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
index b3ccb92b7f..095f13b4ea 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
@@ -25,7 +25,7 @@ class SegmentQueryDecoratorTest extends IntegrationTestCase
*/
private $segmentQueryDecorator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
index 0d4d9d9971..c54f4d4bed 100644
--- a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
+++ b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
@@ -37,7 +37,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertNotContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(!in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'customSegmentUnprocessed', [
'idSite' => self::$fixture->idSite,
@@ -57,7 +57,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertNotContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(!in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'realTimeSegmentUnprocessed', [
'idSite' => self::$fixture->idSite,
@@ -77,7 +77,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'autoArchiveSegmentUnprocessed', [
'idSite' => self::$fixture->idSite,
@@ -97,7 +97,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'autoArchiveSegmentUnprocessedEncoded', [
'idSite' => self::$fixture->idSite,
@@ -120,7 +120,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'autoArchiveSegmentPreprocessed', [
'idSite' => self::$fixture->idSite,
@@ -138,7 +138,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertNotContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(!in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'customSegmentPreprocessed', [
'idSite' => self::$fixture->idSite,
@@ -163,7 +163,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'autoArchiveSegmentNoDataPreprocessed', [
'idSite' => self::$fixture->idSite,
@@ -185,7 +185,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'noLogDataSegmentUnprocessed', [
'idSite' => self::$fixture->idSite,
@@ -205,7 +205,7 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
- $this->assertContains(self::TEST_SEGMENT, $segments);
+ self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
$this->runAnyApiTest('VisitsSummary.get', 'noLogDataSegmentUnprocessedMultiSite', [
'idSite' => 'all',
diff --git a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php
index c3f4a2da55..848080c2af 100644
--- a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php
+++ b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php
@@ -31,7 +31,7 @@ class SegmentQueryDecoratorTest extends \PHPUnit\Framework\TestCase
*/
private $decorator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -83,8 +83,11 @@ class SegmentQueryDecoratorTest extends \PHPUnit\Framework\TestCase
private function getMockSegmentEditorService()
{
- $mock = $this->getMock('Piwik\Plugins\SegmentEditor\Services\StoredSegmentService',
- array('getAllSegmentsAndIgnoreVisibility'), array(), '', $callOriginalConstructor = false);
+ $mock = $this->getMockBuilder('Piwik\Plugins\SegmentEditor\Services\StoredSegmentService')
+ ->setMethods(['getAllSegmentsAndIgnoreVisibility'])
+ ->setConstructorArgs([])
+ ->disableOriginalConstructor()
+ ->getMock();
$mock->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->willReturn(self::$storedSegments);
return $mock;
}
diff --git a/plugins/SitesManager/tests/Fixtures/ManySites.php b/plugins/SitesManager/tests/Fixtures/ManySites.php
index e80d8fbcc9..e8594d09f4 100644
--- a/plugins/SitesManager/tests/Fixtures/ManySites.php
+++ b/plugins/SitesManager/tests/Fixtures/ManySites.php
@@ -19,7 +19,7 @@ class ManySites extends Fixture
{
public $dateTime = '2010-01-03 11:22:33';
- public function setUp()
+ public function setUp(): void
{
for ($idSite = 1; $idSite < 64; $idSite++) {
if (!self::siteCreated($idSite)) {
diff --git a/plugins/SitesManager/tests/Integration/ApiTest.php b/plugins/SitesManager/tests/Integration/ApiTest.php
index 90493fb7cf..1385cef121 100644
--- a/plugins/SitesManager/tests/Integration/ApiTest.php
+++ b/plugins/SitesManager/tests/Integration/ApiTest.php
@@ -22,7 +22,6 @@ use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\Mock\FakeAccess;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Exception;
-use PHPUnit_Framework_Constraint_IsType;
/**
* Class Plugins_SitesManagerTest
@@ -33,7 +32,7 @@ use PHPUnit_Framework_Constraint_IsType;
*/
class ApiTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -43,7 +42,7 @@ class ApiTest extends IntegrationTestCase
FakeAccess::$superUser = true;
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
@@ -52,10 +51,11 @@ class ApiTest extends IntegrationTestCase
/**
* empty name -> exception
- * @expectedException \Exception
*/
public function test_addSite_WithEmptyName_ThrowsException()
{
+ $this->expectException(\Exception::class);
+
API::getInstance()->addSite("", array("http://piwik.net"));
}
@@ -77,10 +77,10 @@ class ApiTest extends IntegrationTestCase
* wrong urls -> exception
*
* @dataProvider getInvalidUrlData
- * @expectedException \Exception
*/
public function test_addSite_WithWrongUrls_ThrowsException($url)
{
+ $this->expectException(\Exception::class);
API::getInstance()->addSite("name", $url);
}
@@ -155,10 +155,10 @@ class ApiTest extends IntegrationTestCase
* Test with invalid IPs
*
* @dataProvider getInvalidIPsData
- * @expectedException \Exception
*/
public function test_addSite_WithInvalidExcludedIps_ThrowsException($ip)
{
+ $this->expectException(\Exception::class);
API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $ip);
}
@@ -171,7 +171,7 @@ class ApiTest extends IntegrationTestCase
$url = "http://piwik.net/";
$urlOK = "http://piwik.net";
$idsite = API::getInstance()->addSite("name", $url);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
+ self::assertIsInt($idsite);
$siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($urlOK, $siteInfo['main_url']);
@@ -189,7 +189,7 @@ class ApiTest extends IntegrationTestCase
$urls = array("http://piwik.net/", "http://piwik.com", "https://piwik.net/test/", "piwik.net/another/test");
$urlsOK = array("http://piwik.net", "http://piwik.com", "http://piwik.net/another/test", "https://piwik.net/test");
$idsite = API::getInstance()->addSite("super website", $urls);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
+ self::assertIsInt($idsite);
$siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($urlsOK[0], $siteInfo['main_url']);
@@ -205,7 +205,7 @@ class ApiTest extends IntegrationTestCase
{
$name = "supertest(); ~@@()''!£\$'%%^'!£ போ";
$idsite = API::getInstance()->addSite($name, "http://piwik.net");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
+ self::assertIsInt($idsite);
$siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
@@ -213,12 +213,13 @@ class ApiTest extends IntegrationTestCase
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage SitesManager_OnlyMatchedUrlsAllowed
* @dataProvider getDifferentTypesDataProvider
*/
public function test_addSite_ShouldFailAndNotCreatedASite_IfASettingIsInvalid($type)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('SitesManager_OnlyMatchedUrlsAllowed');
+
try {
$settings = array('WebsiteMeasurable' => array(array('name' => 'exclude_unknown_urls', 'value' => 'fooBar')));
$this->addSiteWithType($type, $settings);
@@ -263,7 +264,7 @@ class ApiTest extends IntegrationTestCase
{
$name = "website ";
$idsite = API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
+ self::assertIsInt($idsite);
$siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
@@ -423,10 +424,11 @@ class ApiTest extends IntegrationTestCase
/**
* wrong format urls => exception
- * @expectedException \Exception
*/
public function test_addSiteAliasUrls_WithIncorrectFormat_ThrowsException_3()
{
+ $this->expectException(\Exception::class);
+
$idsite = $this->_addSite();
$toAdd = array("http:mpigeq");
API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
@@ -434,20 +436,20 @@ class ApiTest extends IntegrationTestCase
/**
* wrong idsite => no exception because simply no access to this resource
- * @expectedException \Exception
*/
public function test_addSiteAliasUrls_WithWrongIdSite_ThrowsException()
{
+ $this->expectException(\Exception::class);
$toAdd = array("http://pigeq.com/test");
API::getInstance()->addSiteAliasUrls(-1, $toAdd);
}
/**
* wrong idsite => exception
- * @expectedException \Exception
*/
public function test_addSiteAliasUrls_WithWrongIdSite_ThrowsException2()
{
+ $this->expectException(\Exception::class);
$toAdd = array("http://pigeq.com/test");
API::getInstance()->addSiteAliasUrls(155, $toAdd);
}
@@ -492,28 +494,28 @@ class ApiTest extends IntegrationTestCase
/**
* wrong id => exception
- * @expectedException \Exception
*/
public function test_getSiteFromId_WithWrongId_ThrowsException1()
{
+ $this->expectException(\Exception::class);
API::getInstance()->getSiteFromId(0);
}
/**
* wrong id => exception
- * @expectedException \Exception
*/
public function test_getSiteFromId_WithWrongId_ThrowsException2()
{
+ $this->expectException(\Exception::class);
API::getInstance()->getSiteFromId("x1");
}
/**
* wrong id : no access => exception
- * @expectedException \Exception
*/
public function test_getSiteFromId_ThrowsException_WhenTheUserDoesNotHavaAcessToTheSite()
{
+ $this->expectException(\Exception::class);
$idsite = API::getInstance()->addSite("site", array("http://piwik.net", "http://piwik.com/test/"));
$this->assertEquals(1, $idsite);
@@ -531,7 +533,7 @@ class ApiTest extends IntegrationTestCase
{
$name = "website ''";
$idsite = API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
+ self::assertIsInt($idsite);
$siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
@@ -757,10 +759,10 @@ class ApiTest extends IntegrationTestCase
/**
* wrongId => exception
- * @expectedException \Exception
*/
public function test_getSiteUrlsFromId_ThrowsException_WhenSiteIdIsIncorrect()
{
+ $this->expectException(\Exception::class);
FakeAccess::setIdSitesView(array(3));
FakeAccess::setIdSitesAdmin(array());
API::getInstance()->getSiteUrlsFromId(1);
@@ -881,12 +883,11 @@ class ApiTest extends IntegrationTestCase
$this->assertEquals($newurls, $allUrls);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage SitesManager_OnlyMatchedUrlsAllowed
- */
public function test_updateSite_ShouldFailAndNotUpdateSite_IfASettingIsInvalid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('SitesManager_OnlyMatchedUrlsAllowed');
+
$type = MobileAppMeasurable\Type::ID;
$idSite = $this->addSiteWithType($type, array());
@@ -970,12 +971,11 @@ class ApiTest extends IntegrationTestCase
);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage SitesManager_ExceptionDeleteSite
- */
public function test_delete_ShouldNotDeleteASiteInCaseThereIsOnlyOneSite()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('SitesManager_ExceptionDeleteSite');
+
$siteId1 = $this->_addSite();
$this->assertHasSite($siteId1);
@@ -989,12 +989,11 @@ class ApiTest extends IntegrationTestCase
}
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage website id = 99999498 not found
- */
public function test_delete_ShouldTriggerException_IfGivenSiteDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('website id = 99999498 not found');
+
API::getInstance()->deleteSite(99999498);
}
@@ -1068,19 +1067,19 @@ class ApiTest extends IntegrationTestCase
/**
*
* @dataProvider getInvalidTimezoneData
- * @expectedException \Exception
*/
public function test_addSite_WithInvalidTimezone_ThrowsException($timezone)
{
+ $this->expectException(\Exception::class);
+
API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $ip = '', $params = '', $timezone);
}
- /**
- * @expectedException \Exception
- */
public function test_addSite_WithInvalidCurrency_ThrowsException()
{
+ $this->expectException(\Exception::class);
+
$invalidCurrency = '€';
API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, '', 'UTC', $invalidCurrency);
diff --git a/plugins/SitesManager/tests/Integration/ModelTest.php b/plugins/SitesManager/tests/Integration/ModelTest.php
index 9333fb9cd9..1b2f182055 100644
--- a/plugins/SitesManager/tests/Integration/ModelTest.php
+++ b/plugins/SitesManager/tests/Integration/ModelTest.php
@@ -24,7 +24,7 @@ class ModelTest extends IntegrationTestCase
*/
private $model;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SitesManager/tests/Integration/SiteUrlsTest.php b/plugins/SitesManager/tests/Integration/SiteUrlsTest.php
index 3c8739d878..eb5182a1f7 100644
--- a/plugins/SitesManager/tests/Integration/SiteUrlsTest.php
+++ b/plugins/SitesManager/tests/Integration/SiteUrlsTest.php
@@ -29,7 +29,7 @@ class SiteUrlsTest extends IntegrationTestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SitesManager/tests/Integration/SitesManagerTest.php b/plugins/SitesManager/tests/Integration/SitesManagerTest.php
index 85cffe99ae..24be827b95 100644
--- a/plugins/SitesManager/tests/Integration/SitesManagerTest.php
+++ b/plugins/SitesManager/tests/Integration/SitesManagerTest.php
@@ -35,7 +35,7 @@ class SitesManagerTest extends IntegrationTestCase
private $siteId;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/SitesManager/tests/Unit/APITest.php b/plugins/SitesManager/tests/Unit/APITest.php
index 564bc977ec..79f7017e61 100644
--- a/plugins/SitesManager/tests/Unit/APITest.php
+++ b/plugins/SitesManager/tests/Unit/APITest.php
@@ -25,7 +25,7 @@ class APITest extends \PHPUnit\Framework\TestCase
*/
private $api;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -38,7 +38,7 @@ class APITest extends \PHPUnit\Framework\TestCase
$this->api = API::getInstance();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/plugins/TagManager b/plugins/TagManager
-Subproject 935593de7f19e908024cd13ee4f561ca96be1db
+Subproject 7460e1c3060b1449220b1bf6e59ec1817715529
diff --git a/plugins/TasksTimetable b/plugins/TasksTimetable
-Subproject 30054d3bfeb280c510eee5a60df335a20735bdd
+Subproject e65e58eec532d43fb2ac89710b2541eb6d7131c
diff --git a/plugins/Tour/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/Tour/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index 7bbdf8cb4c..196d307263 100644
--- a/plugins/Tour/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/Tour/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -21,13 +21,13 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackFirstVisit();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Tour/tests/Integration/ChallengeTest.php b/plugins/Tour/tests/Integration/ChallengeTest.php
index 58d49dbd0d..0b57ca62bb 100644
--- a/plugins/Tour/tests/Integration/ChallengeTest.php
+++ b/plugins/Tour/tests/Integration/ChallengeTest.php
@@ -50,7 +50,7 @@ class ChallengeTest extends IntegrationTestCase
*/
private $challenge2;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -58,7 +58,7 @@ class ChallengeTest extends IntegrationTestCase
$this->challenge2 = new CustomTest2Challenge();
}
- public function tearDown()
+ public function tearDown(): void
{
Challenge::clearCache();
parent::tearDown();
diff --git a/plugins/Tour/tests/System/APITest.php b/plugins/Tour/tests/System/APITest.php
index 0287f417b3..c790eb62d2 100644
--- a/plugins/Tour/tests/System/APITest.php
+++ b/plugins/Tour/tests/System/APITest.php
@@ -61,21 +61,19 @@ class APITest extends SystemTestCase
$this->assertTrue($steps[1]['isSkipped']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Challenge already completed
- */
public function test_skipStep_alreadyCompleted()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Challenge already completed');
+
Request::processRequest('Tour.skipChallenge', array('id' => 'track_data'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Challenge not found
- */
public function test_skipStep_invalid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Challenge not found');
+
Request::processRequest('Tour.skipChallenge', array('id' => 'foobarbaz'));
}
diff --git a/plugins/Tour/tests/System/DataFinderTest.php b/plugins/Tour/tests/System/DataFinderTest.php
index 4345ada15f..48374e60c6 100644
--- a/plugins/Tour/tests/System/DataFinderTest.php
+++ b/plugins/Tour/tests/System/DataFinderTest.php
@@ -32,7 +32,7 @@ class DataFinderTest extends SystemTestCase
*/
private $dataFinder;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->dataFinder = new DataFinder();
diff --git a/plugins/Tour/tests/System/TourTest.php b/plugins/Tour/tests/System/TourTest.php
index 4163192670..d09fd0c5a1 100644
--- a/plugins/Tour/tests/System/TourTest.php
+++ b/plugins/Tour/tests/System/TourTest.php
@@ -29,7 +29,7 @@ class TourTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
}
diff --git a/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index b8b4468407..882f165747 100644
--- a/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -20,14 +20,14 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
Fixture::createSuperUser(true);
$this->createSuperUser = true;
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php b/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php
index 3b71c0eba7..f5b047ced5 100644
--- a/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php
+++ b/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php
@@ -42,7 +42,7 @@ class TwoFactorFixture extends Fixture
*/
private $twoFa;
- public function setUp()
+ public function setUp(): void
{
$this->dao = StaticContainer::get(RecoveryCodeDao::class);
$this->twoFa = StaticContainer::get(TwoFactorAuthentication::class);
@@ -52,7 +52,7 @@ class TwoFactorFixture extends Fixture
$this->trackFirstVisit();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/TwoFactorAuth/tests/Integration/APITest.php b/plugins/TwoFactorAuth/tests/Integration/APITest.php
index 4f8b738138..500076d246 100644
--- a/plugins/TwoFactorAuth/tests/Integration/APITest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/APITest.php
@@ -39,7 +39,7 @@ class APITest extends IntegrationTestCase
*/
private $twoFa;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -56,12 +56,11 @@ class APITest extends IntegrationTestCase
$this->twoFa = StaticContainer::get(TwoFactorAuthentication::class);
}
- /**
- * @expectedExceptionMessage checkUserHasSuperUserAccess Fake exception
- * @expectedException \Exception
- */
public function test_resetTwoFactorAuth_failsWhenNotPermissions()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess Fake exception');
+
$this->setAdminUser();
$this->api->resetTwoFactorAuth('login');
}
diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php
index 9eda0e9531..b084c85080 100644
--- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php
@@ -25,7 +25,7 @@ class RecoveryCodeDaoTest extends IntegrationTestCase
*/
private $dao;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php
index e3449386c1..cc51316e33 100644
--- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php
@@ -24,7 +24,7 @@ class RecoveryCodeRandomGeneratorTest extends IntegrationTestCase
*/
private $generator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php
index 3ffc97b7a9..1d5193208d 100644
--- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php
@@ -24,7 +24,7 @@ class RecoveryCodeStaticGeneratorTest extends IntegrationTestCase
*/
private $generator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php
index 2a0cf55384..bdd847205e 100644
--- a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php
@@ -24,7 +24,7 @@ class TwoFaSecretRandomGeneratorTest extends IntegrationTestCase
*/
private $generator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php
index e5fa4883c4..84d1e9116a 100644
--- a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php
@@ -23,7 +23,7 @@ class TwoFaSecretStaticGeneratorTest extends IntegrationTestCase
*/
private $generator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php b/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php
index fb9d507e26..ad043450d1 100644
--- a/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php
@@ -24,7 +24,7 @@ class SystemSettingsTest extends IntegrationTestCase
*/
private $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php
index 07429e2916..797620443c 100644
--- a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php
@@ -44,7 +44,7 @@ class TwoFactorAuthTest extends IntegrationTestCase
private $userPassword = '123abcDk3_l3';
private $user2faSecret = '123456';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -64,7 +64,7 @@ class TwoFactorAuthTest extends IntegrationTestCase
unset($_GET['authCode']);
}
- public function tearDown()
+ public function tearDown(): void
{
unset($_GET['authCode']);
}
@@ -87,24 +87,22 @@ class TwoFactorAuthTest extends IntegrationTestCase
$this->assertEquals(32, strlen($token));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage TwoFactorAuth_MissingAuthCodeAPI
- */
public function test_onApiGetTokenAuth_throwsErrorWhenMissingTokenWhenUsing2FaAndAuthenticatedCorrectly()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('TwoFactorAuth_MissingAuthCodeAPI');
+
Request::processRequest('UsersManager.getTokenAuth', array(
'userLogin' => $this->userWith2Fa,
'md5Password' => md5($this->userPassword)
));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage TwoFactorAuth_InvalidAuthCode
- */
public function test_onApiGetTokenAuth_throwsErrorWhenInvalidTokenWhenUsing2FaAndAuthenticatedCorrectly()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('TwoFactorAuth_InvalidAuthCode');
+
$_GET['authCode'] = '111222';
Request::processRequest('UsersManager.getTokenAuth', array(
'userLogin' => $this->userWith2Fa,
diff --git a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php
index 154e343cce..d70bc8010e 100644
--- a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php
+++ b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php
@@ -39,7 +39,7 @@ class TwoFactorAuthenticationTest extends IntegrationTestCase
*/
private $twoFa;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -92,21 +92,19 @@ class TwoFactorAuthenticationTest extends IntegrationTestCase
$this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('mylogin'));
}
- /**
- * @expectedExceptionMessage Anonymous cannot use
- * @expectedException \Exception
- */
public function test_saveSecret_neverWorksForAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Anonymous cannot use');
+
$this->twoFa->saveSecret('anonymous', '123456');
}
- /**
- * @expectedExceptionMessage no recovery codes have been created
- * @expectedException \Exception
- */
public function test_saveSecret_notWorksWhenNoRecoveryCodesCreated()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('no recovery codes have been created');
+
$this->twoFa->saveSecret('not', '123456');
}
diff --git a/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php b/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php
index 4f32be9264..129f1c4275 100644
--- a/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php
+++ b/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php
@@ -47,7 +47,7 @@ class TwoFactorAuthTest extends SystemTestCase
*/
private $twoFa;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
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) {
diff --git a/plugins/UserId/tests/Fixtures/TrackFewVisitsAndCreateUsers.php b/plugins/UserId/tests/Fixtures/TrackFewVisitsAndCreateUsers.php
index 3c5ac0fcbd..cb390f27cf 100644
--- a/plugins/UserId/tests/Fixtures/TrackFewVisitsAndCreateUsers.php
+++ b/plugins/UserId/tests/Fixtures/TrackFewVisitsAndCreateUsers.php
@@ -19,7 +19,7 @@ class TrackFewVisitsAndCreateUsers extends Fixture
public $dateTime = '2010-02-01 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime);
diff --git a/plugins/UserLanguage/tests/Fixtures/LanguageFixture.php b/plugins/UserLanguage/tests/Fixtures/LanguageFixture.php
index b96356d7bd..b4437b44b8 100644
--- a/plugins/UserLanguage/tests/Fixtures/LanguageFixture.php
+++ b/plugins/UserLanguage/tests/Fixtures/LanguageFixture.php
@@ -18,13 +18,13 @@ class LanguageFixture extends Fixture
public $dateTime = '2014-09-04 00:00:00';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
}
diff --git a/plugins/UsersManager/tests/Fixtures/ManyUsers.php b/plugins/UsersManager/tests/Fixtures/ManyUsers.php
index 1382a55fd2..9eba719d2a 100644
--- a/plugins/UsersManager/tests/Fixtures/ManyUsers.php
+++ b/plugins/UsersManager/tests/Fixtures/ManyUsers.php
@@ -68,13 +68,13 @@ class ManyUsers extends Fixture
$this->addTextSuffixes = $addTextSuffixes;
}
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->setUpUsers();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/UsersManager/tests/Integration/APITest.php b/plugins/UsersManager/tests/Integration/APITest.php
index 7605335e88..cd5b43c269 100644
--- a/plugins/UsersManager/tests/Integration/APITest.php
+++ b/plugins/UsersManager/tests/Integration/APITest.php
@@ -145,7 +145,7 @@ class APITest extends IntegrationTestCase
private $email = 'userlogin@password.de';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -161,7 +161,7 @@ class APITest extends IntegrationTestCase
$this->api->addUser($this->login, $this->password, $this->email);
}
- public function tearDown()
+ public function tearDown(): void
{
Config::getInstance()->General['enable_update_users_email'] = 1;
@@ -293,11 +293,10 @@ class APITest extends IntegrationTestCase
$this->assertSame($expected, $result);
}
- /**
- * @expectedException \Exception
- */
public function test_setUserPreference_throws_whenPreferenceNameContainsUnderscore()
{
+ $this->expectException(\Exception::class);
+
$user2 = 'userLogin2';
$this->api->addUser($user2, 'password', 'userlogin2@password.de');
$this->api->setUserPreference($user2, 'ohOH_myPreferenceName', 'valueForUser2');
@@ -382,12 +381,11 @@ class APITest extends IntegrationTestCase
$this->assertSame($userBefore['ts_password_modified'], $user['ts_password_modified']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionInvalidPasswordTooLong
- */
public function test_updateUser_failsIfPasswordTooLong()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionInvalidPasswordTooLong');
+
$this->api->updateUser($this->login, str_pad('foo', UsersManager::PASSWORD_MAX_LENGTH + 1), 'email@example.com', 'newAlias', false, $this->password);
}
@@ -759,75 +757,67 @@ class APITest extends IntegrationTestCase
$this->assertEquals($expected, $access);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionMultipleRoleSet
- */
public function test_setUserAccess_MultipleRolesCannotBeSet()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionMultipleRoleSet');
+
$this->api->setUserAccess($this->login, array('view', 'admin'), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionNoRoleSet
- */
public function test_setUserAccess_NeedsAtLeastOneRole()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionNoRoleSet');
+
$this->api->setUserAccess($this->login, array(TestCap2::ID), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_setUserAccess_NeedsAtLeastOneRoleAsString()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->setUserAccess($this->login, TestCap2::ID, array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_setUserAccess_InvalidCapability()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->setUserAccess($this->login, array('admin', 'foobar'), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionNoRoleSet
- */
public function test_setUserAccess_NeedsAtLeastOneRoleNoneGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionNoRoleSet');
+
$this->api->setUserAccess($this->login, array(), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAnonymousAccessNotPossible
- */
public function test_setUserAccess_CannotSetAdminToAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAnonymousAccessNotPossible');
+
$this->api->setUserAccess('anonymous', 'admin', array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAnonymousAccessNotPossible
- */
public function test_setUserAccess_CannotSetWriteToAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAnonymousAccessNotPossible');
+
$this->api->setUserAccess('anonymous', 'write', array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function test_setUserAccess_UserDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->setUserAccess('foobar', Admin::ID, array(1));
}
@@ -862,30 +852,27 @@ class APITest extends IntegrationTestCase
$this->assertEquals(array(array('site' => '1', 'access' => 'view')), $access);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_addCapabilities_failsWhenNotCapabilityIsGivenAsString()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->addCapabilities($this->login, View::ID, array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_addCapabilities_failsWhenNotCapabilityIsGivenAsArray()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->addCapabilities($this->login, array(TestCap2::ID, View::ID), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function test_addCapabilities_failsWhenUserDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->addCapabilities('foobar', array(TestCap2::ID), array(1));
}
@@ -963,30 +950,27 @@ class APITest extends IntegrationTestCase
$this->assertEquals($expected, $access);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_removeCapabilities_failsWhenNotCapabilityIsGivenAsString()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->removeCapabilities($this->login, View::ID, array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function test_removeCapabilities_failsWhenNotCapabilityIsGivenAsArray()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->removeCapabilities($this->login, array(TestCap2::ID, View::ID), array(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function test_removeCapabilities_failsWhenUserDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->removeCapabilities('foobar', array(TestCap2::ID), array(1));
}
@@ -1004,12 +988,11 @@ class APITest extends IntegrationTestCase
$this->assertEquals(array(View::ID, TestCap1::ID), $access);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_CurrentPasswordNotCorrect
- */
public function test_setSuperUserAccess_failsIfCurrentPasswordIsIncorrect()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_CurrentPasswordNotCorrect');
+
$this->api->setSuperUserAccess($this->login, true, 'asldfkjds');
}
diff --git a/plugins/UsersManager/tests/Integration/ModelTest.php b/plugins/UsersManager/tests/Integration/ModelTest.php
index e90f2314f2..be2c79d333 100644
--- a/plugins/UsersManager/tests/Integration/ModelTest.php
+++ b/plugins/UsersManager/tests/Integration/ModelTest.php
@@ -44,7 +44,7 @@ class ModelTest extends IntegrationTestCase
private $login = 'userLogin';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/UsersManager/tests/Integration/UserAccessFilterTest.php b/plugins/UsersManager/tests/Integration/UserAccessFilterTest.php
index 1d837a7d9f..86c150e2ed 100644
--- a/plugins/UsersManager/tests/Integration/UserAccessFilterTest.php
+++ b/plugins/UsersManager/tests/Integration/UserAccessFilterTest.php
@@ -56,7 +56,7 @@ class UserAccessFilterTest extends IntegrationTestCase
'login8' => array('view' => array(4,7), 'admin' => array(2,5)), // access to a couple of sites with admin and view
);
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/UsersManager/tests/Integration/UserPreferencesTest.php b/plugins/UsersManager/tests/Integration/UserPreferencesTest.php
index b584541442..4367918029 100644
--- a/plugins/UsersManager/tests/Integration/UserPreferencesTest.php
+++ b/plugins/UsersManager/tests/Integration/UserPreferencesTest.php
@@ -29,7 +29,7 @@ class UserPreferencesTest extends IntegrationTestCase
*/
private $userPreferences;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/plugins/UsersManager/tests/Integration/UsersManagerTest.php b/plugins/UsersManager/tests/Integration/UsersManagerTest.php
index 15f2124ab6..d7ae784bf1 100644
--- a/plugins/UsersManager/tests/Integration/UsersManagerTest.php
+++ b/plugins/UsersManager/tests/Integration/UsersManagerTest.php
@@ -45,7 +45,7 @@ class UsersManagerTest extends IntegrationTestCase
private $backupIdentity;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -67,7 +67,7 @@ class UsersManagerTest extends IntegrationTestCase
$this->model = new Model();
}
- public function tearDown()
+ public function tearDown(): void
{
FakeAccess::$identity = $this->backupIdentity;
parent::tearDown();
@@ -125,12 +125,13 @@ class UsersManagerTest extends IntegrationTestCase
}
/**
- * bad password => exception#
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionInvalidPassword
+ * bad password => exception
*/
public function testUpdateUserBadpasswd()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionInvalidPassword');
+
$login = "login";
$user = array('login' => $login,
'password' => "geqgeagae",
@@ -162,31 +163,32 @@ class UsersManagerTest extends IntegrationTestCase
/**
* @dataProvider getAddUserInvalidLoginData
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionInvalidLogin
*/
public function testAddUserWrongLogin($userLogin, $password, $email, $alias)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionInvalidLogin');
+
$this->api->addUser($userLogin, $password, $email, $alias);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionLoginExists
- */
public function testAddUserExistingLogin()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionLoginExists');
+
$this->api->addUser("test", "password", "email@email.com", "alias");
$this->api->addUser("test", "password2", "em2ail@email.com", "al2ias");
}
/**
* @see https://github.com/piwik/piwik/issues/8548
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionLoginExists
*/
public function testAddUserExistingLoginCaseInsensitive()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionLoginExists');
+
$this->api->addUser("test", "password", "email@email.com", "alias");
$this->api->addUser("TeSt", "password2", "em2ail@email.com", "al2ias");
}
@@ -204,20 +206,20 @@ class UsersManagerTest extends IntegrationTestCase
/**
* @dataProvider getWrongPasswordTestData
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionInvalidPassword
*/
public function testAddUserWrongPassword($userLogin, $password, $email, $alias)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionInvalidPassword');
+
$this->api->addUser($userLogin, $password, $email, $alias);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage mail
- */
public function testAddUserWrongEmail()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('mail');
+
$this->api->addUser('geggeqgeqag', 'geqgeagae', "ema il@email.com", 'alias');
}
@@ -323,64 +325,58 @@ class UsersManagerTest extends IntegrationTestCase
], $access);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_AddUserNoInitialAccessError
- */
public function test_addUser_shouldNotAllowAdminUsersToCreateUsers_WithNoInitialSiteWithAccess()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_AddUserNoInitialAccessError');
+
FakeAccess::$superUser = false;
FakeAccess::$idSitesAdmin = [1];
$this->api->addUser('userLogin2', 'password', 'userlogin2@email.com', 'userLogin2');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasAdminAccess Fake exception
- */
public function test_addUser_shouldNotAllowAdminUsersToCreateUsersWithAccessToSite_ThatAdminUserDoesNotHaveAccessTo()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasAdminAccess Fake exception');
+
FakeAccess::$superUser = false;
FakeAccess::$idSitesAdmin = [2];
$this->api->addUser('userLogin2', 'password', 'userlogin2@email.com', 'userLogin2', false, 1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testDeleteUserDoesntExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
$this->api->deleteUser("geggeqggnew");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testDeleteUserEmptyUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->deleteUser("");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testDeleteUserNullUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->deleteUser(null);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionDeleteOnlyUserWithSuperUserAccess
- */
public function testDeleteUser_ShouldFail_InCaseTheUserIsTheOnlyRemainingSuperUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionDeleteOnlyUserWithSuperUserAccess');
+
//add user and set some rights
$this->api->addUser("regularuser", "geqgeagae1", "test1@test.com", "alias1");
$this->api->addUser("superuser", "geqgeagae2", "test2@test.com", "alias2");
@@ -439,12 +435,11 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertFalse($option);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testGetUserNoUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
// try to get it, it should raise an exception
$this->api->getUser("geggeqgeqag");
}
@@ -464,8 +459,8 @@ class UsersManagerTest extends IntegrationTestCase
// check that all fields are the same
$this->assertEquals($login, $user['login']);
- $this->assertInternalType('string', $user['password']);
- $this->assertInternalType('string', $user['date_registered']);
+ self::assertIsString($user['password']);
+ self::assertIsString($user['date_registered']);
$this->assertEquals($email, $user['email']);
//alias shouldn't be empty even if no alias specified
@@ -501,12 +496,11 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertEquals(array($user1, $user2), $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSomeAdminAccess Fake exception
- */
public function testGetUsers_withViewAccess_shouldThrowAnException()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess Fake exception');
+
$this->api->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
$this->api->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
$this->api->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
@@ -553,73 +547,66 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertSame('geggeqge632ge56a4qag', $this->api->getUserLoginFromUserEmail('teSGgT@tesgt.com'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testGetUserLoginFromUserEmail_shouldThrowException_IfUserDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->getUserLoginFromUserEmail('unknownUser@teSsgt.com');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSomeAdminAccess Fake exception
- */
public function testGetUserLoginFromUserEmail_shouldThrowException_IfUserDoesNotHaveAtLeastAdminPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSomeAdminAccess Fake exception');
+
FakeAccess::clearAccess($superUser = false, $admin =array(), $view = array(1));
$this->api->getUserLoginFromUserEmail('tegst@tesgt.com');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testSetUserAccessNoLogin()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
FakeAccess::clearAccess($superUser = false, $admin =array(1), $view = array());
$this->api->setUserAccess("nologin", "view", 1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function testSetUserAccessWrongAccessSpecified()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
FakeAccess::clearAccess($superUser = false, $admin =array(1), $view = array());
$this->api->setUserAccess("gegg4564eqgeqag", "viewnotknown", 1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function testSetUserAccess_ShouldFail_SuperUserAccessIsNotAllowed()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
FakeAccess::clearAccess($superUser = false, $admin =array(1), $view = array());
$this->api->setUserAccess("gegg4564eqgeqag", "superuser", 1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testSetUserAccess_ShouldFail_IfLoginIsConfigSuperUserLogin()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
FakeAccess::clearAccess($superUser = false, $admin =array(1), $view = array());
$this->api->setUserAccess('superusertest', 'view', 1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserHasSuperUserAccess
- */
public function testSetUserAccess_ShouldFail_IfLoginIsUserWithSuperUserAccess()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserHasSuperUserAccess');
+
$this->api->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
$userUpdater = new UserUpdater();
$userUpdater->setSuperUserAccessWithoutCurrentPassword('gegg4564eqgeqag', true);
@@ -672,11 +659,10 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertEquals($idSites, array_keys($access));
}
- /**
- * @expectedException \Exception
- */
public function testSetUserAccess_ShouldNotBeAbleToSetAnyAccess_IfIdSitesIsEmpty()
{
+ $this->expectException(\Exception::class);
+
$this->api->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
$this->api->setUserAccess("gegg4564eqgeqag", "view", array());
@@ -818,44 +804,40 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertEquals($wanted1, $access1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasSuperUserAccess Fake exception
- */
public function testSetSuperUserAccess_ShouldFail_IfUserHasNotSuperUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('checkUserHasSuperUserAccess Fake exception');
+
$pwd = $this->createCurrentUser();
FakeAccess::$superUser= false;
$this->api->setSuperUserAccess('nologin', false, $pwd);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testSetSuperUserAccess_ShouldFail_IfUserWithGivenLoginDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$pwd = $this->createCurrentUser();
$this->api->setSuperUserAccess('nologin', false, $pwd);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionEditAnonymous
- */
public function testSetSuperUserAccess_ShouldFail_IfUserIsAnonymous()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionEditAnonymous');
+
$pwd = $this->createCurrentUser();
$this->api->setSuperUserAccess('anonymous', true, $pwd);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionRemoveSuperUserAccessOnlySuperUser
- */
public function testSetSuperUserAccess_ShouldFail_IfUserIsOnlyRemainingUserWithSuperUserAccess()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionRemoveSuperUserAccessOnlySuperUser');
+
$pwd = $this->createCurrentUser();
$this->api->addUser('login1', 'password1', 'test@example.com', false);
@@ -923,39 +905,35 @@ class UsersManagerTest extends IntegrationTestCase
$this->assertEquals(1, $users[2]['superuser_access']);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testGetSitesAccessFromUserWrongUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->getSitesAccessFromUser("user1");
}
- /**
- * @expectedException \Exception
- */
public function testGetUsersAccessFromSiteWrongIdSite()
{
+ $this->expectException(\Exception::class);
+
FakeAccess::$superUser = false;
$this->api->getUsersAccessFromSite(1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionAccessValues
- */
public function testGetUsersSitesFromAccessWrongSite()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionAccessValues');
+
$this->api->getUsersSitesFromAccess('unknown');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionUserDoesNotExist
- */
public function testUpdateUserNonExistingLogin()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionUserDoesNotExist');
+
$this->api->updateUser("lolgin", "password");
}
@@ -979,12 +957,11 @@ class UsersManagerTest extends IntegrationTestCase
$this->_checkUserHasNotChanged($user, "passowordOK");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ConfirmWithPassword
- */
public function testUpdateUserFailsNoCurrentPassword()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ConfirmWithPassword');
+
$login = "login";
$user = array('login' => $login,
'password' => "geqgeagae",
@@ -997,12 +974,11 @@ class UsersManagerTest extends IntegrationTestCase
$this->api->updateUser($login, "passowordOK", false, false, false, "");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_CurrentPasswordNotCorrect
- */
public function testUpdateUserFailsWrongCurrentPassword()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_CurrentPasswordNotCorrect');
+
$login = "login";
$user = array('login' => $login,
'password' => "geqgeagae",
@@ -1015,12 +991,11 @@ class UsersManagerTest extends IntegrationTestCase
$this->api->updateUser($login, "passowordOK", false, false, false, "geqgeag");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_CurrentPasswordNotCorrect
- */
public function testUpdateUserFailsWrongCurrentPassword_requiresThePasswordOfCurrentLoggedInUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_CurrentPasswordNotCorrect');
+
$login = "login";
$user = array('login' => $login,
'password' => "geqgeagae",
@@ -1072,22 +1047,23 @@ class UsersManagerTest extends IntegrationTestCase
/**
* check to modify as the user
- * @expectedException \Exception
- * @expectedExceptionMessage UsersManager_ExceptionLoginExists
*/
public function testAddUserIAmTheUser()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('UsersManager_ExceptionLoginExists');
+
FakeAccess::$identity = 'login';
$this->testUpdateUserNoEmailNoAlias();
}
/**
* check to modify as being another user => exception
- *
- * @expectedException \Exception
*/
public function testUpdateUserIAmNotTheUser()
{
+ $this->expectException(\Exception::class);
+
FakeAccess::$identity = 'login2';
FakeAccess::$superUser = false;
$this->testUpdateUserNoEmailNoAlias();
@@ -1112,11 +1088,10 @@ class UsersManagerTest extends IntegrationTestCase
$this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com", "NEW ALIAS");
}
- /**
- * @expectedException \Exception
- */
public function testGetUserByEmailInvalidMail()
{
+ $this->expectException(\Exception::class);
+
$this->api->getUserByEmail('email@test.com');
}
diff --git a/plugins/VisitFrequency/tests/Integration/APITest.php b/plugins/VisitFrequency/tests/Integration/APITest.php
index dfba727d4f..b5580c670d 100644
--- a/plugins/VisitFrequency/tests/Integration/APITest.php
+++ b/plugins/VisitFrequency/tests/Integration/APITest.php
@@ -19,7 +19,7 @@ class APITest extends IntegrationTestCase
private $idSite;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->api = API::getInstance();
diff --git a/plugins/VisitTime/tests/Unit/AddSegmentByLabelInUTCTest.php b/plugins/VisitTime/tests/Unit/AddSegmentByLabelInUTCTest.php
index 50b4f137f3..c082fc9eb3 100644
--- a/plugins/VisitTime/tests/Unit/AddSegmentByLabelInUTCTest.php
+++ b/plugins/VisitTime/tests/Unit/AddSegmentByLabelInUTCTest.php
@@ -25,7 +25,7 @@ class AddSegmentByLabelInUTCTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRow(array('label' => '0'));
diff --git a/plugins/VisitorGenerator b/plugins/VisitorGenerator
-Subproject 055f3fd695ba386c8de871a849ffd90ba4cb528
+Subproject 053b017633254568cfba2006cab826b90a93391
diff --git a/plugins/VisitsSummary/tests/Integration/VisitsSummaryTest.php b/plugins/VisitsSummary/tests/Integration/VisitsSummaryTest.php
index 221f48daa0..2c30400730 100644
--- a/plugins/VisitsSummary/tests/Integration/VisitsSummaryTest.php
+++ b/plugins/VisitsSummary/tests/Integration/VisitsSummaryTest.php
@@ -31,7 +31,7 @@ class VisitsSummaryTest extends IntegrationTestCase
protected $date = '2014-04-04';
private $column = 'nb_users';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->plugin = new VisitsSummary();
@@ -42,7 +42,7 @@ class VisitsSummaryTest extends IntegrationTestCase
Fixture::createWebsite('2014-01-01 00:00:00');
}
- public function tearDown()
+ public function tearDown(): void
{
// clean up your test here if needed
$tables = ArchiveTableCreator::getTablesArchivesInstalled();
diff --git a/plugins/VisitsSummary/tests/Unit/Reports/GetTest.php b/plugins/VisitsSummary/tests/Unit/Reports/GetTest.php
index 8831ca7146..c89efdf689 100644
--- a/plugins/VisitsSummary/tests/Unit/Reports/GetTest.php
+++ b/plugins/VisitsSummary/tests/Unit/Reports/GetTest.php
@@ -26,7 +26,7 @@ class GetTest extends \PHPUnit\Framework\TestCase
private $column = 'nb_users';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->get = new Get();
diff --git a/plugins/Widgetize/tests/Fixtures/WidgetizeFixture.php b/plugins/Widgetize/tests/Fixtures/WidgetizeFixture.php
index 322eb0754c..8f3522de79 100644
--- a/plugins/Widgetize/tests/Fixtures/WidgetizeFixture.php
+++ b/plugins/Widgetize/tests/Fixtures/WidgetizeFixture.php
@@ -26,13 +26,13 @@ class WidgetizeFixture extends Fixture
array('name' => 'Visit Docs', 'match' => 'url', 'pattern' => 'docs', 'patternType' => 'contains', 'revenue' => false),
);
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
$this->setUpGoals();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/plugins/Widgetize/tests/System/WidgetTest.php b/plugins/Widgetize/tests/System/WidgetTest.php
index 7cffdb013f..8aaed9f84f 100644
--- a/plugins/Widgetize/tests/System/WidgetTest.php
+++ b/plugins/Widgetize/tests/System/WidgetTest.php
@@ -28,7 +28,7 @@ class WidgetTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -38,7 +38,7 @@ class WidgetTest extends SystemTestCase
$_GET['date'] = '2013-01-23';
}
- public function tearDown()
+ public function tearDown(): void
{
$_GET = array();
parent::tearDown();