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
path: root/tests
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 /tests
parentf28c7fa6cb6c63c8f459206448c7dcb93568099e (diff)
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5 * submodule updates * fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php2
-rw-r--r--tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php2
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php2
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php2
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php2
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php2
-rw-r--r--tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php2
-rw-r--r--tests/PHPUnit/Benchmarks/TrackerBenchmark.php2
-rw-r--r--tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php4
-rw-r--r--tests/PHPUnit/Fixtures/InvalidVisits.php4
-rw-r--r--tests/PHPUnit/Fixtures/JSTrackingUIFixture.php2
-rw-r--r--tests/PHPUnit/Fixtures/LatestStableInstall.php2
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogs.php12
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php2
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php4
-rw-r--r--tests/PHPUnit/Fixtures/OmniFixture.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitWithSiteSearch.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php4
-rw-r--r--tests/PHPUnit/Fixtures/RawArchiveDataWithTempAndInvalidated.php2
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php6
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php4
-rw-r--r--tests/PHPUnit/Fixtures/SqlDump.php2
-rw-r--r--tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php4
-rw-r--r--tests/PHPUnit/Fixtures/UITestFixture.php2
-rw-r--r--tests/PHPUnit/Fixtures/Utf8mb4.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php4
-rw-r--r--tests/PHPUnit/Framework/Constraint/HttpResponseText.php11
-rw-r--r--tests/PHPUnit/Framework/Constraint/ResponseCode.php11
-rw-r--r--tests/PHPUnit/Framework/Fixture.php14
-rw-r--r--tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php6
-rw-r--r--tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php2
-rw-r--r--tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php12
-rw-r--r--tests/PHPUnit/Framework/TestCase/SystemTestCase.php4
-rw-r--r--tests/PHPUnit/Framework/TestCase/UnitTestCase.php4
-rw-r--r--tests/PHPUnit/Framework/TestRequest/Response.php2
-rw-r--r--tests/PHPUnit/Framework/XssTesting.php2
-rw-r--r--tests/PHPUnit/Integration/API/RequestTest.php4
-rw-r--r--tests/PHPUnit/Integration/AccessTest.php74
-rw-r--r--tests/PHPUnit/Integration/Application/Kernel/PluginListTest.php2
-rw-r--r--tests/PHPUnit/Integration/Archive/ArchivePurgerTest.php2
-rw-r--r--tests/PHPUnit/Integration/Archive/ChunksTest.php2
-rw-r--r--tests/PHPUnit/Integration/Archive/DataTableFactoryTest.php9
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessingTest.php4
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php2
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php2
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessor/PluginsArchiverTest.php11
-rw-r--r--tests/PHPUnit/Integration/ArchiveTest.php2
-rw-r--r--tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php2
-rw-r--r--tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php2
-rw-r--r--tests/PHPUnit/Integration/AssetManagerTest.php4
-rw-r--r--tests/PHPUnit/Integration/CacheIdTest.php4
-rw-r--r--tests/PHPUnit/Integration/CliMulti/OutputTest.php11
-rw-r--r--tests/PHPUnit/Integration/CliMulti/ProcessTest.php11
-rw-r--r--tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php4
-rw-r--r--tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php4
-rw-r--r--tests/PHPUnit/Integration/Columns/DimensionTest.php4
-rw-r--r--tests/PHPUnit/Integration/Columns/UpdaterTest.php4
-rw-r--r--tests/PHPUnit/Integration/Concurrency/DistributedListTest.php2
-rw-r--r--tests/PHPUnit/Integration/Concurrency/LockBackend/MysqlLockBackendTest.php4
-rw-r--r--tests/PHPUnit/Integration/Concurrency/LockTest.php4
-rw-r--r--tests/PHPUnit/Integration/Config/CacheTest.php9
-rw-r--r--tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php4
-rw-r--r--tests/PHPUnit/Integration/CronArchiveTest.php8
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ActionsTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php4
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ModelTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataAccess/TableMetadataTest.php2
-rw-r--r--tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php46
-rw-r--r--tests/PHPUnit/Integration/Db/TransactionLevelTest.php2
-rw-r--r--tests/PHPUnit/Integration/DbHelperTest.php6
-rw-r--r--tests/PHPUnit/Integration/DbTest.php11
-rw-r--r--tests/PHPUnit/Integration/DependencyTest.php2
-rw-r--r--tests/PHPUnit/Integration/DocumentationGeneratorTest.php2
-rw-r--r--tests/PHPUnit/Integration/HttpTest.php12
-rw-r--r--tests/PHPUnit/Integration/JsProxyTest.php2
-rw-r--r--tests/PHPUnit/Integration/LogDeleterTest.php2
-rw-r--r--tests/PHPUnit/Integration/Measurable/MeasurableSettingTest.php16
-rw-r--r--tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php9
-rw-r--r--tests/PHPUnit/Integration/NumberFormatterTest.php4
-rw-r--r--tests/PHPUnit/Integration/Period/FactoryTest.php14
-rw-r--r--tests/PHPUnit/Integration/PiwikTest.php4
-rw-r--r--tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php4
-rw-r--r--tests/PHPUnit/Integration/Plugin/CategoriesTest.php4
-rw-r--r--tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php4
-rw-r--r--tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php2
-rw-r--r--tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php2
-rw-r--r--tests/PHPUnit/Integration/Plugin/Dimension/DimensionMetadataProviderTest.php2
-rw-r--r--tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php9
-rw-r--r--tests/PHPUnit/Integration/Plugin/ManagerTest.php2
-rw-r--r--tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php2
-rw-r--r--tests/PHPUnit/Integration/Plugin/SettingsProviderTest.php4
-rw-r--r--tests/PHPUnit/Integration/Plugin/WidgetsProviderTest.php4
-rw-r--r--tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php2
-rw-r--r--tests/PHPUnit/Integration/ReleaseCheckListTest.php3
-rw-r--r--tests/PHPUnit/Integration/ReportRenderingTest.php2
-rw-r--r--tests/PHPUnit/Integration/ReportTest.php15
-rw-r--r--tests/PHPUnit/Integration/SegmentTest.php2
-rw-r--r--tests/PHPUnit/Integration/SequenceTest.php14
-rw-r--r--tests/PHPUnit/Integration/ServeStaticFileTest.php4
-rw-r--r--tests/PHPUnit/Integration/Session/SessionAuthTest.php2
-rw-r--r--tests/PHPUnit/Integration/Settings/BaseSettingsTestCase.php14
-rw-r--r--tests/PHPUnit/Integration/Settings/IntegrationTestCase.php8
-rw-r--r--tests/PHPUnit/Integration/Settings/Measurable/MeasurablePropertyTest.php9
-rw-r--r--tests/PHPUnit/Integration/Settings/Measurable/MeasurableSettingTest.php2
-rw-r--r--tests/PHPUnit/Integration/Settings/Plugin/SystemConfigSettingTest.php16
-rw-r--r--tests/PHPUnit/Integration/Settings/Plugin/SystemSettingTest.php23
-rw-r--r--tests/PHPUnit/Integration/Settings/Plugin/UserSettingTest.php14
-rw-r--r--tests/PHPUnit/Integration/Settings/SettingTest.php44
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/CacheTest.php2
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/ConfigTest.php9
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/MeasurableSettingsTableTest.php16
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/NullTest.php2
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/PluginSettingsTableTest.php30
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/Backend/SitesTableTest.php14
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/FactoryTest.php2
-rw-r--r--tests/PHPUnit/Integration/Settings/Storage/StorageTest.php2
-rw-r--r--tests/PHPUnit/Integration/SiteTest.php9
-rw-r--r--tests/PHPUnit/Integration/SqlTest.php4
-rw-r--r--tests/PHPUnit/Integration/Tracker/ActionTest.php4
-rw-r--r--tests/PHPUnit/Integration/Tracker/DbTest.php16
-rw-r--r--tests/PHPUnit/Integration/Tracker/FailuresTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php7
-rw-r--r--tests/PHPUnit/Integration/Tracker/HandlerTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/ModelTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/PingRequestTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/RequestSetTest.php4
-rw-r--r--tests/PHPUnit/Integration/Tracker/RequestTest.php30
-rw-r--r--tests/PHPUnit/Integration/Tracker/SettingsTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php7
-rw-r--r--tests/PHPUnit/Integration/Tracker/Visit/ReferrerSpamFilterTest.php4
-rw-r--r--tests/PHPUnit/Integration/Tracker/Visit2Test.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/VisitTest.php2
-rw-r--r--tests/PHPUnit/Integration/TrackerTest.php4
-rw-r--r--tests/PHPUnit/Integration/Updater/Migration/Db/FactoryTest.php2
-rw-r--r--tests/PHPUnit/Integration/Updater/Migration/Db/MigrationsTest.php7
-rw-r--r--tests/PHPUnit/Integration/Updater/Migration/FactoryTest.php2
-rw-r--r--tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php2
-rw-r--r--tests/PHPUnit/Integration/Validator/IdSiteTest.php17
-rw-r--r--tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php21
-rw-r--r--tests/PHPUnit/System/AllWebsitesTest.php2
-rw-r--r--tests/PHPUnit/System/ApiGetReportMetadataTest.php4
-rw-r--r--tests/PHPUnit/System/BackwardsCompatibility1XTest.php2
-rw-r--r--tests/PHPUnit/System/BlobReportLimitingTest.php2
-rw-r--r--tests/PHPUnit/System/CliMultiTest.php9
-rw-r--r--tests/PHPUnit/System/ConsoleTest.php2
-rw-r--r--tests/PHPUnit/System/CookieTest.php8
-rw-r--r--tests/PHPUnit/System/CustomEventsTest.php2
-rw-r--r--tests/PHPUnit/System/DuplicateActionsTest.php2
-rw-r--r--tests/PHPUnit/System/EnvironmentValidationTest.php6
-rw-r--r--tests/PHPUnit/System/FrontControllerTest.php4
-rw-r--r--tests/PHPUnit/System/ImportLogsTest.php12
-rw-r--r--tests/PHPUnit/System/MultipleSitesArchivingTest.php2
-rw-r--r--tests/PHPUnit/System/OneVisitorTwoVisitsTest.php4
-rw-r--r--tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php2
-rw-r--r--tests/PHPUnit/System/PivotByQueryParamTest.php2
-rw-r--r--tests/PHPUnit/System/RawLogDaoTest.php9
-rw-r--r--tests/PHPUnit/System/TimezonesTest.php2
-rw-r--r--tests/PHPUnit/System/TrackerResponseTest.php2
-rw-r--r--tests/PHPUnit/System/TrackerTest.php16
-rw-r--r--tests/PHPUnit/System/UserIdAndVisitorIdTest.php4
-rw-r--r--tests/PHPUnit/Unit/API/ApiRendererTest.php9
-rw-r--r--tests/PHPUnit/Unit/API/ResponseBuilderTest.php2
-rw-r--r--tests/PHPUnit/Unit/Archive/ChunkTest.php2
-rw-r--r--tests/PHPUnit/Unit/Archiver/RequestTest.php2
-rw-r--r--tests/PHPUnit/Unit/AssetManager/UIAssetCacheBusterTest.php2
-rw-r--r--tests/PHPUnit/Unit/Category/CategoryListTest.php9
-rw-r--r--tests/PHPUnit/Unit/Category/CategoryTest.php9
-rw-r--r--tests/PHPUnit/Unit/Category/SubcategoryTest.php2
-rw-r--r--tests/PHPUnit/Unit/CommonTest.php37
-rw-r--r--tests/PHPUnit/Unit/Config/IniFileChainCacheTest.php4
-rw-r--r--tests/PHPUnit/Unit/ConfigTest.php4
-rw-r--r--tests/PHPUnit/Unit/Container/IniConfigDefinitionSourceTest.php7
-rw-r--r--tests/PHPUnit/Unit/CookieTest.php2
-rw-r--r--tests/PHPUnit/Unit/CronArchive/FixedSiteIdsTest.php2
-rw-r--r--tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php4
-rw-r--r--tests/PHPUnit/Unit/DataAccess/ArchiveTableCreatorTest.php4
-rw-r--r--tests/PHPUnit/Unit/DataAccess/ArchiveWriterTest.php10
-rw-r--r--tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php15
-rw-r--r--tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinTablesTest.php16
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterByLabelMappingTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/AddSegmentValueTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/ColumnCallbackDeleteMetadataTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/PrependValueToMetadataTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/TruncateTest.php4
-rw-r--r--tests/PHPUnit/Unit/DataTable/ManagerTest.php9
-rw-r--r--tests/PHPUnit/Unit/DataTable/MapTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Renderer/ConsoleTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Renderer/PHPTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php2
-rw-r--r--tests/PHPUnit/Unit/DataTable/RowTest.php9
-rw-r--r--tests/PHPUnit/Unit/DataTableTest.php17
-rw-r--r--tests/PHPUnit/Unit/DateTest.php26
-rw-r--r--tests/PHPUnit/Unit/FactoryTest.php7
-rw-r--r--tests/PHPUnit/Unit/FilesystemTest.php14
-rw-r--r--tests/PHPUnit/Unit/LegacyAutoLoaderTest.php10
-rw-r--r--tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php6
-rw-r--r--tests/PHPUnit/Unit/Metrics/FormatterTest.php6
-rw-r--r--tests/PHPUnit/Unit/Metrics/SorterTest.php2
-rw-r--r--tests/PHPUnit/Unit/Period/BasePeriodTest.php4
-rw-r--r--tests/PHPUnit/Unit/Period/DayTest.php21
-rw-r--r--tests/PHPUnit/Unit/Period/RangeTest.php28
-rw-r--r--tests/PHPUnit/Unit/PeriodTest.php20
-rw-r--r--tests/PHPUnit/Unit/Plugin/ComponentFactoryTest.php3
-rw-r--r--tests/PHPUnit/Unit/Report/ReportWidgetConfigTest.php9
-rw-r--r--tests/PHPUnit/Unit/Report/ReportWidgetFactoryTest.php2
-rw-r--r--tests/PHPUnit/Unit/Scheduler/Schedule/DailyTest.php38
-rw-r--r--tests/PHPUnit/Unit/Scheduler/Schedule/HourlyTest.php28
-rw-r--r--tests/PHPUnit/Unit/Scheduler/Schedule/MonthlyTest.php19
-rw-r--r--tests/PHPUnit/Unit/Scheduler/Schedule/WeeklyTest.php48
-rw-r--r--tests/PHPUnit/Unit/Scheduler/SchedulerTest.php8
-rw-r--r--tests/PHPUnit/Unit/Scheduler/TimetableTest.php2
-rw-r--r--tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php13
-rw-r--r--tests/PHPUnit/Unit/Session/SessionFingerprintTest.php4
-rw-r--r--tests/PHPUnit/Unit/Session/SessionInitializerTest.php27
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestSetTest.php4
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestTest.php11
-rw-r--r--tests/PHPUnit/Unit/Tracker/ResponseTest.php8
-rw-r--r--tests/PHPUnit/Unit/TrackerTest.php9
-rw-r--r--tests/PHPUnit/Unit/Translation/Loader/LoaderCacheTest.php4
-rw-r--r--tests/PHPUnit/Unit/UrlHelperTest.php2
-rw-r--r--tests/PHPUnit/Unit/Validator/CharacterLengthTest.php20
-rw-r--r--tests/PHPUnit/Unit/Validator/DateTimeTest.php14
-rw-r--r--tests/PHPUnit/Unit/Validator/EmailTest.php5
-rw-r--r--tests/PHPUnit/Unit/Validator/IpRangesTest.php8
-rw-r--r--tests/PHPUnit/Unit/Validator/NotEmptyTest.php5
-rw-r--r--tests/PHPUnit/Unit/Validator/NumberRangeTest.php32
-rw-r--r--tests/PHPUnit/Unit/Validator/UrlLikeTest.php5
-rw-r--r--tests/PHPUnit/Unit/Validator/WhiteListedValueTest.php14
-rw-r--r--tests/PHPUnit/Unit/VersionTest.php2
-rw-r--r--tests/PHPUnit/Unit/Widget/WidgetConfigTest.php9
-rw-r--r--tests/PHPUnit/Unit/Widget/WidgetContainerConfigTest.php9
-rw-r--r--tests/PHPUnit/Unit/Widget/WidgetsListTest.php2
-rw-r--r--tests/PHPUnit/phpunit.xml.dist3
-rw-r--r--tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php4
-rw-r--r--tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php2
-rw-r--r--tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php4
264 files changed, 842 insertions, 1005 deletions
diff --git a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
index c002e0e906..c24e9e1b59 100644
--- a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
@@ -19,7 +19,7 @@ class ArchiveQueryBenchmark extends BenchmarkTestCase
{
private $archivingLaunched = false;
- public function setUp()
+ public function setUp(): void
{
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
diff --git a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
index 504b31bbd6..ca3a9dfd2b 100644
--- a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
@@ -13,7 +13,7 @@ use Piwik\Tests\Framework\TestCase\BenchmarkTestCase;
*/
class ArchivingProcessBenchmark extends BenchmarkTestCase
{
- public function setUp()
+ public function setUp(): void
{
BenchmarkTestCase::deleteArchiveTables();
}
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
index 81941ff67f..2a2a909469 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
@@ -20,7 +20,7 @@ class Piwik_Test_Fixture_ManyThousandSitesOneVisitEach
public $siteCount = 20000;
public $idSite = 'all';
- public function setUp()
+ public function setUp(): void
{
for ($i = 0; $i != $this->siteCount; ++$i) {
$idSite = Fixture::createWebsite(
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
index 9ee3984b6d..0de4f2662a 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
@@ -21,7 +21,7 @@ class Piwik_Test_Fixture_OneSiteThousandsOfDistinctUrlsOverMonth
public $period = 'month';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
// add one site
Fixture::createWebsite(
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
index c5bebf92c1..c437cd9599 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
@@ -21,7 +21,7 @@ class Piwik_Test_Fixture_OneSiteTwelveThousandVisitsOneYear
public $idGoal1 = 1;
public $idGoal2 = 2;
- public function setUp()
+ public function setUp(): void
{
// add one site
Fixture::createWebsite(
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
index 0216e66e93..d0af41e26e 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
@@ -18,7 +18,7 @@ class Piwik_Test_Fixture_ThousandSitesTwelveVisitsEachOneDay
public $period = 'day';
public $idSite = 'all';
- public function setUp()
+ public function setUp(): void
{
// add one thousand sites
$allIdSites = array();
diff --git a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
index bd55f3e5b8..d69c98a4c1 100644
--- a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
@@ -18,7 +18,7 @@ class MultiSitesBenchmark extends BenchmarkTestCase
{
private $archivingLaunched = false;
- public function setUp()
+ public function setUp(): void
{
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
diff --git a/tests/PHPUnit/Benchmarks/TrackerBenchmark.php b/tests/PHPUnit/Benchmarks/TrackerBenchmark.php
index dfb8353196..16595d8777 100644
--- a/tests/PHPUnit/Benchmarks/TrackerBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/TrackerBenchmark.php
@@ -20,7 +20,7 @@ class TrackerBenchmark extends BenchmarkTestCase
private $visitTimes = array();
private $t = null;
- public function setUp()
+ public function setUp(): void
{
// set up action URLs
for ($i = 0; $i != 100; ++$i) {
diff --git a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php
index cf4252499f..a7969cdff0 100644
--- a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php
+++ b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php
@@ -24,7 +24,7 @@ class FewVisitsWithSetVisitorId extends Fixture
const USER_ID_EXAMPLE_COM = 'email@example.com';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits_setVisitorId();
@@ -34,7 +34,7 @@ class FewVisitsWithSetVisitorId extends Fixture
$this->trackVisits_oneWeekLater_setUserId();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php
index 7891e69a0d..f7694d0fea 100644
--- a/tests/PHPUnit/Fixtures/InvalidVisits.php
+++ b/tests/PHPUnit/Fixtures/InvalidVisits.php
@@ -24,13 +24,13 @@ class InvalidVisits extends Fixture
public $trackInvalidRequests = true;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php b/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php
index 73c86fef61..9aebb3e0a0 100644
--- a/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php
+++ b/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php
@@ -16,7 +16,7 @@ use Piwik\Tests\Framework\Fixture;
class JSTrackingUIFixture extends Fixture
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Fixtures/LatestStableInstall.php b/tests/PHPUnit/Fixtures/LatestStableInstall.php
index 3a1c381552..3d1578511b 100644
--- a/tests/PHPUnit/Fixtures/LatestStableInstall.php
+++ b/tests/PHPUnit/Fixtures/LatestStableInstall.php
@@ -30,7 +30,7 @@ class LatestStableInstall extends Fixture
$this->subdirToInstall = $subdirToInstall;
}
- public function setUp()
+ public function setUp(): void
{
$this->removeLatestStableInstall();
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
index 6b4fea8102..dce0894088 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
@@ -32,7 +32,7 @@ class ManySitesImportedLogs extends Fixture
public $includeNginxJson = false;
public $includeApiCustomVarMapping = false;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
@@ -45,7 +45,7 @@ class ManySitesImportedLogs extends Fixture
$this->setupSegments();
}
- public function tearDown()
+ public function tearDown(): void
{
LocationProvider::$providers = null;
ManyVisitsWithGeoIP::unsetLocationProvider();
@@ -158,7 +158,7 @@ class ManySitesImportedLogs extends Fixture
$output = self::executeLogImporter($logFile, $opts);
$output = implode("\n", $output);
- $this->assertContains('4 filtered log lines', $output);
+ self::assertStringContainsString('4 filtered log lines', $output);
}
private function logWithIncludeFilters()
@@ -174,7 +174,7 @@ class ManySitesImportedLogs extends Fixture
$output = self::executeLogImporter($logFile, $opts);
$output = implode("\n", $output);
- $this->assertContains('2 filtered log lines', $output);
+ self::assertStringContainsString('2 filtered log lines', $output);
}
private function setupSegments()
@@ -288,13 +288,13 @@ class ManySitesImportedLogs extends Fixture
$output = self::executeLogImporter($logFile, $opts);
$output = implode("\n", $output);
- $this->assertContains('1 filtered log lines', $output);
+ self::assertStringContainsString('1 filtered log lines', $output);
// test that correct logs are excluded when the host is in the log file
$output = self::executeLogImporter($logFileWithHost, $opts);
$output = implode("\n", $output);
- $this->assertContains('2 filtered log lines', $output);
+ self::assertStringContainsString('2 filtered log lines', $output);
}
/**
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
index 72ba5ed6b6..097b2fecbb 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
@@ -28,7 +28,7 @@ class ManySitesImportedLogsWithXssAttempts extends ManySitesImportedLogs
$this->now = Date::factory('now');
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index a34fd1f3c4..571795140b 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -56,7 +56,7 @@ class ManyVisitsWithGeoIP extends Fixture
protected $idGoal;
protected $idGoal2;
- public function setUp()
+ public function setUp(): void
{
// set option, so tracked data for the past won't get converted
Option::set(GeoIp2::SWITCH_TO_ISO_REGIONS_OPTION_NAME, 1);
@@ -78,7 +78,7 @@ class ManyVisitsWithGeoIP extends Fixture
$this->setLocationProvider('GeoIP2-City.mmdb');
}
- public function tearDown()
+ public function tearDown(): void
{
$this->unsetLocationProvider();
}
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
index 78f77c134e..66dc09b052 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
@@ -30,7 +30,7 @@ class ManyVisitsWithMockLocationProvider extends Fixture
$this->nextDay = Date::factory($this->dateTime)->addDay(1)->getDatetime();
}
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->customDimensionId = CustomDimensions\API::getInstance()->configureNewCustomDimension($this->idSite, 'testdim', 'visit', '1');
@@ -41,7 +41,7 @@ class ManyVisitsWithMockLocationProvider extends Fixture
ManyVisitsWithGeoIP::unsetLocationProvider();
}
- public function tearDown()
+ public function tearDown(): void
{
ManyVisitsWithGeoIP::unsetLocationProvider();
}
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php b/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
index dcd6b8e169..2551896b14 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
@@ -19,13 +19,13 @@ class ManyVisitsWithSubDirReferrersAndCustomVars extends Fixture
public $dateTime = '2010-03-05 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/OmniFixture.php b/tests/PHPUnit/Fixtures/OmniFixture.php
index 3b716a22c5..626580574c 100644
--- a/tests/PHPUnit/Fixtures/OmniFixture.php
+++ b/tests/PHPUnit/Fixtures/OmniFixture.php
@@ -122,7 +122,7 @@ class OmniFixture extends Fixture
return $result;
}
- public function setUp()
+ public function setUp(): void
{
$firstFixture = array_shift($this->fixtures);
$this->setUpFixture($firstFixture);
@@ -140,7 +140,7 @@ class OmniFixture extends Fixture
Option::set("Tests.forcedNowTimestamp", $this->now->getTimestamp());
}
- public function tearDown()
+ public function tearDown(): void
{
foreach ($this->fixtures as $fixture) {
echo "Tearing down " . get_class($fixture) . "...\n";
diff --git a/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php b/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
index 33c6c3adfc..178f02d2d2 100644
--- a/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
+++ b/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
@@ -18,13 +18,13 @@ class OneVisitSeveralPageViews extends Fixture
public $dateTime = '2010-03-06 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php b/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
index 49e78f32de..67500c6efc 100644
--- a/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
+++ b/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
@@ -19,13 +19,13 @@ class OneVisitWithAbnormalPageviewUrls extends Fixture
public $dateTime = '2010-03-06 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitWithSiteSearch.php b/tests/PHPUnit/Fixtures/OneVisitWithSiteSearch.php
index af78854901..bf0f8f14a1 100644
--- a/tests/PHPUnit/Fixtures/OneVisitWithSiteSearch.php
+++ b/tests/PHPUnit/Fixtures/OneVisitWithSiteSearch.php
@@ -9,13 +9,13 @@ class OneVisitWithSiteSearch extends Fixture
public $dateTime = '2012-01-11 07:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
index a4945fcaba..0bbf1a673a 100644
--- a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
+++ b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
@@ -30,14 +30,14 @@ class OneVisitorTwoVisits extends Fixture
public $simulateIntegerOverflow = false;
public $maxUnsignedIntegerValue = '4294967295';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->simulateIntegerOverflow();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/RawArchiveDataWithTempAndInvalidated.php b/tests/PHPUnit/Fixtures/RawArchiveDataWithTempAndInvalidated.php
index b4f597b97a..b007548eae 100644
--- a/tests/PHPUnit/Fixtures/RawArchiveDataWithTempAndInvalidated.php
+++ b/tests/PHPUnit/Fixtures/RawArchiveDataWithTempAndInvalidated.php
@@ -355,7 +355,7 @@ class RawArchiveDataWithTempAndInvalidated extends Fixture
*/
public $february;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
index 5865c114da..d7d096c736 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
@@ -21,13 +21,13 @@ class SomeVisitsAllConversions extends Fixture
public $idGoal_OneConversionPerVisit = 1;
public $idGoal_MultipleConversionPerVisit = 2;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
index 22c2ff5c20..7a8826db71 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
@@ -24,14 +24,14 @@ class SomeVisitsCustomVariablesCampaignsNotHeuristics extends Fixture
public $idGoal = 1;
private $tmpHost = '';
- public function setUp()
+ public function setUp(): void
{
$this->setPiwikEnvironmentOverrides();
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
}
@@ -233,7 +233,7 @@ class SomeVisitsCustomVariablesCampaignsNotHeuristics extends Fixture
$_COOKIE[$customVarCookieName] = '{"1":["VAR 1 set, var 2 not set","yes"],"3":["var 3 set","yes!!!!"]}';
// test loading 'id' cookie
- self::assertContains("_viewts=" . $viewts, $t->getUrlTrackPageView());
+ self::assertStringContainsString("_viewts=" . $viewts, $t->getUrlTrackPageView());
self::assertEquals($uuid, $t->getVisitorId());
self::assertEquals($t->getAttributionInfo(), $_COOKIE[$refCookieName]);
self::assertEquals(array("VAR 1 set, var 2 not set", "yes"), $t->getCustomVariable(1));
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
index 21f011f75c..d2d9ce3714 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
@@ -22,13 +22,13 @@ class SomeVisitsManyPageviewsWithTransitions extends Fixture
private $prefixCounter = 0;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php b/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
index 52b5ca7044..60a60be815 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
@@ -19,13 +19,13 @@ class SomeVisitsWithLongUrls extends Fixture
public $dateTime = '2010-03-06 01:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
index 798ed1a620..18d2066619 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
@@ -19,13 +19,13 @@ class SomeVisitsWithNonUnicodePageTitles extends Fixture
public $idSite1 = 1;
public $dateTime = '2010-01-03 11:22:33';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsites();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php
index 8c9175c8c1..94cddf0bc5 100644
--- a/tests/PHPUnit/Fixtures/SqlDump.php
+++ b/tests/PHPUnit/Fixtures/SqlDump.php
@@ -27,7 +27,7 @@ class SqlDump extends Fixture
public $tablesPrefix = 'piwik_';
public $dumpUrl = "http://piwik-team.s3.amazonaws.com/generated-logs-one-day.sql.gz";
- public function setUp()
+ public function setUp(): void
{
// drop all tables
Db::dropAllTables();
diff --git a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
index de0cb90db7..07c24faff9 100644
--- a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
+++ b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
@@ -23,14 +23,14 @@ class ThreeGoalsOnePageview extends Fixture
public $idGoal2 = 2;
public $idGoal3 = 3;
- public function setUp()
+ public function setUp(): void
{
Fixture::createSuperUser();
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
index 9b90c82e85..e522c5e296 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
@@ -22,13 +22,13 @@ class ThreeSitesWithManyVisitsWithSiteSearch extends Fixture
public $idSite3 = 3;
public $dateTime = '2010-01-03 11:22:33';
- public function setUp()
+ public function setUp(): void
{
self::setUpWebsites();
self::trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php b/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
index 0bd11ca17c..d772a5e356 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
@@ -20,13 +20,13 @@ class ThreeSitesWithSharedVisitors extends Fixture
public $idSite2 = 3;
public $dateTime = '2010-03-06 11:22:33';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php b/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php
index 0096500959..330efd179a 100644
--- a/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php
+++ b/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php
@@ -21,7 +21,7 @@ class ThreeVisitsWithCustomEvents extends Fixture
public $idSite = 1;
public static $idGoalTriggeredOnEventCategory = 3;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
@@ -226,7 +226,7 @@ class ThreeVisitsWithCustomEvents extends Fixture
$vis->setCustomVariable($id = 1, $name = 'Visit Scope Custom var', $value = 'should not appear in events report Bis', $scope = 'visit');
}
- public function tearDown()
+ public function tearDown(): void
{
}
} \ No newline at end of file
diff --git a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
index 9c24915796..fc6bb422a8 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
@@ -21,7 +21,7 @@ class TwoSitesEcommerceOrderWithItems extends Fixture
public $idSite2 = 2;
public $idGoalStandard = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
self::setUpScheduledReports($this->idSite);
@@ -30,7 +30,7 @@ class TwoSitesEcommerceOrderWithItems extends Fixture
$this->trackVisitsSite2($url = 'http://example-site2.com/index.htm');
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
index 6134f01ec6..29892783da 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
@@ -26,13 +26,13 @@ class TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers extends Fixture
'justice )(&^#%$ NOT \'" corruption!',
);
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
index ba89314897..3ac0bd51a0 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
@@ -27,14 +27,14 @@ class TwoSitesTwoVisitorsDifferentDays extends Fixture
const URL_IS_GOAL_WITH_CAMPAIGN_PARAMETERS = 'http://example.org/index.htm?pk_campaign=goal-matching-url-parameter';
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
self::setUpScheduledReports($this->idSite1);
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
index 373b418992..4b5d3c8fd5 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
@@ -22,13 +22,13 @@ class TwoSitesVisitsInPast extends Fixture
public $idSite = 1;
public $idSite2 = 2;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
index 90c98bb950..6b909ba43e 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
@@ -22,13 +22,13 @@ class TwoSitesWithAnnotations extends Fixture
public $idSite1 = 1;
public $idSite2 = 2;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->addAnnotations();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
index ac1dfc4236..6623b931b9 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
@@ -20,13 +20,13 @@ class TwoVisitsNoKeywordWithBot extends Fixture
public $dateTime = '2010-03-06 11:22:33';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
index 8840f9767b..c9e6e93aa2 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
@@ -28,13 +28,13 @@ class TwoVisitsWithCustomVariables extends Fixture
public $resolutionWidthToUse = 1111;
public $resolutionHeightToUse = 222;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php
index e83070eb8f..dd4dadea0a 100644
--- a/tests/PHPUnit/Fixtures/UITestFixture.php
+++ b/tests/PHPUnit/Fixtures/UITestFixture.php
@@ -66,7 +66,7 @@ class UITestFixture extends SqlDump
$this->xssTesting = new XssTesting();
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Fixtures/Utf8mb4.php b/tests/PHPUnit/Fixtures/Utf8mb4.php
index 20313332b9..7d61f28f8c 100644
--- a/tests/PHPUnit/Fixtures/Utf8mb4.php
+++ b/tests/PHPUnit/Fixtures/Utf8mb4.php
@@ -20,13 +20,13 @@ class Utf8mb4 extends Fixture
public $trackInvalidRequests = true;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php b/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
index 16d6849a09..df3fcdadb9 100644
--- a/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
@@ -19,13 +19,13 @@ class VisitOverSeveralDaysImportedLogs extends Fixture
public $dateTime = '2013-04-07 19:00:00';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
index 88f31ba955..0cebc6d29a 100644
--- a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
+++ b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
@@ -25,13 +25,13 @@ class VisitsInDifferentTimezones extends Fixture
$this->date = Date::factory($this->dateTime)->toString();
}
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php b/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
index 8f15052b02..d670799389 100644
--- a/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
+++ b/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
@@ -42,13 +42,13 @@ class VisitsOverSeveralDays extends Fixture
'http://mixi.jp',
);
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php b/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
index 3784ddb824..675ee917d0 100644
--- a/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
+++ b/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
@@ -21,13 +21,13 @@ class VisitsTwoWebsitesWithAdditionalVisits extends Fixture
public $idSite1 = 1;
public $idSite2 = 2;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/PHPUnit/Framework/Constraint/HttpResponseText.php b/tests/PHPUnit/Framework/Constraint/HttpResponseText.php
index 2225d9daf3..318a69ad8d 100644
--- a/tests/PHPUnit/Framework/Constraint/HttpResponseText.php
+++ b/tests/PHPUnit/Framework/Constraint/HttpResponseText.php
@@ -10,9 +10,10 @@ namespace Piwik\Tests\Framework\Constraint;
/**
* @deprecated
*/
-class HttpResponseText extends \PHPUnit_Framework_Constraint
+class HttpResponseText extends \PHPUnit\Framework\Constraint\Constraint
{
private $actualCode;
+ private $value;
/**
* @param string $value Expected response text.
@@ -47,7 +48,7 @@ class HttpResponseText extends \PHPUnit_Framework_Constraint
* @param mixed $other Value or object to evaluate.
* @return bool
*/
- public function matches($other)
+ public function matches($other): bool
{
$this->actualCode = $this->getResponse($other);
@@ -59,8 +60,8 @@ class HttpResponseText extends \PHPUnit_Framework_Constraint
*
* @return string
*/
- public function toString()
+ public function toString(): string
{
- return 'does not return response text ' . $this->exporter->export($this->value) . ' it is ' . $this->actualCode;
+ return 'does not return response text ' . $this->exporter()->export($this->value) . ' it is ' . $this->actualCode;
}
-}?>
+} \ No newline at end of file
diff --git a/tests/PHPUnit/Framework/Constraint/ResponseCode.php b/tests/PHPUnit/Framework/Constraint/ResponseCode.php
index fc0cae2f97..a9977a097d 100644
--- a/tests/PHPUnit/Framework/Constraint/ResponseCode.php
+++ b/tests/PHPUnit/Framework/Constraint/ResponseCode.php
@@ -10,9 +10,10 @@ namespace Piwik\Tests\Framework\Constraint;
/**
* @deprecated
*/
-class ResponseCode extends \PHPUnit_Framework_Constraint
+class ResponseCode extends \PHPUnit\Framework\Constraint\Constraint
{
private $actualCode;
+ private $value;
/**
* @param integer $value Expected response code
@@ -30,7 +31,7 @@ class ResponseCode extends \PHPUnit_Framework_Constraint
* @param mixed $other Value or object to evaluate.
* @return bool
*/
- public function matches($other)
+ public function matches($other): bool
{
$options = array(
CURLOPT_URL => $other,
@@ -55,8 +56,8 @@ class ResponseCode extends \PHPUnit_Framework_Constraint
*
* @return string
*/
- public function toString()
+ public function toString(): string
{
- return 'does not return response code ' . $this->exporter->export($this->value) . ' it is ' . $this->actualCode;
+ return 'does not return response code ' . $this->exporter()->export($this->value) . ' it is ' . $this->actualCode;
}
-}?>
+} \ No newline at end of file
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php
index 6f9a54ed7c..307daa838c 100644
--- a/tests/PHPUnit/Framework/Fixture.php
+++ b/tests/PHPUnit/Framework/Fixture.php
@@ -72,7 +72,7 @@ use ReflectionClass;
* merging some together.
* @since 2.8.0
*/
-class Fixture extends \PHPUnit_Framework_Assert
+class Fixture extends \PHPUnit\Framework\Assert
{
const IMAGES_GENERATED_ONLY_FOR_OS = 'linux';
const IMAGES_GENERATED_FOR_PHP = '7.2';
@@ -174,13 +174,13 @@ class Fixture extends \PHPUnit_Framework_Assert
}
/** Adds data to Piwik. Creates sites, tracks visits, imports log files, etc. */
- public function setUp()
+ public function setUp(): void
{
// empty
}
/** Does any clean up. Most of the time there will be no need to clean up. */
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
@@ -670,10 +670,10 @@ class Fixture extends \PHPUnit_Framework_Assert
$trans_gif_64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
$expectedResponse = base64_decode($trans_gif_64);
- self::assertContains($expectedResponse, $response);
- self::assertContains('This resource is part of Matomo.', $response);
- self::assertNotContains('Error', $response);
- self::assertNotContains('Fatal', $response);
+ self::assertStringContainsString($expectedResponse, $response);
+ self::assertStringContainsString('This resource is part of Matomo.', $response);
+ self::assertStringNotContainsString('Error', $response);
+ self::assertStringNotContainsString('Fatal', $response);
}
/**
diff --git a/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php b/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php
index 011d8aa8e0..c4802942c6 100644
--- a/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/BenchmarkTestCase.php
@@ -27,7 +27,7 @@ abstract class BenchmarkTestCase extends SystemTestCase
{
public static $fixture;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
$dbName = false;
if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) {
@@ -69,7 +69,7 @@ abstract class BenchmarkTestCase extends SystemTestCase
}
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
// only drop the database if PIWIK_BENCHMARK_DATABASE isn't set
$dropDatabase = empty($GLOBALS['PIWIK_BENCHMARK_DATABASE']);
@@ -104,7 +104,7 @@ class Piwik_Test_Fixture_EmptyOneSite
public $period = 'day';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
// add one site
Fixture::createWebsite(
diff --git a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
index 91747847c2..46bd0546ff 100644
--- a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
@@ -71,7 +71,7 @@ class ConsoleCommandTestCase extends SystemTestCase
*/
protected $application;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php
index 21d8d678a6..5e46659a8a 100644
--- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php
@@ -46,18 +46,18 @@ abstract class IntegrationTestCase extends SystemTestCase
* If your test modifies table columns, you will need to recreate the database
* completely. This can be accomplished by:
*
- * public function setUp()
+ * public function setUp(): void
* {
* self::$fixture->performSetUp();
* }
*
- * public function tearDown()
+ * public function tearDown(): void
* {
* parent::tearDown();
* self::$fixture->performTearDown();
* }
*/
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
static::configureFixture(static::$fixture);
parent::setUpBeforeClass();
@@ -66,7 +66,7 @@ abstract class IntegrationTestCase extends SystemTestCase
self::$tableData = self::getDbTablesWithData();
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
self::$tableData = array();
}
@@ -74,7 +74,7 @@ abstract class IntegrationTestCase extends SystemTestCase
/**
* Setup the database and create the base tables for all tests
*/
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -98,7 +98,7 @@ abstract class IntegrationTestCase extends SystemTestCase
/**
* Resets all caches and drops the database
*/
- public function tearDown()
+ public function tearDown(): void
{
static::$fixture->clearInMemoryCaches();
static::$fixture->destroyEnvironment();
diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
index ca97061c42..1cc27afef4 100644
--- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
@@ -58,7 +58,7 @@ abstract class SystemTestCase extends TestCase
*/
public static $fixture;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
Log::debug("Setting up " . get_called_class());
@@ -83,7 +83,7 @@ abstract class SystemTestCase extends TestCase
}
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
Log::debug("Tearing down " . get_called_class());
diff --git a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
index e61a6255db..8c0516c3d6 100644
--- a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
@@ -26,7 +26,7 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase
*/
protected $environment;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -35,7 +35,7 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase
File::reset();
}
- public function tearDown()
+ public function tearDown(): void
{
File::reset();
diff --git a/tests/PHPUnit/Framework/TestRequest/Response.php b/tests/PHPUnit/Framework/TestRequest/Response.php
index 24ddae506d..0e6e062366 100644
--- a/tests/PHPUnit/Framework/TestRequest/Response.php
+++ b/tests/PHPUnit/Framework/TestRequest/Response.php
@@ -9,7 +9,7 @@
namespace Piwik\Tests\Framework\TestRequest;
use Piwik\API\Request;
-use PHPUnit_Framework_Assert as Asserts;
+use PHPUnit\Framework\Assert as Asserts;
use Exception;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
diff --git a/tests/PHPUnit/Framework/XssTesting.php b/tests/PHPUnit/Framework/XssTesting.php
index 4e9160562a..ba2853a40e 100644
--- a/tests/PHPUnit/Framework/XssTesting.php
+++ b/tests/PHPUnit/Framework/XssTesting.php
@@ -170,7 +170,7 @@ JS;
$actualEntries = array_values($actualEntries);
try {
- \PHPUnit_Framework_Assert::assertEquals($expectedEntries, $actualEntries);
+ \PHPUnit\Framework\Assert::assertEquals($expectedEntries, $actualEntries);
} catch (\Exception $ex) {
print "XssTesting::sanityCheck() failed, got: " . var_export($actualEntries, true)
. "\nexpected: " . var_export($expectedEntries, true);
diff --git a/tests/PHPUnit/Integration/API/RequestTest.php b/tests/PHPUnit/Integration/API/RequestTest.php
index 2ef1576b60..809a876925 100644
--- a/tests/PHPUnit/Integration/API/RequestTest.php
+++ b/tests/PHPUnit/Integration/API/RequestTest.php
@@ -18,9 +18,9 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class RequestTest extends IntegrationTestCase
{
- /** @var \Piwik\Auth|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Piwik\Auth|\PHPUnit\Framework\MockObject\MockObject */
private $auth;
- /** @var \Piwik\Access|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Piwik\Access|\PHPUnit\Framework\MockObject\MockObject */
private $access;
private $userAuthToken = 'token';
diff --git a/tests/PHPUnit/Integration/AccessTest.php b/tests/PHPUnit/Integration/AccessTest.php
index daf6a3008e..d1eeec96ea 100644
--- a/tests/PHPUnit/Integration/AccessTest.php
+++ b/tests/PHPUnit/Integration/AccessTest.php
@@ -167,11 +167,9 @@ class AccessTest extends IntegrationTestCase
$this->assertEmpty($access->getSitesIdWithViewAccess());
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasSuperUserAccessWithEmptyAccess()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasSuperUserAccess();
}
@@ -183,11 +181,9 @@ class AccessTest extends IntegrationTestCase
$access->checkUserHasSuperUserAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasSomeAdminAccessWithEmptyAccess()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasSomeAdminAccess();
}
@@ -212,38 +208,30 @@ class AccessTest extends IntegrationTestCase
$this->assertFalse($access->isUserHasSomeAdminAccess());
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function test_CheckUserHasSomeAdminAccessWithSomeAccessFails_IfUserHasPermissionsToSitesButIsNotAuthenticated()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$mock = $this->createAccessMockWithAccessToSitesButUnauthenticated(array(2, 9));
$mock->checkUserHasSomeAdminAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function test_checkUserHasAdminAccessFails_IfUserHasPermissionsToSitesButIsNotAuthenticated()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$mock = $this->createAccessMockWithAccessToSitesButUnauthenticated(array(2, 9));
$mock->checkUserHasAdminAccess('2');
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function test_checkUserHasSomeViewAccessFails_IfUserHasPermissionsToSitesButIsNotAuthenticated()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$mock = $this->createAccessMockWithAccessToSitesButUnauthenticated(array(2, 9));
$mock->checkUserHasSomeViewAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function test_checkUserHasViewAccessFails_IfUserHasPermissionsToSitesButIsNotAuthenticated()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$mock = $this->createAccessMockWithAccessToSitesButUnauthenticated(array(2, 9));
$mock->checkUserHasViewAccess('2');
}
@@ -259,11 +247,9 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasSomeAdminAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasSomeViewAccessWithEmptyAccess()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasSomeViewAccess();
}
@@ -297,11 +283,9 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasSomeWriteAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasSomeWriteAccessWithSomeAccessDoesNotHaveAccess()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$mock = $this->createAccessMockWithAuthenticatedUser(array('getRawSitesWithSomeViewAccess'));
$mock->expects($this->once())
@@ -311,11 +295,9 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasSomeWriteAccess();
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasViewAccessWithEmptyAccessNoSiteIdsGiven()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasViewAccess(array());
}
@@ -351,12 +333,10 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasViewAccess('all');
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasViewAccessWithSomeAccessFailure()
{
- $mock = $this->getMockBuilder('Piwik\Access')->setMethods(array('getSitesIdWithAtLeastViewAccess'))->getMock();
+ $this->expectException(\Piwik\NoAccessException::class);
+ $mock = $this->getMockBuilder('Piwik\Access')->onlyMethods(array('getSitesIdWithAtLeastViewAccess'))->getMock();
$mock->expects($this->once())
->method('getSitesIdWithAtLeastViewAccess')
@@ -365,11 +345,9 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasViewAccess(array(1, 5));
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasWriteAccessWithEmptyAccessNoSiteIdsGiven()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasWriteAccess(array());
}
@@ -381,12 +359,10 @@ class AccessTest extends IntegrationTestCase
$access->checkUserHasWriteAccess(array());
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasWriteAccessWithSomeAccessFailure()
{
- $mock = $this->getMockBuilder('Piwik\Access')->setMethods(array('getSitesIdWithAtLeastWriteAccess'))->getMock();
+ $this->expectException(\Piwik\NoAccessException::class);
+ $mock = $this->getMockBuilder('Piwik\Access')->onlyMethods(array('getSitesIdWithAtLeastWriteAccess'))->getMock();
$mock->expects($this->once())
->method('getSitesIdWithAtLeastWriteAccess')
@@ -402,18 +378,16 @@ class AccessTest extends IntegrationTestCase
$access->checkUserHasAdminAccess(array());
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasAdminAccessWithEmptyAccessNoSiteIdsGiven()
{
+ $this->expectException(\Piwik\NoAccessException::class);
$access = $this->getAccess();
$access->checkUserHasViewAccess(array());
}
public function testCheckUserHasAdminAccessWithSomeAccessSuccessIdSitesAsString()
{
- $mock = $this->getMock(
+ $mock = $this->createPartialMock(
'Piwik\Access',
array('getSitesIdWithAdminAccess')
);
@@ -427,7 +401,7 @@ class AccessTest extends IntegrationTestCase
public function testCheckUserHasAdminAccessWithSomeAccessSuccessAllSites()
{
- $mock = $this->getMock(
+ $mock = $this->createPartialMock(
'Piwik\Access',
array('getSitesIdWithAdminAccess', 'getSitesIdWithAtLeastViewAccess')
);
@@ -443,12 +417,10 @@ class AccessTest extends IntegrationTestCase
$mock->checkUserHasAdminAccess('all');
}
- /**
- * @expectedException \Piwik\NoAccessException
- */
public function testCheckUserHasAdminAccessWithSomeAccessFailure()
{
- $mock = $this->getMock(
+ $this->expectException(\Piwik\NoAccessException::class);
+ $mock = $this->createPartialMock(
'Piwik\Access',
array('getSitesIdWithAdminAccess')
);
@@ -697,7 +669,7 @@ class AccessTest extends IntegrationTestCase
private function createPiwikAuthMockInstance()
{
return $this->getMockBuilder('Piwik\\Auth')
- ->setMethods(array('authenticate', 'getName', 'getTokenAuthSecret', 'getLogin', 'setTokenAuth', 'setLogin',
+ ->onlyMethods(array('authenticate', 'getName', 'getTokenAuthSecret', 'getLogin', 'setTokenAuth', 'setLogin',
'setPassword', 'setPasswordHash'))
->getMock();
}
@@ -705,7 +677,7 @@ class AccessTest extends IntegrationTestCase
private function createAccessMockWithAccessToSitesButUnauthenticated($idSites)
{
$mock = $this->getMockBuilder('Piwik\Access')
- ->setMethods(array('getRawSitesWithSomeViewAccess', 'loadSitesIfNeeded'))
+ ->onlyMethods(array('getRawSitesWithSomeViewAccess', 'loadSitesIfNeeded'))
->getMock();
// this method will be actually never called as it is unauthenticated. The tests are supposed to fail if it
@@ -719,7 +691,7 @@ class AccessTest extends IntegrationTestCase
private function createAccessMockWithAuthenticatedUser($methodsToMock = array())
{
- $methods = array('authenticate');
+ $methods = [];
foreach ($methodsToMock as $methodToMock) {
$methods[] = $methodToMock;
@@ -730,7 +702,7 @@ class AccessTest extends IntegrationTestCase
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login', 'token')));
- $mock = $this->getMockBuilder('Piwik\Access')->setMethods($methods)->getMock();
+ $mock = $this->getMockBuilder('Piwik\Access')->onlyMethods($methods)->getMock();
$mock->reloadAccess($authMock);
return $mock;
diff --git a/tests/PHPUnit/Integration/Application/Kernel/PluginListTest.php b/tests/PHPUnit/Integration/Application/Kernel/PluginListTest.php
index 35d6999446..a8f0df2369 100644
--- a/tests/PHPUnit/Integration/Application/Kernel/PluginListTest.php
+++ b/tests/PHPUnit/Integration/Application/Kernel/PluginListTest.php
@@ -22,7 +22,7 @@ class PluginListTest extends \PHPUnit\Framework\TestCase
*/
private $pluginList = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->pluginList = $this->makePluginList();
diff --git a/tests/PHPUnit/Integration/Archive/ArchivePurgerTest.php b/tests/PHPUnit/Integration/Archive/ArchivePurgerTest.php
index 8045376478..9a0bed2301 100644
--- a/tests/PHPUnit/Integration/Archive/ArchivePurgerTest.php
+++ b/tests/PHPUnit/Integration/Archive/ArchivePurgerTest.php
@@ -41,7 +41,7 @@ class ArchivePurgerTest extends IntegrationTestCase
*/
private $february;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Archive/ChunksTest.php b/tests/PHPUnit/Integration/Archive/ChunksTest.php
index aba383174f..bd8621b8e8 100644
--- a/tests/PHPUnit/Integration/Archive/ChunksTest.php
+++ b/tests/PHPUnit/Integration/Archive/ChunksTest.php
@@ -33,7 +33,7 @@ class ChunksTest extends IntegrationTestCase
{
private $date = '2015-01-01';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Archive/DataTableFactoryTest.php b/tests/PHPUnit/Integration/Archive/DataTableFactoryTest.php
index 0339cd0473..2f19a7732c 100644
--- a/tests/PHPUnit/Integration/Archive/DataTableFactoryTest.php
+++ b/tests/PHPUnit/Integration/Archive/DataTableFactoryTest.php
@@ -42,7 +42,7 @@ class DataTableFactoryTest extends IntegrationTestCase
'nb_visits' => 97
);
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -267,12 +267,11 @@ class DataTableFactoryTest extends IntegrationTestCase
$this->assertRowEquals($row3, $this->site2, $map->getTable($this->date2)->getRowFromId(1));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage supposed to work with non-numeric data types but it is not tested
- */
public function test_makeMerged_shouldThrowAnException_IfANonNumericDataTypeIsGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('supposed to work with non-numeric data types but it is not tested');
+
$dataType = 'blob';
$dataNames = array('nb_visits');
diff --git a/tests/PHPUnit/Integration/ArchiveProcessingTest.php b/tests/PHPUnit/Integration/ArchiveProcessingTest.php
index 0a493dff34..5c53c4a2b1 100644
--- a/tests/PHPUnit/Integration/ArchiveProcessingTest.php
+++ b/tests/PHPUnit/Integration/ArchiveProcessingTest.php
@@ -40,7 +40,7 @@ class ArchiveProcessorTest extends ArchiveProcessor\Loader
*/
class ArchiveProcessingTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -50,7 +50,7 @@ class ArchiveProcessingTest extends IntegrationTestCase
ArchiveTableCreator::$tablesAlreadyInstalled = null;
}
- public function tearDown()
+ public function tearDown(): void
{
ArchiveTableCreator::$tablesAlreadyInstalled = null;
}
diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php
index 4db7bd10d4..0372f7421f 100644
--- a/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php
+++ b/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php
@@ -22,7 +22,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
class ArchivingStatusTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php
index 39fb445c25..ed6c2d3ee8 100644
--- a/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php
+++ b/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php
@@ -19,7 +19,7 @@ use Piwik\Period;
class ParametersTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/PluginsArchiverTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/PluginsArchiverTest.php
index 587fd92662..613e88c9cb 100644
--- a/tests/PHPUnit/Integration/ArchiveProcessor/PluginsArchiverTest.php
+++ b/tests/PHPUnit/Integration/ArchiveProcessor/PluginsArchiverTest.php
@@ -60,7 +60,7 @@ class PluginsArchiverTest extends IntegrationTestCase
*/
private $pluginsArchiver;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -81,13 +81,12 @@ class PluginsArchiverTest extends IntegrationTestCase
return $params;
}
- /**
- * @expectedException \Piwik\ArchiveProcessor\PluginsArchiverException
- * @expectedExceptionMessage Failed query foo bar - in plugin MyPluginName
- * @expectedExceptionCode 42
- */
public function test_purgeOutdatedArchives_PurgesCorrectTemporaryArchives_WhileKeepingNewerTemporaryArchives_WithBrowserTriggeringEnabled()
{
+ $this->expectException(\Piwik\ArchiveProcessor\PluginsArchiverException::class);
+ $this->expectExceptionCode(42);
+ $this->expectExceptionMessage('Failed query foo bar - in plugin MyPluginName');
+
$this->pluginsArchiver->callAggregateAllPlugins(1, 1);
}
diff --git a/tests/PHPUnit/Integration/ArchiveTest.php b/tests/PHPUnit/Integration/ArchiveTest.php
index bd2e2d8246..9097e82664 100644
--- a/tests/PHPUnit/Integration/ArchiveTest.php
+++ b/tests/PHPUnit/Integration/ArchiveTest.php
@@ -57,7 +57,7 @@ class ArchiveTest extends IntegrationTestCase
*/
public static $fixture;
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php b/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php
index 58a7dafb33..feb0dc8b17 100644
--- a/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php
+++ b/tests/PHPUnit/Integration/ArchiveWithNoVisitsTest.php
@@ -40,7 +40,7 @@ class ArchiveWithNoVisitsTest_MockArchiver extends Archiver
class ArchiveWithNoVisitsTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php b/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php
index 33fb055052..3448607b61 100644
--- a/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php
+++ b/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php
@@ -18,7 +18,7 @@ class UIAssetMinifierTest extends \PHPUnit\Framework\TestCase
*/
private $assetMinifier;
- public function setUp()
+ public function setUp(): void
{
$this->assetMinifier = UIAssetMinifier::getInstance();
}
diff --git a/tests/PHPUnit/Integration/AssetManagerTest.php b/tests/PHPUnit/Integration/AssetManagerTest.php
index 82654af55a..3a5e165071 100644
--- a/tests/PHPUnit/Integration/AssetManagerTest.php
+++ b/tests/PHPUnit/Integration/AssetManagerTest.php
@@ -61,7 +61,7 @@ class AssetManagerTest extends IntegrationTestCase
*/
private $pluginManager;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -80,7 +80,7 @@ class AssetManagerTest extends IntegrationTestCase
$this->setUpPlugins();
}
- public function tearDown()
+ public function tearDown(): void
{
if ($this->assetManager !== null) {
$this->assetManager->removeMergedAssets();
diff --git a/tests/PHPUnit/Integration/CacheIdTest.php b/tests/PHPUnit/Integration/CacheIdTest.php
index 77d150b2d6..7865d8d11c 100644
--- a/tests/PHPUnit/Integration/CacheIdTest.php
+++ b/tests/PHPUnit/Integration/CacheIdTest.php
@@ -18,12 +18,12 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class CacheIdTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
}
diff --git a/tests/PHPUnit/Integration/CliMulti/OutputTest.php b/tests/PHPUnit/Integration/CliMulti/OutputTest.php
index fe06a22d8e..e0a897d526 100644
--- a/tests/PHPUnit/Integration/CliMulti/OutputTest.php
+++ b/tests/PHPUnit/Integration/CliMulti/OutputTest.php
@@ -22,7 +22,7 @@ class OutputTest extends \PHPUnit\Framework\TestCase
*/
private $output;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -31,7 +31,7 @@ class OutputTest extends \PHPUnit\Framework\TestCase
$this->output = new Output('myid');
}
- public function tearDown()
+ public function tearDown(): void
{
if(is_object($this->output)){
$this->output->destroy();
@@ -42,12 +42,11 @@ class OutputTest extends \PHPUnit\Framework\TestCase
parent::tearDown();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The given output id has an invalid format
- */
public function test_construct_shouldFail_IfInvalidOutputIdGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The given output id has an invalid format');
+
new Output('../../');
}
diff --git a/tests/PHPUnit/Integration/CliMulti/ProcessTest.php b/tests/PHPUnit/Integration/CliMulti/ProcessTest.php
index abd0e4ad15..5c14919a71 100644
--- a/tests/PHPUnit/Integration/CliMulti/ProcessTest.php
+++ b/tests/PHPUnit/Integration/CliMulti/ProcessTest.php
@@ -22,7 +22,7 @@ class ProcessTest extends \PHPUnit\Framework\TestCase
*/
private $process;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -30,7 +30,7 @@ class ProcessTest extends \PHPUnit\Framework\TestCase
$this->process = new Process('testPid');
}
- public function tearDown()
+ public function tearDown(): void
{
if(is_object($this->process)){
$this->process->finishProcess();
@@ -38,12 +38,11 @@ class ProcessTest extends \PHPUnit\Framework\TestCase
File::reset();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The given pid has an invalid format
- */
public function test_construct_shouldFailInCasePidIsInvalid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The given pid has an invalid format');
+
new Process('../../htaccess');
}
diff --git a/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php
index 8c662fdb33..ea852ce60a 100644
--- a/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php
+++ b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php
@@ -24,7 +24,7 @@ class ComputedMetricFactoryTest extends IntegrationTestCase
*/
private $factory;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -33,7 +33,7 @@ class ComputedMetricFactoryTest extends IntegrationTestCase
$this->factory = new ComputedMetricFactory(MetricsList::get());
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php
index d4c4d754e2..c92d2da0a7 100644
--- a/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php
+++ b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php
@@ -24,7 +24,7 @@ class DimensionMetricFactoryTest extends IntegrationTestCase
/** @var Dimension */
private $country;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -33,7 +33,7 @@ class DimensionMetricFactoryTest extends IntegrationTestCase
$this->country = new Country();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Columns/DimensionTest.php b/tests/PHPUnit/Integration/Columns/DimensionTest.php
index 6f3e64464c..551da965d8 100644
--- a/tests/PHPUnit/Integration/Columns/DimensionTest.php
+++ b/tests/PHPUnit/Integration/Columns/DimensionTest.php
@@ -79,7 +79,7 @@ class ColumnDimensionTest extends IntegrationTestCase
*/
private $dimension;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -93,7 +93,7 @@ class ColumnDimensionTest extends IntegrationTestCase
$this->dimension = new CustomDimensionTest();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Columns/UpdaterTest.php b/tests/PHPUnit/Integration/Columns/UpdaterTest.php
index 13bf722b5b..c9ca49d0c8 100644
--- a/tests/PHPUnit/Integration/Columns/UpdaterTest.php
+++ b/tests/PHPUnit/Integration/Columns/UpdaterTest.php
@@ -59,7 +59,7 @@ class UpdaterTest extends IntegrationTestCase
*/
private $columnsUpdater;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -189,7 +189,7 @@ class UpdaterTest extends IntegrationTestCase
private function getMockUpdater($hasNewVersion = true)
{
- $result = $this->getMockBuilder("Piwik\\Updater")->setMethods(array('hasNewVersion'))->getMock();
+ $result = $this->getMockBuilder("Piwik\\Updater")->onlyMethods(array('hasNewVersion'))->getMock();
$result->expects($this->any())->method('hasNewVersion')->will($this->returnCallback(function () use ($hasNewVersion) {
return $hasNewVersion;
diff --git a/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php b/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php
index f846b185be..dc322418c2 100644
--- a/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php
+++ b/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php
@@ -33,7 +33,7 @@ class DistributedListTest extends IntegrationTestCase
*/
private $distributedList;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Concurrency/LockBackend/MysqlLockBackendTest.php b/tests/PHPUnit/Integration/Concurrency/LockBackend/MysqlLockBackendTest.php
index 432491591b..8c2c9e1517 100644
--- a/tests/PHPUnit/Integration/Concurrency/LockBackend/MysqlLockBackendTest.php
+++ b/tests/PHPUnit/Integration/Concurrency/LockBackend/MysqlLockBackendTest.php
@@ -21,7 +21,7 @@ class MysqlLockBackendTest extends IntegrationTestCase
private $backend;
private $key = 'testKeyValueKey';
- public function setUp()
+ public function setUp(): void
{
if (!$this->hasDependencies()) {
parent::setUp();
@@ -34,7 +34,7 @@ class MysqlLockBackendTest extends IntegrationTestCase
$this->backend = $this->createMysqlBackend();
}
- public function tearDown()
+ public function tearDown(): void
{
$GLOBALS['PIWIK_TRACKER_MODE'] = false;
Db::destroyDatabaseObject();
diff --git a/tests/PHPUnit/Integration/Concurrency/LockTest.php b/tests/PHPUnit/Integration/Concurrency/LockTest.php
index cb1345c2f2..228c96d08b 100644
--- a/tests/PHPUnit/Integration/Concurrency/LockTest.php
+++ b/tests/PHPUnit/Integration/Concurrency/LockTest.php
@@ -23,7 +23,7 @@ class LockTest extends IntegrationTestCase
*/
public $lock;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -31,7 +31,7 @@ class LockTest extends IntegrationTestCase
$this->lock = $this->createLock($mysql);
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
}
diff --git a/tests/PHPUnit/Integration/Config/CacheTest.php b/tests/PHPUnit/Integration/Config/CacheTest.php
index a5c9c05881..2a9e51415f 100644
--- a/tests/PHPUnit/Integration/Config/CacheTest.php
+++ b/tests/PHPUnit/Integration/Config/CacheTest.php
@@ -24,7 +24,7 @@ class CacheTest extends IntegrationTestCase
private $testHost = 'analytics.test.matomo.org';
- public function setUp()
+ public function setUp(): void
{
unset($GLOBALS['ENABLE_CONFIG_PHP_CACHE']);
$this->setTrustedHosts();
@@ -39,7 +39,7 @@ class CacheTest extends IntegrationTestCase
Config::setSetting('General', 'trusted_hosts', array($this->testHost, 'foonot.exists'));
}
- public function tearDown()
+ public function tearDown(): void
{
$this->setTrustedHosts();
$this->cache->doDelete(IniFileChain::CONFIG_CACHE_KEY);
@@ -55,11 +55,12 @@ class CacheTest extends IntegrationTestCase
/**
* @dataProvider getRandmHosts
- * @expectedException \Exception
- * @expectedExceptionMessage Unsupported host
*/
public function test_construct_failsWhenUsingRandomHost($host)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported host');
+
$_SERVER['HTTP_HOST'] = $host;
new Cache();
}
diff --git a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
index e514e797ea..5dd0327d86 100644
--- a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
+++ b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
@@ -22,7 +22,7 @@ class SharedSiteIdsTest extends IntegrationTestCase
*/
private $sharedSiteIds;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -34,7 +34,7 @@ class SharedSiteIdsTest extends IntegrationTestCase
$this->sharedSiteIds = $this->makeSharedSiteIds(array(1,2,5,9));
}
- public function tearDown()
+ public function tearDown(): void
{
if (!SharedSiteIds::isSupported()) {
return;
diff --git a/tests/PHPUnit/Integration/CronArchiveTest.php b/tests/PHPUnit/Integration/CronArchiveTest.php
index 74f0dc561b..775c348e68 100644
--- a/tests/PHPUnit/Integration/CronArchiveTest.php
+++ b/tests/PHPUnit/Integration/CronArchiveTest.php
@@ -106,9 +106,9 @@ class CronArchiveTest extends IntegrationTestCase
$archiver->init();
$archiver->run();
- $this->assertContains('Will skip segments archiving for today unless they were created recently', $logger->output);
- $this->assertContains('Segment "actions>=1" was created or changed recently and will therefore archive today', $logger->output);
- $this->assertNotContains('Segment "actions>=2" was created recently', $logger->output);
+ self::assertStringContainsString('Will skip segments archiving for today unless they were created recently', $logger->output);
+ self::assertStringContainsString('Segment "actions>=1" was created or changed recently and will therefore archive today', $logger->output);
+ self::assertStringNotContainsString('Segment "actions>=2" was created recently', $logger->output);
}
public function test_output()
@@ -212,7 +212,7 @@ Will pre-process for website id = 1, period = day, date = last52
- pre-processing all visits
LOG;
- $this->assertContains($expected, $logger->output);
+ self::assertStringContainsString($expected, $logger->output);
}
public function provideContainerConfig()
diff --git a/tests/PHPUnit/Integration/DataAccess/ActionsTest.php b/tests/PHPUnit/Integration/DataAccess/ActionsTest.php
index d74e2e655d..ef6b83c869 100644
--- a/tests/PHPUnit/Integration/DataAccess/ActionsTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ActionsTest.php
@@ -22,7 +22,7 @@ class ActionsTest extends IntegrationTestCase
*/
private $actionsAccess;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
index e5d60efddd..e5423c371d 100644
--- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
@@ -54,7 +54,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase
*/
private static $segment2;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -72,7 +72,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase
}
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php
index 5090799496..0ceb3eb959 100644
--- a/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php
@@ -28,7 +28,7 @@ class ArchiveTableDaoTest extends IntegrationTestCase
*/
private $archiveTableDao;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php
index f513518e3b..fa60b7d2dc 100644
--- a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php
@@ -38,7 +38,7 @@ class ArchiveWriterTest extends IntegrationTestCase
{
private $idSite;
- public function setUp()
+ public function setUp(): void
{
Access::getInstance()->setSuperUserAccess(true);
$this->idSite = Fixture::createWebsite('2019-08-29');
diff --git a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
index 817595270b..3aa46d1875 100644
--- a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
@@ -41,7 +41,7 @@ class LogAggregatorTest extends IntegrationTestCase
*/
private $logAggregator;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
index d5191026bb..8f165f0420 100644
--- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
@@ -23,7 +23,7 @@ class ModelTest extends IntegrationTestCase
private $model;
private $tableName = 'archive_numeric_test';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataAccess/TableMetadataTest.php b/tests/PHPUnit/Integration/DataAccess/TableMetadataTest.php
index a1a1bbf7de..b00ae83f4e 100644
--- a/tests/PHPUnit/Integration/DataAccess/TableMetadataTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/TableMetadataTest.php
@@ -21,7 +21,7 @@ class TableMetadataTest extends IntegrationTestCase
*/
private $tableMetadataAccess;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php
index 6d1d5b6eba..30ea7a4934 100644
--- a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php
+++ b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php
@@ -39,7 +39,7 @@ class PivotByDimensionTest extends IntegrationTestCase
*/
public $segmentUsedToGetIntersected = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -50,67 +50,61 @@ class PivotByDimensionTest extends IntegrationTestCase
$this->segmentTableCount = 0;
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Unsupported pivot: report 'ExampleReport.getExampleReport' has no subtable dimension.
- */
public function test_construction_ShouldFail_WhenReportHasNoSubtableAndSegmentFetchingIsDisabled()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported pivot: report \'ExampleReport.getExampleReport\' has no subtable dimension.');
+
$this->loadPlugins('ExampleReport', 'UserCountry');
new PivotByDimension(new DataTable(), "ExampleReport.GetExampleReport", "UserCountry.City", 'nb_visits', $columnLimit = -1, $enableFetchBySegment = false);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Unsupported pivot: the subtable dimension for 'Referrers.getKeywords' does not match the requested pivotBy dimension.
- */
public function test_construction_ShouldFail_WhenDimensionIsNotSubtableAndSegmentFetchingIsDisabled()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported pivot: the subtable dimension for \'Referrers.getKeywords\' does not match the requested pivotBy dimension.');
+
$this->loadPlugins('Referrers', 'UserCountry');
new PivotByDimension(new DataTable(), "Referrers.getKeywords", "UserCountry.City", "nb_visits", $columnLimit = -1, $enableFetchBySegment = false);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Unsupported pivot: No segment for dimension of report 'Resolution.getConfiguration'
- */
public function test_construction_ShouldFail_WhenDimensionIsNotSubtableAndSegmentFetchingIsEnabledButThereIsNoSegment()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported pivot: No segment for dimension of report \'Resolution.getConfiguration\'');
+
$this->loadPlugins('Referrers', 'Resolution');
new PivotByDimension(new DataTable(), "Resolution.GetConfiguration", "Referrers.Keyword", "nb_visits");
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Invalid dimension 'ExampleTracker.InvalidDimension'
- */
public function test_construction_ShouldFail_WhenDimensionDoesNotExist()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid dimension \'ExampleTracker.InvalidDimension\'');
+
$this->loadPlugins('ExampleReport', 'ExampleTracker');
new PivotByDimension(new DataTable(), "ExampleReport.GetExampleReport", "ExampleTracker.InvalidDimension", 'nb_visits');
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Unsupported pivot: No report for pivot dimension 'ExampleTracker.ExampleDimension'
- */
public function test_construction_ShouldFail_WhenThereIsNoReportForADimension()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unsupported pivot: No report for pivot dimension \'ExampleTracker.ExampleDimension\'');
+
$this->loadPlugins('ExampleReport', 'ExampleTracker');
new PivotByDimension(new DataTable(), "ExampleReport.GetExampleReport", "ExampleTracker.ExampleDimension", "nb_visits");
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Unable to find report 'ExampleReport.InvalidReport'
- */
public function test_construction_ShouldFail_WhenSpecifiedReportIsNotValid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unable to find report \'ExampleReport.InvalidReport\'');
+
$this->loadPlugins('ExampleReport', 'Referrers');
new PivotByDimension(new DataTable(), "ExampleReport.InvalidReport", "Referrers.Keyword", "nb_visits");
@@ -380,7 +374,7 @@ class PivotByDimensionTest extends IntegrationTestCase
public function provideContainerConfig()
{
- $proxyMock = $this->getMockBuilder('stdClass')->setMethods(array('call'))->getMock();
+ $proxyMock = $this->getMockBuilder('stdClass')->addMethods(array('call'))->getMock();
$proxyMock->expects($this->any())->method('call')->willReturnCallback(function ($className, $methodName, $parameters) {
if ($className == "\\Piwik\\Plugins\\UserCountry\\API"
&& $methodName == 'getCity'
diff --git a/tests/PHPUnit/Integration/Db/TransactionLevelTest.php b/tests/PHPUnit/Integration/Db/TransactionLevelTest.php
index 3438108879..129526e058 100644
--- a/tests/PHPUnit/Integration/Db/TransactionLevelTest.php
+++ b/tests/PHPUnit/Integration/Db/TransactionLevelTest.php
@@ -30,7 +30,7 @@ class TransactionLevelTest extends IntegrationTestCase
*/
private $db;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->db = Db::get();
diff --git a/tests/PHPUnit/Integration/DbHelperTest.php b/tests/PHPUnit/Integration/DbHelperTest.php
index d9f60418f0..523f197cde 100644
--- a/tests/PHPUnit/Integration/DbHelperTest.php
+++ b/tests/PHPUnit/Integration/DbHelperTest.php
@@ -16,7 +16,7 @@ use Piwik\Version;
class DbHelperTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -93,14 +93,14 @@ class DbHelperTest extends IntegrationTestCase
{
$dbs = Db::fetchAll("SHOW DATABASES");
$dbs = array_column($dbs, 'Database');
- $this->assertContains($this->cleanName($dbName), $dbs);
+ self::assertTrue(in_array($this->cleanName($dbName), $dbs));
}
private function assertDbNotExists($dbName)
{
$dbs = Db::fetchAll("SHOW DATABASES");
$dbs = array_column($dbs, 'Database');
- $this->assertNotContains($this->cleanName($dbName), $dbs);
+ self::assertTrue(!in_array($this->cleanName($dbName), $dbs));
}
private function cleanName($dbName)
diff --git a/tests/PHPUnit/Integration/DbTest.php b/tests/PHPUnit/Integration/DbTest.php
index c88b207810..f4632e01fc 100644
--- a/tests/PHPUnit/Integration/DbTest.php
+++ b/tests/PHPUnit/Integration/DbTest.php
@@ -20,14 +20,14 @@ class DbTest extends IntegrationTestCase
{
private $dbReaderConfigBackup;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->dbReaderConfigBackup = Config::getInstance()->database_reader;
}
- public function tearDown()
+ public function tearDown(): void
{
Db::destroyDatabaseObject();
Config::getInstance()->database_reader = $this->dbReaderConfigBackup;
@@ -130,12 +130,11 @@ class DbTest extends IntegrationTestCase
$this->assertSame($expected, $result);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessagelock name has to be 64 characters or less
- */
public function test_getDbLock_shouldThrowAnException_IfDbLockNameIsTooLong()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('name has to be 64 characters or less');
+
Db::getDbLock(str_pad('test', 65, '1'));
}
diff --git a/tests/PHPUnit/Integration/DependencyTest.php b/tests/PHPUnit/Integration/DependencyTest.php
index 862f4d8196..221a4a1de0 100644
--- a/tests/PHPUnit/Integration/DependencyTest.php
+++ b/tests/PHPUnit/Integration/DependencyTest.php
@@ -23,7 +23,7 @@ class DependencyTest extends IntegrationTestCase
*/
private $dependency;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->dependency = new Dependency();
diff --git a/tests/PHPUnit/Integration/DocumentationGeneratorTest.php b/tests/PHPUnit/Integration/DocumentationGeneratorTest.php
index 09236e4024..f41889eaef 100644
--- a/tests/PHPUnit/Integration/DocumentationGeneratorTest.php
+++ b/tests/PHPUnit/Integration/DocumentationGeneratorTest.php
@@ -23,7 +23,7 @@ class DocumentationGeneratorTest extends TestCase
$annotation = '@hideExceptForSuperUser test test';
$mock = $this->getMockBuilder('ReflectionClass')
->disableOriginalConstructor()
- ->setMethods(array('getDocComment'))
+ ->onlyMethods(array('getDocComment'))
->getMock();
$mock->expects($this->once())->method('getDocComment')->willReturn($annotation);
$documentationGenerator = new DocumentationGenerator();
diff --git a/tests/PHPUnit/Integration/HttpTest.php b/tests/PHPUnit/Integration/HttpTest.php
index 171fe2c7e3..11f90249e4 100644
--- a/tests/PHPUnit/Integration/HttpTest.php
+++ b/tests/PHPUnit/Integration/HttpTest.php
@@ -270,21 +270,21 @@ class HttpTest extends \PHPUnit\Framework\TestCase
* curl_exec: server certificate verification failed. CAfile: /home/travis/build/piwik/piwik/core/DataFiles/cacert.pem CRLfile: none. Hostname requested was: self-signed.badssl.com
* or
* curl_exec: SSL certificate problem: self signed certificate. Hostname requested was: self-signed.badssl.com
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp /curl_exec: .*certificate.* /
*/
public function testCurlHttpsFailsWithInvalidCertificate()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/curl_exec: .*certificate.* /');
+
// use a domain from https://badssl.com/
Http::sendHttpRequestBy('curl', 'https://self-signed.badssl.com/', 10);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage failed to open stream
- */
public function testFopenHttpsFailsWithInvalidCertificate()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('failed to open stream');
+
// use a domain from https://badssl.com/
Http::sendHttpRequestBy('fopen', 'https://self-signed.badssl.com/', 10);
}
diff --git a/tests/PHPUnit/Integration/JsProxyTest.php b/tests/PHPUnit/Integration/JsProxyTest.php
index 65e8e56570..2c9830d71c 100644
--- a/tests/PHPUnit/Integration/JsProxyTest.php
+++ b/tests/PHPUnit/Integration/JsProxyTest.php
@@ -16,7 +16,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class JsProxyTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::createWebsite('2014-01-01 02:03:04');
diff --git a/tests/PHPUnit/Integration/LogDeleterTest.php b/tests/PHPUnit/Integration/LogDeleterTest.php
index bfb8df5b23..310da942a1 100644
--- a/tests/PHPUnit/Integration/LogDeleterTest.php
+++ b/tests/PHPUnit/Integration/LogDeleterTest.php
@@ -31,7 +31,7 @@ class LogDeleterTest extends IntegrationTestCase
*/
private $logDeleter;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Measurable/MeasurableSettingTest.php b/tests/PHPUnit/Integration/Measurable/MeasurableSettingTest.php
index 639f2153ce..bfc49e8cdd 100644
--- a/tests/PHPUnit/Integration/Measurable/MeasurableSettingTest.php
+++ b/tests/PHPUnit/Integration/Measurable/MeasurableSettingTest.php
@@ -20,7 +20,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class MeasurableSettingTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:01');
@@ -42,23 +42,21 @@ class MeasurableSettingTest extends IntegrationTestCase
$this->assertSame('test', $value);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function testSetValue_shouldThrowException_IfOnlyViewPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
FakeAccess::clearAccess();
FakeAccess::setIdSitesView(array(1, 2, 3));
$this->createSetting()->setValue('test');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function testSetValue_shouldThrowException_IfNoPermissionAtAll()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
FakeAccess::clearAccess();
$this->createSetting()->setValue('test');
}
diff --git a/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php b/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php
index d130dd9eed..599b5e0355 100644
--- a/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php
+++ b/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php
@@ -29,7 +29,7 @@ class MeasurableSettingsTest extends IntegrationTestCase
*/
private $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -56,12 +56,11 @@ class MeasurableSettingsTest extends IntegrationTestCase
$this->assertStoredSettingsValue(array('value3'), 'sitesearch_category_parameters');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_save_shouldCheckAdminPermissionsForThatSite()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
FakeAccess::clearAccess();
$this->settings = $this->createSettings();
diff --git a/tests/PHPUnit/Integration/NumberFormatterTest.php b/tests/PHPUnit/Integration/NumberFormatterTest.php
index 542cfb83a5..44e5cf3158 100644
--- a/tests/PHPUnit/Integration/NumberFormatterTest.php
+++ b/tests/PHPUnit/Integration/NumberFormatterTest.php
@@ -23,14 +23,14 @@ class NumberFormatterTest extends \PHPUnit\Framework\TestCase
*/
private $translator;
- public function setUp()
+ public function setUp(): void
{
\Piwik\Plugin\Manager::getInstance()->loadPluginTranslations();
$this->translator = StaticContainer::get('Piwik\Translation\Translator');
}
- public function tearDown()
+ public function tearDown(): void
{
$this->translator->reset();
}
diff --git a/tests/PHPUnit/Integration/Period/FactoryTest.php b/tests/PHPUnit/Integration/Period/FactoryTest.php
index 470cacccd1..c83b231c82 100644
--- a/tests/PHPUnit/Integration/Period/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Period/FactoryTest.php
@@ -100,21 +100,19 @@ class FactoryTest extends IntegrationTestCase
$this->assertInstanceOf(TestPeriod::class, $period);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionInvalidPeriod
- */
public function test_build_ThrowsIfPeriodIsUnrecognized()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidPeriod');
+
Period\Factory::build('garbageperiod', '2015-01-01');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionInvalidPeriod
- */
public function test_build_ThrowsIfPeriodIsNotEnabledForApi()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidPeriod');
+
Config::getInstance()->General['enabled_periods_API'] = 'day';
Period\Factory::build('week', '2015-01-01');
}
diff --git a/tests/PHPUnit/Integration/PiwikTest.php b/tests/PHPUnit/Integration/PiwikTest.php
index 36564c2501..875a14899d 100644
--- a/tests/PHPUnit/Integration/PiwikTest.php
+++ b/tests/PHPUnit/Integration/PiwikTest.php
@@ -103,10 +103,10 @@ class PiwikTest extends IntegrationTestCase
/**
* @dataProvider getInvalidLoginStringData
- * @expectedException \Exception
*/
public function testCheckInvalidLoginString($toTest)
{
+ $this->expectException(\Exception::class);
Piwik::checkValidLoginString($toTest);
}
@@ -242,7 +242,7 @@ class PiwikTest extends IntegrationTestCase
private function createPiwikAuthMockInstance()
{
return $this->getMockBuilder('Piwik\\Auth')
- ->setMethods(array('authenticate', 'getName', 'getTokenAuthSecret', 'getLogin', 'setTokenAuth', 'setLogin',
+ ->onlyMethods(array('authenticate', 'getName', 'getTokenAuthSecret', 'getLogin', 'setTokenAuth', 'setLogin',
'setPassword', 'setPasswordHash'))
->getMock();
}
diff --git a/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php
index 570a56bcaa..03946c9b63 100644
--- a/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php
+++ b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php
@@ -33,7 +33,7 @@ class ArchivedMetricTest extends IntegrationTestCase
*/
private $metric;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -45,7 +45,7 @@ class ArchivedMetricTest extends IntegrationTestCase
$this->metric = $this->makeMetric('%s');
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Plugin/CategoriesTest.php b/tests/PHPUnit/Integration/Plugin/CategoriesTest.php
index 1c2c92539b..981fbbb00d 100644
--- a/tests/PHPUnit/Integration/Plugin/CategoriesTest.php
+++ b/tests/PHPUnit/Integration/Plugin/CategoriesTest.php
@@ -27,7 +27,7 @@ class CategoriesTest extends IntegrationTestCase
*/
private $categories;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -39,7 +39,7 @@ class CategoriesTest extends IntegrationTestCase
$this->categories = new Categories(StaticContainer::get('Piwik\Plugin\Manager'));
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
unset($_GET['idSite']);
diff --git a/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php
index 0d79512d02..5ab1c4b338 100644
--- a/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php
+++ b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php
@@ -22,7 +22,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class ComputedMetricTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -31,7 +31,7 @@ class ComputedMetricTest extends IntegrationTestCase
Fixture::createWebsite('2015-01-01 00:00:00');
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php
index 944dbdc0ff..68c2ede8e5 100644
--- a/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php
+++ b/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php
@@ -53,7 +53,7 @@ class ActionDimensionTest extends IntegrationTestCase
*/
private $dimension;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php
index 544fba56ec..f4b40e2b28 100644
--- a/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php
+++ b/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php
@@ -53,7 +53,7 @@ class ConversionDimensionTest extends IntegrationTestCase
*/
private $dimension;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/DimensionMetadataProviderTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/DimensionMetadataProviderTest.php
index 497c7facc4..1e60b7fd77 100644
--- a/tests/PHPUnit/Integration/Plugin/Dimension/DimensionMetadataProviderTest.php
+++ b/tests/PHPUnit/Integration/Plugin/Dimension/DimensionMetadataProviderTest.php
@@ -15,7 +15,7 @@ use Piwik\Plugin\Manager as PluginManager;
class DimensionMetadataProviderTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
index 7d9b964f08..4ca8550d7d 100644
--- a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
+++ b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
@@ -74,7 +74,7 @@ class VisitDimensionTest extends IntegrationTestCase
*/
private $conversionDimension;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -212,12 +212,11 @@ class VisitDimensionTest extends IntegrationTestCase
$this->assertSame(array($dimension3, $dimension4, $dimension2, $dimension1), $instances);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Circular reference detected for required field column4 in dimension column2
- */
public function test_sortDimensions_ShouldThrowAnException_IfCircularReferenceDetected()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Circular reference detected for required field column4 in dimension column2');
+
$dimension1 = new FakeVisitDimension();
$dimension1->set('columnName', 'column1');
$dimension1->requiredFields = array('column3');
diff --git a/tests/PHPUnit/Integration/Plugin/ManagerTest.php b/tests/PHPUnit/Integration/Plugin/ManagerTest.php
index d785f0f176..d2bfd4133d 100644
--- a/tests/PHPUnit/Integration/Plugin/ManagerTest.php
+++ b/tests/PHPUnit/Integration/Plugin/ManagerTest.php
@@ -30,7 +30,7 @@ class ManagerTest extends IntegrationTestCase
*/
private $manager;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->manager = Plugin\Manager::getInstance();
diff --git a/tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php b/tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php
index 59a23fe743..54847143a6 100644
--- a/tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php
+++ b/tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php
@@ -30,7 +30,7 @@ class ReleaseChannelsTest extends IntegrationTestCase
*/
private $channels;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Plugin/SettingsProviderTest.php b/tests/PHPUnit/Integration/Plugin/SettingsProviderTest.php
index 0d620cfef1..7698d24b5d 100644
--- a/tests/PHPUnit/Integration/Plugin/SettingsProviderTest.php
+++ b/tests/PHPUnit/Integration/Plugin/SettingsProviderTest.php
@@ -37,7 +37,7 @@ class SettingsProviderTest extends IntegrationTestCase
private $examplePlugin = 'ExampleSettingsPlugin';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -50,7 +50,7 @@ class SettingsProviderTest extends IntegrationTestCase
$this->settings = new SettingsProvider($this->pluginManager);
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
unset($_GET['idSite']);
diff --git a/tests/PHPUnit/Integration/Plugin/WidgetsProviderTest.php b/tests/PHPUnit/Integration/Plugin/WidgetsProviderTest.php
index 14e18d2851..9f375fe7b1 100644
--- a/tests/PHPUnit/Integration/Plugin/WidgetsProviderTest.php
+++ b/tests/PHPUnit/Integration/Plugin/WidgetsProviderTest.php
@@ -28,7 +28,7 @@ class WidgetsProviderTest extends IntegrationTestCase
*/
private $widgets;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -40,7 +40,7 @@ class WidgetsProviderTest extends IntegrationTestCase
$this->widgets = new WidgetsProvider(StaticContainer::get('Piwik\Plugin\Manager'));
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
unset($_GET['idSite']);
diff --git a/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php b/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php
index 4d8c400c33..2c10e38d98 100644
--- a/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php
+++ b/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php
@@ -37,7 +37,7 @@ class AdvertisingTest extends \PHPUnit\Framework\TestCase
private $exampleUrl = 'https://piwik.xyz/test';
- public function setUp()
+ public function setUp(): void
{
$this->config = new FakeConfig(array('General' => array('piwik_professional_support_ads_enabled' => '1')));
$this->pluginManager = new Manager();
diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
index 22e560e3b6..690ef8e166 100644
--- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
@@ -30,7 +30,7 @@ class ReleaseCheckListTest extends \PHPUnit\Framework\TestCase
const MINIMUM_PHP_VERSION = '7.2.0';
- public function setUp()
+ public function setUp(): void
{
$iniReader = new IniReader();
$this->globalConfig = $iniReader->readFile(PIWIK_PATH_TEST_TO_ROOT . '/config/global.ini.php');
@@ -222,6 +222,7 @@ class ReleaseCheckListTest extends \PHPUnit\Framework\TestCase
PIWIK_INCLUDE_PATH . '/tests/resources/overlay-test-site-real/',
PIWIK_INCLUDE_PATH . '/tests/resources/overlay-test-site/',
PIWIK_INCLUDE_PATH . '/vendor/lox/xhprof/xhprof_html/docs/',
+ PIWIK_INCLUDE_PATH . '/vendor/phpunit/php-code-coverage/tests',
PIWIK_INCLUDE_PATH . '/plugins/Morpheus/icons/',
);
diff --git a/tests/PHPUnit/Integration/ReportRenderingTest.php b/tests/PHPUnit/Integration/ReportRenderingTest.php
index 01a0337d41..5be9b787ba 100644
--- a/tests/PHPUnit/Integration/ReportRenderingTest.php
+++ b/tests/PHPUnit/Integration/ReportRenderingTest.php
@@ -31,6 +31,6 @@ class ReportRenderingTest extends IntegrationTestCase
$frontController = FrontController::getInstance();
$response = $frontController->dispatch('DevicesDetection', 'getBrand');
- $this->assertContains('Diagnostics_NoDataForReportArchivingNotRun', $response);
+ self::assertStringContainsString('Diagnostics_NoDataForReportArchivingNotRun', $response);
}
} \ No newline at end of file
diff --git a/tests/PHPUnit/Integration/ReportTest.php b/tests/PHPUnit/Integration/ReportTest.php
index eeab859fd6..3029420eff 100644
--- a/tests/PHPUnit/Integration/ReportTest.php
+++ b/tests/PHPUnit/Integration/ReportTest.php
@@ -102,7 +102,7 @@ class ReportTest extends IntegrationTestCase
*/
private $advancedReport;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -116,7 +116,7 @@ class ReportTest extends IntegrationTestCase
$this->advancedReport = new GetAdvancedReport();
}
- public function tearDown()
+ public function tearDown(): void
{
unset($_GET['idSite']);
parent::tearDown();
@@ -142,12 +142,11 @@ class ReportTest extends IntegrationTestCase
$this->assertTrue($this->basicReport->isEnabled());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionReportNotEnabled
- */
public function test_checkIsEnabled_shouldThrowAnExceptionIfReportIsNotEnabled()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionReportNotEnabled');
+
$this->disabledReport->checkIsEnabled();
}
@@ -365,7 +364,7 @@ class ReportTest extends IntegrationTestCase
{
PluginManager::getInstance()->loadPlugins(array('API', 'ExampleReport'));
- $proxyMock = $this->getMockBuilder('stdClass')->setMethods(array('call', '__construct'))->getMock();
+ $proxyMock = $this->getMockBuilder('stdClass')->addMethods(array('call', '__construct'))->getMock();
$proxyMock->expects($this->once())->method('call')->with(
'\\Piwik\\Plugins\\ExampleReport\\API', 'getExampleReport', array(
'idSite' => 1,
@@ -389,7 +388,7 @@ class ReportTest extends IntegrationTestCase
{
PluginManager::getInstance()->loadPlugins(array('API', 'Referrers'));
- $proxyMock = $this->getMockBuilder('stdClass')->setMethods(array('call', '__construct'))->getMock();
+ $proxyMock = $this->getMockBuilder('stdClass')->addMethods(array('call', '__construct'))->getMock();
$proxyMock->expects($this->once())->method('call')->with(
'\\Piwik\\Plugins\\Referrers\\API', 'getSearchEnginesFromKeywordId', array(
'idSubtable' => 23,
diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php
index 2b0d015a38..22586fa147 100644
--- a/tests/PHPUnit/Integration/SegmentTest.php
+++ b/tests/PHPUnit/Integration/SegmentTest.php
@@ -33,7 +33,7 @@ class SegmentTest extends IntegrationTestCase
private $exampleSegment = 'visitCount>=1';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/SequenceTest.php b/tests/PHPUnit/Integration/SequenceTest.php
index 24e96fa91f..75a42f4a6c 100644
--- a/tests/PHPUnit/Integration/SequenceTest.php
+++ b/tests/PHPUnit/Integration/SequenceTest.php
@@ -42,12 +42,11 @@ class SequenceTest extends IntegrationTestCase
$this->assertSame(11, $id);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Duplicate entry
- */
public function test_create_shouldFailIfSequenceAlreadyExists()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Duplicate entry');
+
$sequence = $this->getExistingSequence();
$sequence->create();
@@ -62,12 +61,11 @@ class SequenceTest extends IntegrationTestCase
$this->assertNextIdGenerated($sequence, 3);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Sequence 'notCreatedSequence' not found
- */
public function test_getNextId_shouldFailIfThereIsNoSequenceHavingThisName()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Sequence \'notCreatedSequence\' not found');
+
$sequence = $this->getEmptySequence();
$sequence->getNextId();
}
diff --git a/tests/PHPUnit/Integration/ServeStaticFileTest.php b/tests/PHPUnit/Integration/ServeStaticFileTest.php
index 94c14aa872..062157d0b0 100644
--- a/tests/PHPUnit/Integration/ServeStaticFileTest.php
+++ b/tests/PHPUnit/Integration/ServeStaticFileTest.php
@@ -49,7 +49,7 @@ define("PARTIAL_BYTE_END", 14724);
// If the static file server has not been requested, the standard unit test case class is defined
class ServeStaticFileTest extends \PHPUnit\Framework\TestCase
{
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
if(!chmod(TEST_FILE_LOCATION, 0644)) {
@@ -159,7 +159,7 @@ class ServeStaticFileTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(200, $responseInfo["http_code"]);
// Tests content type
- $this->assertContains(TEST_FILE_CONTENT_TYPE, $responseInfo["content_type"]);
+ self::assertStringContainsString(TEST_FILE_CONTENT_TYPE, $responseInfo["content_type"]);
// Tests no compression has been applied
$this->assertNull($this->getContentEncodingValue($fullResponse));
diff --git a/tests/PHPUnit/Integration/Session/SessionAuthTest.php b/tests/PHPUnit/Integration/Session/SessionAuthTest.php
index e2579ceb08..4f4c7eccb3 100644
--- a/tests/PHPUnit/Integration/Session/SessionAuthTest.php
+++ b/tests/PHPUnit/Integration/Session/SessionAuthTest.php
@@ -29,7 +29,7 @@ class SessionAuthTest extends IntegrationTestCase
*/
private $testInstance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Settings/BaseSettingsTestCase.php b/tests/PHPUnit/Integration/Settings/BaseSettingsTestCase.php
index b51c7a54d7..d85289d0ea 100644
--- a/tests/PHPUnit/Integration/Settings/BaseSettingsTestCase.php
+++ b/tests/PHPUnit/Integration/Settings/BaseSettingsTestCase.php
@@ -41,12 +41,11 @@ class BaseSettingsTestCase extends IntegrationTestCase
$this->assertNotNull($this->settings->getSetting('myName'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage A setting with name "myName" does already exist for plugin "ExampleSettingsPlugin"
- */
public function test_makeSetting_ShouldFailWhenAdingSameSettingTwice()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('A setting with name "myName" does already exist for plugin "ExampleSettingsPlugin"');
+
$this->makeSetting('myName');
$this->makeSetting('myName');
}
@@ -136,12 +135,11 @@ class BaseSettingsTestCase extends IntegrationTestCase
$this->assertSame($setting, $settings->getSetting($settingName));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage "testSetting" does already exist
- */
public function test_addSetting_throwsException_IfSameSettingAddedTwice()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('"testSetting" does already exist');
+
$settingName = 'testSetting';
$setting = $this->buildSetting($settingName);
$settings = $this->createSettingsInstance();
diff --git a/tests/PHPUnit/Integration/Settings/IntegrationTestCase.php b/tests/PHPUnit/Integration/Settings/IntegrationTestCase.php
index b01c61397f..0a2b8fe76d 100644
--- a/tests/PHPUnit/Integration/Settings/IntegrationTestCase.php
+++ b/tests/PHPUnit/Integration/Settings/IntegrationTestCase.php
@@ -8,6 +8,7 @@
namespace Piwik\Tests\Integration\Settings;
+use PHPUnit\Framework\Constraint\IsType;
use Piwik\Db;
use Piwik\Settings\Setting;
use Piwik\Settings\Storage;
@@ -26,7 +27,7 @@ class IntegrationTestCase extends \Piwik\Tests\Framework\TestCase\IntegrationTes
*/
protected $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Db::destroyDatabaseObject();
@@ -39,7 +40,10 @@ class IntegrationTestCase extends \Piwik\Tests\Framework\TestCase\IntegrationTes
$this->assertEquals($expectedValue, $value);
if (!is_null($expectedType)) {
- $this->assertInternalType($expectedType, $value);
+ static::assertThat(
+ $value,
+ new IsType($expectedType)
+ );
}
}
diff --git a/tests/PHPUnit/Integration/Settings/Measurable/MeasurablePropertyTest.php b/tests/PHPUnit/Integration/Settings/Measurable/MeasurablePropertyTest.php
index 4d8023a989..4332de1c2e 100644
--- a/tests/PHPUnit/Integration/Settings/Measurable/MeasurablePropertyTest.php
+++ b/tests/PHPUnit/Integration/Settings/Measurable/MeasurablePropertyTest.php
@@ -25,7 +25,7 @@ use Piwik\Tests\Integration\Settings\IntegrationTestCase;
class MeasurablePropertyTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Db::destroyDatabaseObject();
@@ -49,12 +49,11 @@ class MeasurablePropertyTest extends IntegrationTestCase
$this->assertNotDbConnectionCreated();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Name "name" is not allowed to be used
- */
public function test_constructor_shouldThrowAnExceptionWhenNotWhitelistedNameIsUsed()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Name "name" is not allowed to be used');
+
new MeasurableProperty('name', $default = 5, FieldConfig::TYPE_INT, 'MyPlugin', $idSite = 1);
}
diff --git a/tests/PHPUnit/Integration/Settings/Measurable/MeasurableSettingTest.php b/tests/PHPUnit/Integration/Settings/Measurable/MeasurableSettingTest.php
index 3ce37143c6..3a6d9603f4 100644
--- a/tests/PHPUnit/Integration/Settings/Measurable/MeasurableSettingTest.php
+++ b/tests/PHPUnit/Integration/Settings/Measurable/MeasurableSettingTest.php
@@ -24,7 +24,7 @@ use Piwik\Tests\Integration\Settings\IntegrationTestCase;
class MeasurableSettingTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
foreach (array(2,3) as $idSite) {
diff --git a/tests/PHPUnit/Integration/Settings/Plugin/SystemConfigSettingTest.php b/tests/PHPUnit/Integration/Settings/Plugin/SystemConfigSettingTest.php
index 37db4918ca..4b0d2fdf29 100644
--- a/tests/PHPUnit/Integration/Settings/Plugin/SystemConfigSettingTest.php
+++ b/tests/PHPUnit/Integration/Settings/Plugin/SystemConfigSettingTest.php
@@ -24,7 +24,7 @@ class SystemConfigSettingTest extends IntegrationTestCase
{
private $section = 'MySection';
- public function tearDown()
+ public function tearDown(): void
{
$this->setConfigValues(array());
parent::tearDown();
@@ -39,24 +39,22 @@ class SystemConfigSettingTest extends IntegrationTestCase
$this->assertNotDbConnectionCreated();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingValue_shouldThrowException_IfAUserIsTryingToSetASettingWhichNeedsSuperUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setUser();
$setting = $this->buildSetting('mysystem');
$setting->setValue(2);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingValue_shouldThrowException_IfAnonymousIsTryingToSetASettingWhichNeedsSuperUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setAnonymousUser();
$setting = $this->buildSetting('mysystem');
diff --git a/tests/PHPUnit/Integration/Settings/Plugin/SystemSettingTest.php b/tests/PHPUnit/Integration/Settings/Plugin/SystemSettingTest.php
index e44d6e0fdd..f0d55e5fba 100644
--- a/tests/PHPUnit/Integration/Settings/Plugin/SystemSettingTest.php
+++ b/tests/PHPUnit/Integration/Settings/Plugin/SystemSettingTest.php
@@ -22,7 +22,7 @@ use Piwik\Tests\Integration\Settings\IntegrationTestCase;
class SystemSettingTest extends IntegrationTestCase
{
- public function tearDown()
+ public function tearDown(): void
{
Config::getInstance()->MyPluginName = array();
parent::tearDown();
@@ -37,24 +37,22 @@ class SystemSettingTest extends IntegrationTestCase
$this->assertNotDbConnectionCreated();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingValue_shouldThrowException_IfAUserIsTryingToSetASettingWhichNeedsSuperUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setUser();
$setting = $this->buildSetting('mysystem');
$setting->setValue(2);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingValue_shouldThrowException_IfAnonymousIsTryingToSetASettingWhichNeedsSuperUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setAnonymousUser();
$setting = $this->buildSetting('mysystem');
@@ -147,12 +145,11 @@ class SystemSettingTest extends IntegrationTestCase
$this->assertTrue($setting->isWritableByCurrentUser());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingsValue_shouldNotBePossible_AsSoonAsAConfigValueIsConfigured()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setSuperUser();
$setting = $this->buildSetting('myusersetting');
diff --git a/tests/PHPUnit/Integration/Settings/Plugin/UserSettingTest.php b/tests/PHPUnit/Integration/Settings/Plugin/UserSettingTest.php
index a0478b6229..fa435b34c4 100644
--- a/tests/PHPUnit/Integration/Settings/Plugin/UserSettingTest.php
+++ b/tests/PHPUnit/Integration/Settings/Plugin/UserSettingTest.php
@@ -68,12 +68,11 @@ class UserSettingTest extends IntegrationTestCase
$this->assertDbConnectionCreated();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
- */
public function test_setSettingValue_shouldThrowException_IfAnonymousIsTryingToSetASettingWhichNeedsUserPermission()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingChangeNotAllowed');
+
$this->setAnonymousUser();
$setting = $this->buildSetting('mysystem');
@@ -141,12 +140,11 @@ class UserSettingTest extends IntegrationTestCase
$this->assertSettingHasValue($setting, 43939, 'integer');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Validation Fail
- */
public function test_setSettingValue_shouldValidateAValue_IfAFilterIsSet()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Validation Fail');
+
$this->setUser();
$self = $this;
diff --git a/tests/PHPUnit/Integration/Settings/SettingTest.php b/tests/PHPUnit/Integration/Settings/SettingTest.php
index 83975cd841..8cbdf76c3d 100644
--- a/tests/PHPUnit/Integration/Settings/SettingTest.php
+++ b/tests/PHPUnit/Integration/Settings/SettingTest.php
@@ -25,25 +25,24 @@ use Piwik\Validators\NumberRange;
*/
class SettingTest extends \PHPUnit\Framework\TestCase
{
- protected function setUp()
+ public function setUp(): void
{
$fixutre = new Fixture();
$fixutre->createEnvironmentInstance();
}
- protected function tearDown()
+ public function tearDown(): void
{
$fixutre = new Fixture();
$fixutre->clearInMemoryCaches();
$fixutre->destroyEnvironment();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage setting name "myname-" in plugin "MyPluginName" is invalid
- */
public function test_constructor_shouldThrowException_IfTheSettingNameIsNotValid()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('setting name "myname-" in plugin "MyPluginName" is invalid');
+
$this->makeSetting('myname-');
}
@@ -58,24 +57,22 @@ class SettingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(FieldConfig::UI_CONTROL_CHECKBOX, $field->uiControl);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Type must be an array when using a multi select
- */
public function test_configureField_ShouldCheckThatTypeMakesActuallySenseForConfiguredUiControl()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Type must be an array when using a multi select');
+
$setting = $this->makeSetting('myname', FieldConfig::TYPE_STRING, $default = '', function (FieldConfig $field) {
$field->uiControl = FieldConfig::UI_CONTROL_MULTI_SELECT;
});
$setting->configureField();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Type does not exist
- */
public function test_configureField_ChecksTheGivenTypeIsKnown()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Type does not exist');
+
$setting = $this->makeSetting('myname', 'unknOwnTyPe');
$setting->configureField();
}
@@ -93,19 +90,18 @@ class SettingTest extends \PHPUnit\Framework\TestCase
try {
$setting->setValue('invAliDValue');
} catch (Exception $e) {
- $this->assertContains('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
+ self::assertStringContainsString('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
return;
}
$this->fail('An expected exception has not been thrown');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage CoreAdminHome_PluginSettingsValueNotAllowed
- */
public function test_setValue_shouldApplyValidationAndFail_IfOptionsAreSetAndValueIsAnArray()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('CoreAdminHome_PluginSettingsValueNotAllowed');
+
$setting = $this->makeSetting('myname', FieldConfig::TYPE_ARRAY, $default = '', function (FieldConfig $field) {
$field->availableValues = array('allowedval' => 'DisplayName', 'allowedval2' => 'Name 2');
$field->uiControl = FieldConfig::UI_CONTROL_MULTI_SELECT;
@@ -146,7 +142,7 @@ class SettingTest extends \PHPUnit\Framework\TestCase
try {
$setting->setValue('invAliDValue');
} catch (Exception $e) {
- $this->assertContains('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
+ self::assertStringContainsString('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
return;
}
@@ -170,7 +166,7 @@ class SettingTest extends \PHPUnit\Framework\TestCase
try {
$setting->setValue('1invalid');
} catch (Exception $e) {
- $this->assertContains('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
+ self::assertStringContainsString('CoreAdminHome_PluginSettingsValueNotAllowed', $e->getMessage());
return;
}
@@ -192,21 +188,21 @@ class SettingTest extends \PHPUnit\Framework\TestCase
$setting->setValue('1invalid');
$this->fail('An expected exception has not been thrown');
} catch (Exception $e) {
- $this->assertContains('General_ValidatorErrorNotANumber', $e->getMessage());
+ self::assertStringContainsString('General_ValidatorErrorNotANumber', $e->getMessage());
}
try {
$setting->setValue('3');
$this->fail('An expected exception has not been thrown');
} catch (Exception $e) {
- $this->assertContains('General_ValidatorErrorNumberTooLow', $e->getMessage());
+ self::assertStringContainsString('General_ValidatorErrorNumberTooLow', $e->getMessage());
}
try {
$setting->setValue('');
$this->fail('An expected exception has not been thrown');
} catch (Exception $e) {
- $this->assertContains('General_ValidatorErrorEmptyValue', $e->getMessage());
+ self::assertStringContainsString('General_ValidatorErrorEmptyValue', $e->getMessage());
}
}
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/CacheTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/CacheTest.php
index 577cdb0d61..f8c8bc06e4 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/CacheTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/CacheTest.php
@@ -30,7 +30,7 @@ class CacheTest extends IntegrationTestCase
*/
private $cacheBackend;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/ConfigTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/ConfigTest.php
index 21e375325f..ce75cd8e59 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/ConfigTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/ConfigTest.php
@@ -41,7 +41,7 @@ class ConfigTest extends IntegrationTestCase
*/
private $allBackends = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -56,12 +56,11 @@ class ConfigTest extends IntegrationTestCase
return new Config($plugin);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No section given
- */
public function test_construct_shouldThrowAnException_IfSectionIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No section given');
+
$this->createSettings('');
}
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/MeasurableSettingsTableTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/MeasurableSettingsTableTest.php
index f9572eb153..6b636cd687 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/MeasurableSettingsTableTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/MeasurableSettingsTableTest.php
@@ -41,7 +41,7 @@ class MeasurableSettingsTableTest extends IntegrationTestCase
*/
private $allBackends = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -56,21 +56,19 @@ class MeasurableSettingsTableTest extends IntegrationTestCase
return new MeasurableSettingsTable($idSite, $plugin);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin name given
- */
public function test_construct_shouldThrowAnException_IfPluginNameIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin name given');
+
$this->createSettings(1, '');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No idSite given
- */
public function test_construct_shouldThrowAnException_IfIdSiteIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No idSite given');
+
$this->createSettings(0, 'MyPlugin');
}
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/NullTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/NullTest.php
index 91929e43b0..362b0c43d6 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/NullTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/NullTest.php
@@ -23,7 +23,7 @@ class NullTest extends \PHPUnit\Framework\TestCase
*/
private $backend;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/PluginSettingsTableTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/PluginSettingsTableTest.php
index ec1c0b229a..1c57d27041 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/PluginSettingsTableTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/PluginSettingsTableTest.php
@@ -46,7 +46,7 @@ class PluginSettingsTableTest extends IntegrationTestCase
*/
private $allBackends = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -62,30 +62,27 @@ class PluginSettingsTableTest extends IntegrationTestCase
return new PluginSettingsTable($plugin, $login);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin name given
- */
public function test_construct_shouldThrowAnException_IfPluginNameIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin name given');
+
$this->createSettings('', '');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid user login name
- */
public function test_construct_shouldThrowAnException_IfUserLoginFalse()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid user login name');
+
$this->createSettings('MyPlugin', false);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid user login name
- */
public function test_construct_shouldThrowAnException_IfUserLoginNull()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid user login name');
+
$this->createSettings('MyPlugin', null);
}
@@ -263,12 +260,11 @@ class PluginSettingsTableTest extends IntegrationTestCase
}
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No userLogin specified
- */
public function test_removeAllUserSettingsForUser_shouldThrowAnExceptionIfLoginIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No userLogin specified');
+
PluginSettingsTable::removeAllUserSettingsForUser('');
}
diff --git a/tests/PHPUnit/Integration/Settings/Storage/Backend/SitesTableTest.php b/tests/PHPUnit/Integration/Settings/Storage/Backend/SitesTableTest.php
index 32d3a2c903..aa54f175cb 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/Backend/SitesTableTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/Backend/SitesTableTest.php
@@ -32,7 +32,7 @@ class SitesTableTest extends IntegrationTestCase
*/
private $backendSite2;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -48,12 +48,11 @@ class SitesTableTest extends IntegrationTestCase
return new SitesTable($idSite);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No idSite given
- */
public function test_construct_shouldThrowAnException_IfPluginNameIsEmpty()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No idSite given');
+
$this->createSettings(0);
}
@@ -63,11 +62,10 @@ class SitesTableTest extends IntegrationTestCase
$this->assertFieldsLoaded(array('idsite' => '2'), $this->backendSite2);
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- */
public function test_load_shouldThrowException_IfSiteDoesNotExist()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+
$this->createSettings($idSite = 999)->load();
}
diff --git a/tests/PHPUnit/Integration/Settings/Storage/FactoryTest.php b/tests/PHPUnit/Integration/Settings/Storage/FactoryTest.php
index ddfdd2da4d..1e573e88ef 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/FactoryTest.php
@@ -33,7 +33,7 @@ class FactoryTest extends IntegrationTestCase
*/
private $factory;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->factory = new Factory();
diff --git a/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php b/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php
index 9e9089438f..5f3e43a32e 100644
--- a/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php
+++ b/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php
@@ -36,7 +36,7 @@ class StorageTest extends IntegrationTestCase
*/
protected $settingName = 'myname';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/SiteTest.php b/tests/PHPUnit/Integration/SiteTest.php
index 1a8b1a3324..1d7a1e4ff6 100644
--- a/tests/PHPUnit/Integration/SiteTest.php
+++ b/tests/PHPUnit/Integration/SiteTest.php
@@ -22,7 +22,7 @@ class SiteTest extends IntegrationTestCase
public $siteAppendix = ' foo';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -39,12 +39,11 @@ class SiteTest extends IntegrationTestCase
});
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage An unexpected website was found in the request
- */
public function test_constructor_throwsException_ifSiteDoesNotExist()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+ $this->expectExceptionMessage('An unexpected website was found in the request');
+
$this->makeSite(9999);
}
diff --git a/tests/PHPUnit/Integration/SqlTest.php b/tests/PHPUnit/Integration/SqlTest.php
index ccafa9e6ee..df8301074d 100644
--- a/tests/PHPUnit/Integration/SqlTest.php
+++ b/tests/PHPUnit/Integration/SqlTest.php
@@ -16,7 +16,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class SqlTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -29,7 +29,7 @@ class SqlTest extends IntegrationTestCase
Db::exec("CREATE TABLE table4 (d INT) ENGINE=InnoDB");
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
}
diff --git a/tests/PHPUnit/Integration/Tracker/ActionTest.php b/tests/PHPUnit/Integration/Tracker/ActionTest.php
index ee071b2467..adc3f0efff 100644
--- a/tests/PHPUnit/Integration/Tracker/ActionTest.php
+++ b/tests/PHPUnit/Integration/Tracker/ActionTest.php
@@ -24,7 +24,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class ActionTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -40,7 +40,7 @@ class ActionTest extends IntegrationTestCase
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Tracker/DbTest.php b/tests/PHPUnit/Integration/Tracker/DbTest.php
index 4d94d34f9c..f340725343 100644
--- a/tests/PHPUnit/Integration/Tracker/DbTest.php
+++ b/tests/PHPUnit/Integration/Tracker/DbTest.php
@@ -22,7 +22,7 @@ use Piwik\Tracker;
class DbTest extends IntegrationTestCase
{
private $tableName;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->tableName = Common::prefixTable('option');
@@ -60,24 +60,22 @@ class DbTest extends IntegrationTestCase
$this->assertSame(1, $db->rowCount($result));
}
- /**
- * @expectedExceptionMessage doesn't exist
- * @expectedException \Piwik\Tracker\Db\DbException
- */
public function test_fetchOne_notExistingTable()
{
+ $this->expectException(\Piwik\Tracker\Db\DbException::class);
+ $this->expectExceptionMessage('doesn\'t exist');
+
$db = Tracker::getDatabase();
$this->insertRowId(3);
$val = $db->fetchOne('SELECT option_value FROM foobarbaz where option_value = "rowid"');
$this->assertEquals('3', $val);
}
- /**
- * @expectedExceptionMessage Duplicate entry
- * @expectedException \Piwik\Tracker\Db\DbException
- */
public function test_query_error_whenInsertingDuplicateRow()
{
+ $this->expectException(\Piwik\Tracker\Db\DbException::class);
+ $this->expectExceptionMessage('Duplicate entry');
+
$this->insertRowId();
$this->insertRowId();
}
diff --git a/tests/PHPUnit/Integration/Tracker/FailuresTest.php b/tests/PHPUnit/Integration/Tracker/FailuresTest.php
index 308dfc18ab..748cdba93c 100644
--- a/tests/PHPUnit/Integration/Tracker/FailuresTest.php
+++ b/tests/PHPUnit/Integration/Tracker/FailuresTest.php
@@ -30,7 +30,7 @@ class FailuresTest extends IntegrationTestCase
*/
private $now;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php b/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php
index 9ffecb9a30..f500c3e244 100644
--- a/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php
@@ -53,12 +53,11 @@ class FactoryTest extends IntegrationTestCase
$this->assertSame($handlerToUse, $handler);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The Handler object set in the plugin
- */
public function test_make_shouldTriggerExceptionInCaseWrongInstanceCreatedInHandler()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The Handler object set in the plugin');
+
Piwik::addAction('Tracker.newHandler', function (&$handler) {
$handler = new Tracker();
});
diff --git a/tests/PHPUnit/Integration/Tracker/HandlerTest.php b/tests/PHPUnit/Integration/Tracker/HandlerTest.php
index cab53e29a0..63bd684c60 100644
--- a/tests/PHPUnit/Integration/Tracker/HandlerTest.php
+++ b/tests/PHPUnit/Integration/Tracker/HandlerTest.php
@@ -46,7 +46,7 @@ class HandlerTest extends IntegrationTestCase
*/
private $requestSet;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Tracker/ModelTest.php b/tests/PHPUnit/Integration/Tracker/ModelTest.php
index 6562b28a5c..4d8f940b90 100644
--- a/tests/PHPUnit/Integration/Tracker/ModelTest.php
+++ b/tests/PHPUnit/Integration/Tracker/ModelTest.php
@@ -30,7 +30,7 @@ class ModelTest extends IntegrationTestCase
*/
private $model;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Tracker/PingRequestTest.php b/tests/PHPUnit/Integration/Tracker/PingRequestTest.php
index 353e9c7d26..7b2d149754 100644
--- a/tests/PHPUnit/Integration/Tracker/PingRequestTest.php
+++ b/tests/PHPUnit/Integration/Tracker/PingRequestTest.php
@@ -26,7 +26,7 @@ class PingRequestTest extends IntegrationTestCase
const CHANGED_COUNTRY = 'jp';
const CHANGED_REGION = '22';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Tracker/RequestSetTest.php b/tests/PHPUnit/Integration/Tracker/RequestSetTest.php
index c9ed7a524c..c07dcffd6d 100644
--- a/tests/PHPUnit/Integration/Tracker/RequestSetTest.php
+++ b/tests/PHPUnit/Integration/Tracker/RequestSetTest.php
@@ -40,7 +40,7 @@ class RequestSetTest extends IntegrationTestCase
private $post;
private $time;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -63,7 +63,7 @@ class RequestSetTest extends IntegrationTestCase
$_POST = array();
}
- public function tearDown()
+ public function tearDown(): void
{
$_GET = $this->get;
$_POST = $this->post;
diff --git a/tests/PHPUnit/Integration/Tracker/RequestTest.php b/tests/PHPUnit/Integration/Tracker/RequestTest.php
index aea944fa15..2de6b0e92f 100644
--- a/tests/PHPUnit/Integration/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Integration/Tracker/RequestTest.php
@@ -34,7 +34,7 @@ class RequestTest extends IntegrationTestCase
private $time;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -50,12 +50,11 @@ class RequestTest extends IntegrationTestCase
$this->time = 1416795617;
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Custom timestamp is 86500 seconds old
- */
public function test_cdt_ShouldNotTrackTheRequest_IfNotAuthenticatedAndTimestampIsNotRecent()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Custom timestamp is 86500 seconds old');
+
$request = $this->buildRequest(array('cdt' => '' . $this->time - 86500));
$request->setCurrentTimestamp($this->time);
$this->assertSame($this->time, $request->getCurrentTimestamp());
@@ -99,22 +98,20 @@ class RequestTest extends IntegrationTestCase
$this->assertSame(14, $request->getIdSite());
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage Invalid idSite: '0'
- */
public function test_getIdSite_shouldNotThrowException_IfValueIsZero()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+ $this->expectExceptionMessage('Invalid idSite: \'0\'');
+
$request = $this->buildRequest(array('idsite' => '0'));
$request->getIdSite();
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage Invalid idSite: '-1'
- */
public function test_getIdSite_shouldThrowException_IfValueIsLowerThanZero()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+ $this->expectExceptionMessage('Invalid idSite: \'-1\'');
+
$request = $this->buildRequest(array('idsite' => '-1'));
$request->getIdSite();
}
@@ -472,12 +469,11 @@ class RequestTest extends IntegrationTestCase
);
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage An unexpected website was found in the request: website id was set to '155'
- */
public function test_getIdSite_shouldTriggerExceptionWhenSiteNotExists()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+ $this->expectExceptionMessage('An unexpected website was found in the request: website id was set to \'155\'');
+
$self = $this;
Piwik::addAction('Tracker.Request.getIdSite', function (&$idSite, $params) use ($self) {
$self->assertSame(14, $idSite);
diff --git a/tests/PHPUnit/Integration/Tracker/SettingsTest.php b/tests/PHPUnit/Integration/Tracker/SettingsTest.php
index 14e32113bb..4689d8d274 100644
--- a/tests/PHPUnit/Integration/Tracker/SettingsTest.php
+++ b/tests/PHPUnit/Integration/Tracker/SettingsTest.php
@@ -26,7 +26,7 @@ class SettingsTest extends IntegrationTestCase
*/
protected $ip = '123.30.30.30';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php b/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php
index b4c76fe9c1..fc5e210882 100644
--- a/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php
@@ -54,12 +54,11 @@ class FactoryTest extends IntegrationTestCase
$this->assertSame($visitToUse, $visit);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The Visit object set in the plugin
- */
public function test_make_shouldTriggerExceptionInCaseWrongInstanceCreatedInHandler()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The Visit object set in the plugin');
+
Piwik::addAction('Tracker.makeNewVisitObject', function (&$visit) {
$visit = new Tracker();
});
diff --git a/tests/PHPUnit/Integration/Tracker/Visit/ReferrerSpamFilterTest.php b/tests/PHPUnit/Integration/Tracker/Visit/ReferrerSpamFilterTest.php
index f7b256d7c5..f6570b9300 100644
--- a/tests/PHPUnit/Integration/Tracker/Visit/ReferrerSpamFilterTest.php
+++ b/tests/PHPUnit/Integration/Tracker/Visit/ReferrerSpamFilterTest.php
@@ -25,7 +25,7 @@ class ReferrerSpamFilterTest extends IntegrationTestCase
*/
private $filter;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -33,7 +33,7 @@ class ReferrerSpamFilterTest extends IntegrationTestCase
$this->filter = new ReferrerSpamFilter;
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/PHPUnit/Integration/Tracker/Visit2Test.php b/tests/PHPUnit/Integration/Tracker/Visit2Test.php
index a1606f668a..67ffd18b2a 100644
--- a/tests/PHPUnit/Integration/Tracker/Visit2Test.php
+++ b/tests/PHPUnit/Integration/Tracker/Visit2Test.php
@@ -141,7 +141,7 @@ class FakeTrackerVisit extends Visit
*/
class Visit2Test extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
diff --git a/tests/PHPUnit/Integration/Tracker/VisitTest.php b/tests/PHPUnit/Integration/Tracker/VisitTest.php
index 7d0cb60440..eb702586c5 100644
--- a/tests/PHPUnit/Integration/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Integration/Tracker/VisitTest.php
@@ -27,7 +27,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class VisitTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/TrackerTest.php b/tests/PHPUnit/Integration/TrackerTest.php
index cd0778a253..db7a644bbb 100644
--- a/tests/PHPUnit/Integration/TrackerTest.php
+++ b/tests/PHPUnit/Integration/TrackerTest.php
@@ -40,7 +40,7 @@ class TrackerTest extends IntegrationTestCase
private $iniTimeZone;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -52,7 +52,7 @@ class TrackerTest extends IntegrationTestCase
$this->iniTimeZone = ini_get('date.timezone');
}
- public function tearDown()
+ public function tearDown(): void
{
$this->restoreConfigFile();
diff --git a/tests/PHPUnit/Integration/Updater/Migration/Db/FactoryTest.php b/tests/PHPUnit/Integration/Updater/Migration/Db/FactoryTest.php
index 40afc8b5a4..7e26c33c45 100644
--- a/tests/PHPUnit/Integration/Updater/Migration/Db/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Updater/Migration/Db/FactoryTest.php
@@ -43,7 +43,7 @@ class FactoryTest extends IntegrationTestCase
private $testTable = 'tablename';
private $testTablePrefixed = '';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Updater/Migration/Db/MigrationsTest.php b/tests/PHPUnit/Integration/Updater/Migration/Db/MigrationsTest.php
index 73d0716a7f..496a01df20 100644
--- a/tests/PHPUnit/Integration/Updater/Migration/Db/MigrationsTest.php
+++ b/tests/PHPUnit/Integration/Updater/Migration/Db/MigrationsTest.php
@@ -32,14 +32,14 @@ class MigrationsTest extends IntegrationTestCase
private $testTable = 'tablename';
private $testTablePrefixed = '';
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::dropTestTableIfNeeded();
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
self::dropTestTableIfNeeded();
@@ -52,7 +52,7 @@ class MigrationsTest extends IntegrationTestCase
Db::exec("DROP TABLE IF EXISTS `$table`");
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -156,6 +156,7 @@ class MigrationsTest extends IntegrationTestCase
public function test_changeColumnType()
{
$this->factory->changeColumnType($this->testTable, 'column2', 'SMALLINT(4) NOT NULL')->exec();
+ $this->assertTrue(true);
}
/**
diff --git a/tests/PHPUnit/Integration/Updater/Migration/FactoryTest.php b/tests/PHPUnit/Integration/Updater/Migration/FactoryTest.php
index 3cbde51fd3..88a780a5bf 100644
--- a/tests/PHPUnit/Integration/Updater/Migration/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Updater/Migration/FactoryTest.php
@@ -25,7 +25,7 @@ class FactoryTest extends IntegrationTestCase
*/
private $factory;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php b/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php
index f0da8fd54b..dc278750d5 100644
--- a/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php
@@ -26,7 +26,7 @@ class FactoryTest extends IntegrationTestCase
private $pluginName = 'MyTestPluginName';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Integration/Validator/IdSiteTest.php b/tests/PHPUnit/Integration/Validator/IdSiteTest.php
index 3fa670a1e2..5128be372d 100644
--- a/tests/PHPUnit/Integration/Validator/IdSiteTest.php
+++ b/tests/PHPUnit/Integration/Validator/IdSiteTest.php
@@ -18,7 +18,7 @@ use Piwik\Validators\IdSite;
*/
class IdSiteTest extends IntegrationTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::createWebsite('2012-03-04 05:06:07');
@@ -34,27 +34,24 @@ class IdSiteTest extends IntegrationTestCase
$this->validate(2);
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- */
public function test_validate_failValueDoesNotExist()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+
$this->validate(99);
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- */
public function test_validate_failValueIsEmpty()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+
$this->validate(0);
}
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- */
public function test_validate_failValueIsFalse()
{
+ $this->expectException(\Piwik\Exception\UnexpectedWebsiteFoundException::class);
+
$this->validate(false);
}
diff --git a/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php b/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
index eb88564d1f..0492edd19e 100644
--- a/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
+++ b/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
@@ -41,12 +41,11 @@ class ManagerTest extends IntegrationTestCase
$this->assertEquals($params['params'], $storedParams);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Setting parameters translations is not allowed. Please report this bug to the Matomo team.
- */
public function test_setViewDataTableParameters_inConfigProperty_shouldOnlyAllowOverridableParams()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Setting parameters translations is not allowed. Please report this bug to the Matomo team.');
+
$login = 'mylogin';
$method = 'API.get';
$params = array(
@@ -58,12 +57,11 @@ class ManagerTest extends IntegrationTestCase
ViewDataTableManager::saveViewDataTableParameters($login, $method, $params);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Setting parameters filters is not allowed. Please report this bug to the Matomo team.
- */
public function test_setViewDataTableParameters_inConfigProperty_shouldOnlyAllowOverridableParams_bis()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Setting parameters filters is not allowed. Please report this bug to the Matomo team.');
+
$login = 'mylogin';
$method = 'API.get';
$params = array(
@@ -75,12 +73,11 @@ class ManagerTest extends IntegrationTestCase
ViewDataTableManager::saveViewDataTableParameters($login, $method, $params);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Setting parameters apiMethodToRequestDataTable is not allowed. Please report this bug to the Matomo team.
- */
public function test_setViewDataTableParameters_inRequestConfigProperty_shouldOnlyAllowOverridableParams()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Setting parameters apiMethodToRequestDataTable is not allowed. Please report this bug to the Matomo team.');
+
$login = 'mylogin';
$method = 'API.get';
$params = array(
diff --git a/tests/PHPUnit/System/AllWebsitesTest.php b/tests/PHPUnit/System/AllWebsitesTest.php
index 3f2e07b8dd..eaa6f08e16 100644
--- a/tests/PHPUnit/System/AllWebsitesTest.php
+++ b/tests/PHPUnit/System/AllWebsitesTest.php
@@ -21,7 +21,7 @@ class AllWebsitesTest extends SystemTestCase
public static $fixture = null; // initialized below class definition
protected static $userTokenAuth = '34bcc4d2c330259d6f37bc3d98d425f4';
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/ApiGetReportMetadataTest.php b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
index a33f3a6663..aa49071c5e 100644
--- a/tests/PHPUnit/System/ApiGetReportMetadataTest.php
+++ b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
@@ -24,7 +24,7 @@ class ApiGetReportMetadataTest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -34,7 +34,7 @@ class ApiGetReportMetadataTest extends SystemTestCase
Proxy::getInstance()->setHideIgnoredFunctions(false);
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
index eb29b65d33..1e8604eab0 100644
--- a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
+++ b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
@@ -26,7 +26,7 @@ class BackwardsCompatibility1XTest extends SystemTestCase
public static $fixture = null; // initialized below class
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/BlobReportLimitingTest.php b/tests/PHPUnit/System/BlobReportLimitingTest.php
index c2231e327e..7b7e7a78a1 100644
--- a/tests/PHPUnit/System/BlobReportLimitingTest.php
+++ b/tests/PHPUnit/System/BlobReportLimitingTest.php
@@ -29,7 +29,7 @@ class BlobReportLimitingTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
Cache::getTransientCache()->flushAll();
parent::setUp();
diff --git a/tests/PHPUnit/System/CliMultiTest.php b/tests/PHPUnit/System/CliMultiTest.php
index 48563627cf..04a6ba654f 100644
--- a/tests/PHPUnit/System/CliMultiTest.php
+++ b/tests/PHPUnit/System/CliMultiTest.php
@@ -39,7 +39,7 @@ class CliMultiTest extends SystemTestCase
*/
private $responses = array();
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -66,12 +66,9 @@ class CliMultiTest extends SystemTestCase
$this->assertEquals(array(), $response);
}
- /**
- * @expectedException PHPUnit_Framework_Error
- */
public function test_request_shouldFail_IfUrlsIsNotAnArray()
{
- $this->setExpectedException('TypeError');
+ $this->expectException('TypeError');
$this->cliMulti->request('');
}
@@ -145,7 +142,7 @@ class CliMultiTest extends SystemTestCase
{
$this->cliMulti->runAsSuperUser();
$response = $this->cliMulti->request(array($this->completeUrl('')));
- $this->assertContains('Error: no website was found', $response[0]);
+ self::assertStringContainsString('Error: no website was found', $response[0]);
}
public function test_request_shouldBeAbleToRenderARegularPageInPiwik()
diff --git a/tests/PHPUnit/System/ConsoleTest.php b/tests/PHPUnit/System/ConsoleTest.php
index 9221fa8530..c0a0cfa750 100644
--- a/tests/PHPUnit/System/ConsoleTest.php
+++ b/tests/PHPUnit/System/ConsoleTest.php
@@ -107,7 +107,7 @@ class TestCommandWithException extends ConsoleCommand
class ConsoleTest extends ConsoleCommandTestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->application->addCommands([
diff --git a/tests/PHPUnit/System/CookieTest.php b/tests/PHPUnit/System/CookieTest.php
index 2220e37bb4..0c5d709a5b 100644
--- a/tests/PHPUnit/System/CookieTest.php
+++ b/tests/PHPUnit/System/CookieTest.php
@@ -23,14 +23,14 @@ class CookieTest extends SystemTestCase
private $originalAssumeSecureValue;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->testVars = static::$fixture->getTestEnvironment();
$this->originalAssumeSecureValue = Config::getInstance()->General['assume_secure_protocol'];
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
$this->testVars->overrideConfig('General', 'assume_secure_protocol', $this->originalAssumeSecureValue);
@@ -68,7 +68,7 @@ class CookieTest extends SystemTestCase
{
$headers = $this->setIgnoreCookie(self::USERAGENT_SAFARI);
$cookie = $this->findIgnoreCookie($headers);
- $this->assertNotContains($cookie, 'SameSite');
+ self::assertStringNotContainsString($cookie, 'SameSite');
}
private function setIgnoreCookie($userAgent)
@@ -103,6 +103,6 @@ class CookieTest extends SystemTestCase
private function assertCookieSameSiteMatches($expectedSameSite, $cookieHeader)
{
- $this->assertContains('SameSite=' . $expectedSameSite, $cookieHeader);
+ self::assertStringContainsString('SameSite=' . $expectedSameSite, $cookieHeader);
}
} \ No newline at end of file
diff --git a/tests/PHPUnit/System/CustomEventsTest.php b/tests/PHPUnit/System/CustomEventsTest.php
index 385c6d3c46..a82a77e7d6 100644
--- a/tests/PHPUnit/System/CustomEventsTest.php
+++ b/tests/PHPUnit/System/CustomEventsTest.php
@@ -44,7 +44,7 @@ class CustomEventsTest extends SystemTestCase
);
}
- protected function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
}
diff --git a/tests/PHPUnit/System/DuplicateActionsTest.php b/tests/PHPUnit/System/DuplicateActionsTest.php
index a0179ed9d2..8860d29cde 100644
--- a/tests/PHPUnit/System/DuplicateActionsTest.php
+++ b/tests/PHPUnit/System/DuplicateActionsTest.php
@@ -30,7 +30,7 @@ class DuplicateActionsTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/EnvironmentValidationTest.php b/tests/PHPUnit/System/EnvironmentValidationTest.php
index 3af600ab8d..e7b28f2740 100644
--- a/tests/PHPUnit/System/EnvironmentValidationTest.php
+++ b/tests/PHPUnit/System/EnvironmentValidationTest.php
@@ -27,7 +27,7 @@ class EnvironmentValidationTest extends SystemTestCase
);
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -57,7 +57,7 @@ class EnvironmentValidationTest extends SystemTestCase
$this->simulateAbsentConfigFile('config.ini.php');
$output = $this->triggerPiwikFrom('tracker');
- $this->assertContains('As Matomo is not installed yet, the Tracking API cannot proceed and will exit without error.', $output);
+ self::assertStringContainsString('As Matomo is not installed yet, the Tracking API cannot proceed and will exit without error.', $output);
}
public function test_NoLocalConfigFile_TriggersError_inConsole()
@@ -135,7 +135,7 @@ class EnvironmentValidationTest extends SystemTestCase
private function assertInstallationProcessStarted($output)
{
- $this->assertContains('<title>Matomo '. Version::VERSION .' &rsaquo; Installation</title>', $output);
+ self::assertStringContainsString('<title>Matomo '. Version::VERSION .' &rsaquo; Installation</title>', $output);
}
private function simulateAbsentConfigFile($fileName)
diff --git a/tests/PHPUnit/System/FrontControllerTest.php b/tests/PHPUnit/System/FrontControllerTest.php
index e0eb62df7d..c2f3063c2e 100644
--- a/tests/PHPUnit/System/FrontControllerTest.php
+++ b/tests/PHPUnit/System/FrontControllerTest.php
@@ -24,9 +24,9 @@ class FrontControllerTest extends SystemTestCase
$header = $this->getResponseHeader($url);
if ($redirection) {
- $this->assertContains('Location: ' . Fixture::getRootUrl() . 'tests/PHPUnit/proxy/' . $redirection . "\r\n", $header);
+ self::assertStringContainsString('Location: ' . Fixture::getRootUrl() . 'tests/PHPUnit/proxy/' . $redirection . "\r\n", $header);
} else {
- $this->assertNotContains('Location: ', $header);
+ self::assertStringNotContainsString('Location: ', $header);
}
}
diff --git a/tests/PHPUnit/System/ImportLogsTest.php b/tests/PHPUnit/System/ImportLogsTest.php
index 94d542a9f9..9cf644be60 100644
--- a/tests/PHPUnit/System/ImportLogsTest.php
+++ b/tests/PHPUnit/System/ImportLogsTest.php
@@ -27,7 +27,7 @@ class ImportLogsTest extends SystemTestCase
/** @var ManySitesImportedLogs */
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -132,8 +132,8 @@ class ImportLogsTest extends SystemTestCase
$this->assertEquals(1, count($whateverDotCom));
// make sure invalid requests are reported correctly
- $this->assertContains('The Matomo tracker identified 2 invalid requests on lines: 10, 11', $output);
- $this->assertContains("The following lines were not tracked by Matomo, either due to a malformed tracker request or error in the tracker:\n\n10, 11", $output);
+ self::assertStringContainsString('The Matomo tracker identified 2 invalid requests on lines: 10, 11', $output);
+ self::assertStringContainsString("The following lines were not tracked by Matomo, either due to a malformed tracker request or error in the tracker:\n\n10, 11", $output);
}
public function test_LogImporter_RetriesWhenServerFails()
@@ -153,12 +153,12 @@ class ImportLogsTest extends SystemTestCase
$output = implode("\n", $output);
for ($i = 2; $i != 6; ++$i) {
- $this->assertContains("Retrying request, attempt number $i", $output);
+ self::assertStringContainsString("Retrying request, attempt number $i", $output);
}
- $this->assertNotContains("Retrying request, attempt number 6", $output);
+ self::assertStringNotContainsString("Retrying request, attempt number 6", $output);
- $this->assertContains("Max number of attempts reached, server is unreachable!", $output);
+ self::assertStringContainsString("Max number of attempts reached, server is unreachable!", $output);
}
private function simulateTrackerFailure()
diff --git a/tests/PHPUnit/System/MultipleSitesArchivingTest.php b/tests/PHPUnit/System/MultipleSitesArchivingTest.php
index 1889e3770e..198828d6fd 100644
--- a/tests/PHPUnit/System/MultipleSitesArchivingTest.php
+++ b/tests/PHPUnit/System/MultipleSitesArchivingTest.php
@@ -21,7 +21,7 @@ class MultipleSitesArchivingTest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
index 96a81bea52..22a8cca5f8 100644
--- a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
+++ b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
@@ -33,12 +33,12 @@ class OneVisitorTwoVisitsTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class
- public function setUp()
+ public function setUp(): void
{
Proxy::getInstance()->setHideIgnoredFunctions(false);
}
- public function tearDown()
+ public function tearDown(): void
{
Proxy::getInstance()->setHideIgnoredFunctions(true);
}
diff --git a/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php b/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
index 9b9b74295d..5842250617 100644
--- a/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
+++ b/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
@@ -21,7 +21,7 @@ class PeriodIsRangeDateIsLastNMetadataAndNormalAPITest extends SystemTestCase
{
public static $fixture = null;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
self::$fixture->dateTime = Date::factory('yesterday')->getDateTime();
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/PivotByQueryParamTest.php b/tests/PHPUnit/System/PivotByQueryParamTest.php
index f94d1749fa..8250cfb159 100644
--- a/tests/PHPUnit/System/PivotByQueryParamTest.php
+++ b/tests/PHPUnit/System/PivotByQueryParamTest.php
@@ -23,7 +23,7 @@ class PivotByQueryParamTest extends SystemTestCase
*/
public static $fixture = null;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/PHPUnit/System/RawLogDaoTest.php b/tests/PHPUnit/System/RawLogDaoTest.php
index c8108972f9..cce4e7a40d 100644
--- a/tests/PHPUnit/System/RawLogDaoTest.php
+++ b/tests/PHPUnit/System/RawLogDaoTest.php
@@ -44,7 +44,7 @@ class RawLogDaoTest extends SystemTestCase
private $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -85,12 +85,11 @@ class RawLogDaoTest extends SystemTestCase
$this->assertSame('idvisit', $this->dao->getIdFieldForLogTable('log_visit'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Unknown log table 'log_foobarbaz'
- */
public function test_getIdFieldForLogTable_whenUnknownTable()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unknown log table \'log_foobarbaz\'');
+
$this->dao->getIdFieldForLogTable('log_foobarbaz');
}
diff --git a/tests/PHPUnit/System/TimezonesTest.php b/tests/PHPUnit/System/TimezonesTest.php
index 3ae4e1433a..7bce78d87a 100644
--- a/tests/PHPUnit/System/TimezonesTest.php
+++ b/tests/PHPUnit/System/TimezonesTest.php
@@ -24,7 +24,7 @@ class TimezonesTest extends SystemTestCase
*/
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/System/TrackerResponseTest.php b/tests/PHPUnit/System/TrackerResponseTest.php
index 629278bec0..c76d145591 100644
--- a/tests/PHPUnit/System/TrackerResponseTest.php
+++ b/tests/PHPUnit/System/TrackerResponseTest.php
@@ -24,7 +24,7 @@ class TrackerResponseTest extends SystemTestCase
*/
private $tracker;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/System/TrackerTest.php b/tests/PHPUnit/System/TrackerTest.php
index 4595df922f..98b689e34e 100644
--- a/tests/PHPUnit/System/TrackerTest.php
+++ b/tests/PHPUnit/System/TrackerTest.php
@@ -30,7 +30,7 @@ class TrackerTest extends IntegrationTestCase
const TASKS_FINISHED_OPTION_NAME = "Tests.scheduledTasksFinished";
const TASKS_STARTED_OPTION_NAME = "Tests.scheduledTasksStarted";
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -161,7 +161,7 @@ class TrackerTest extends IntegrationTestCase
$this->assertEquals(1, count($this->getConversionItems()));
$response = $this->sendTrackingRequestByCurl($urlToTest);
- $this->assertContains('This resource is part of Matomo.', $response);
+ self::assertStringContainsString('This resource is part of Matomo.', $response);
$this->assertEquals(1, $this->getCountOfConversions());
$this->assertEquals(1, count($this->getConversionItems()));
@@ -210,7 +210,7 @@ class TrackerTest extends IntegrationTestCase
$this->assertScheduledTasksWereRun();
- $this->assertContains('Scheduled Tasks: Starting...', $response);
+ self::assertStringContainsString('Scheduled Tasks: Starting...', $response);
}
public function getTypesOfErrorsForScheduledTasksTrackerFailureTest()
@@ -255,11 +255,11 @@ class TrackerTest extends IntegrationTestCase
$this->assertStringStartsWith('{"status":', $output);
if($expectTrackingToSucceed) {
- $this->assertNotContains('error', $output);
- $this->assertContains('success', $output);
+ self::assertStringNotContainsString('error', $output);
+ self::assertStringContainsString('success', $output);
} else {
- $this->assertContains('error', $output);
- $this->assertNotContains('success', $output);
+ self::assertStringContainsString('error', $output);
+ self::assertStringNotContainsString('success', $output);
}
}
@@ -359,7 +359,7 @@ class TrackerTest extends IntegrationTestCase
$initialTask = new Task($this, 'markCustomTaskExecuted', null, Schedule::factory('hourly'));
$tasksToAdd = array_merge(array($initialTask), $tasksToAdd);
- $mockTaskLoader = $this->getMock('Piwik\Scheduler\TaskLoader', array('loadTasks'));
+ $mockTaskLoader = $this->createPartialMock('Piwik\Scheduler\TaskLoader', array('loadTasks'));
$mockTaskLoader->expects($this->any())->method('loadTasks')->will($this->returnValue($tasksToAdd));
$result['Piwik\Scheduler\TaskLoader'] = $mockTaskLoader;
}
diff --git a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
index 7e3acbcf97..d4536cc327 100644
--- a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
+++ b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
@@ -21,12 +21,12 @@ class UserIdAndVisitorIdTest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition
- public function setUp()
+ public function setUp(): void
{
Proxy::getInstance()->setHideIgnoredFunctions(false);
}
- public function tearDown()
+ public function tearDown(): void
{
Proxy::getInstance()->setHideIgnoredFunctions(true);
}
diff --git a/tests/PHPUnit/Unit/API/ApiRendererTest.php b/tests/PHPUnit/Unit/API/ApiRendererTest.php
index 37d193483f..427991fdac 100644
--- a/tests/PHPUnit/Unit/API/ApiRendererTest.php
+++ b/tests/PHPUnit/Unit/API/ApiRendererTest.php
@@ -17,7 +17,7 @@ use Piwik\Plugin\Manager;
*/
class ApiRendererTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
Manager::getInstance()->loadPlugins(array('API'));
}
@@ -40,12 +40,11 @@ class ApiRendererTest extends \PHPUnit\Framework\TestCase
$this->assertInstanceOf('Piwik\Plugins\API\Renderer\Original', $renderer);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage General_ExceptionInvalidRendererFormat
- */
public function test_factory_shouldThrowAnException_IfInvalidFormatGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidRendererFormat');
+
ApiRenderer::factory('phpi', array());
}
}
diff --git a/tests/PHPUnit/Unit/API/ResponseBuilderTest.php b/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
index 67280d9c36..d4c0a37fdf 100644
--- a/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
+++ b/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
@@ -19,7 +19,7 @@ use Piwik\Plugin\Manager;
*/
class ResponseBuilderTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
Manager::getInstance()->loadPlugins(array('API'));
}
diff --git a/tests/PHPUnit/Unit/Archive/ChunkTest.php b/tests/PHPUnit/Unit/Archive/ChunkTest.php
index 12ddeb1a6d..c755ac2674 100644
--- a/tests/PHPUnit/Unit/Archive/ChunkTest.php
+++ b/tests/PHPUnit/Unit/Archive/ChunkTest.php
@@ -23,7 +23,7 @@ class ChunkTest extends \PHPUnit\Framework\TestCase
private $recordName = 'Actions_ActionsUrl';
- public function setUp()
+ public function setUp(): void
{
$this->chunk = new Chunk();
}
diff --git a/tests/PHPUnit/Unit/Archiver/RequestTest.php b/tests/PHPUnit/Unit/Archiver/RequestTest.php
index a72468348c..85363472fb 100644
--- a/tests/PHPUnit/Unit/Archiver/RequestTest.php
+++ b/tests/PHPUnit/Unit/Archiver/RequestTest.php
@@ -15,7 +15,7 @@ use Piwik\Date;
class RequestTest extends \PHPUnit\Framework\TestCase
{
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
Date::$now = null;
diff --git a/tests/PHPUnit/Unit/AssetManager/UIAssetCacheBusterTest.php b/tests/PHPUnit/Unit/AssetManager/UIAssetCacheBusterTest.php
index 866808825b..5404cca2dc 100644
--- a/tests/PHPUnit/Unit/AssetManager/UIAssetCacheBusterTest.php
+++ b/tests/PHPUnit/Unit/AssetManager/UIAssetCacheBusterTest.php
@@ -18,7 +18,7 @@ class UIAssetCacheBusterTest extends TestCase
*/
private $cacheBuster;
- public function setUp()
+ public function setUp(): void
{
$this->cacheBuster = UIAssetCacheBuster::getInstance();
}
diff --git a/tests/PHPUnit/Unit/Category/CategoryListTest.php b/tests/PHPUnit/Unit/Category/CategoryListTest.php
index 371a674e3d..32392b2ac4 100644
--- a/tests/PHPUnit/Unit/Category/CategoryListTest.php
+++ b/tests/PHPUnit/Unit/Category/CategoryListTest.php
@@ -23,7 +23,7 @@ class CategoryListTest extends \PHPUnit\Framework\TestCase
*/
private $categoryList;
- public function setUp()
+ public function setUp(): void
{
$this->categoryList = new CategoryList();
}
@@ -40,12 +40,11 @@ class CategoryListTest extends \PHPUnit\Framework\TestCase
$this->assertSame(array('myTest' => $category), $this->categoryList->getCategories());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Category myTest already exists
- */
public function test_addCategory_shouldThrowException_IfAddingSameCategoryIdTwice()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Category myTest already exists');
+
$this->addCategory('myTest');
$this->addCategory('myTest');
}
diff --git a/tests/PHPUnit/Unit/Category/CategoryTest.php b/tests/PHPUnit/Unit/Category/CategoryTest.php
index 39ae0bfb92..6d475c08a3 100644
--- a/tests/PHPUnit/Unit/Category/CategoryTest.php
+++ b/tests/PHPUnit/Unit/Category/CategoryTest.php
@@ -23,7 +23,7 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
*/
private $category;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->category = new Category();
@@ -76,12 +76,11 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
$this->assertSame(array($subcategory1, $subcategory2), $this->category->getSubcategories());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Subcategory id1 already exists
- */
public function test_addSubcategory_ShouldThrowException_WhenAddingSubcategoryWithSameIdTwice()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Subcategory id1 already exists');
+
$subcategory1 = $this->createSubcategory('id1', 'name1');
$subcategory2 = $this->createSubcategory('id1', 'name2');
diff --git a/tests/PHPUnit/Unit/Category/SubcategoryTest.php b/tests/PHPUnit/Unit/Category/SubcategoryTest.php
index 1b035a68b1..073118087f 100644
--- a/tests/PHPUnit/Unit/Category/SubcategoryTest.php
+++ b/tests/PHPUnit/Unit/Category/SubcategoryTest.php
@@ -23,7 +23,7 @@ class SubcategoryTest extends \PHPUnit\Framework\TestCase
*/
private $subcategory;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->subcategory = new Subcategory();
diff --git a/tests/PHPUnit/Unit/CommonTest.php b/tests/PHPUnit/Unit/CommonTest.php
index 8647dd00f6..a09c68aa73 100644
--- a/tests/PHPUnit/Unit/CommonTest.php
+++ b/tests/PHPUnit/Unit/CommonTest.php
@@ -120,13 +120,9 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarEmptyVarName()
{
- try {
- $_GET[''] = 1;
- Common::getRequestVar('');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+ $_GET[''] = 1;
+ Common::getRequestVar('');
}
/**
@@ -134,12 +130,8 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarNoDefaultNoTypeNoValue()
{
- try {
- Common::getRequestVar('test');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+ Common::getRequestVar('test');
}
/**
@@ -168,11 +160,11 @@ class CommonTest extends TestCase
/**
* nodefault Withtype WithValue => exception cos type not matching
- * @expectedException \Exception
- * @expectedExceptionMessage The parameter 'test' isn't set in the Request
*/
public function testGetRequestVarNoDefaultWithTypeWithValue()
{
+ $this->expectException(Exception::class);
+ $this->expectDeprecationMessage("The parameter 'test' isn't set in the Request");
$_GET['test'] = false;
Common::getRequestVar('test', null, 'string');
}
@@ -182,13 +174,8 @@ class CommonTest extends TestCase
*/
public function testGetRequestVarNoDefaultWithTypeWithValue2()
{
- try {
- Common::getRequestVar('test', null, 'string');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
-
+ $this->expectException(Exception::class);
+ Common::getRequestVar('test', null, 'string');
}
/**
@@ -285,7 +272,7 @@ class CommonTest extends TestCase
"WHITE SPACE",
);
foreach ($notvalid as $toTest) {
- $this->assertFalse(Filesystem::isValidFilename($toTest), $toTest . " valid but shouldn't!");
+ self::assertFalse(Filesystem::isValidFilename($toTest), $toTest . " valid but shouldn't!");
}
}
@@ -299,8 +286,8 @@ class CommonTest extends TestCase
// strings not unserializable should return false and trigger a debug log
$logger = $this->createFakeLogger();
- $this->assertFalse(Common::safe_unserialize('{1:somebroken}'));
- $this->assertContains('Unable to unserialize a string: unserialize(): Error at offset 0 of 14 bytes', $logger->output);
+ self::assertFalse(Common::safe_unserialize('{1:somebroken}'));
+ self::assertStringContainsString('Unable to unserialize a string: unserialize(): Error at offset 0 of 14 bytes', $logger->output);
}
private function createFakeLogger()
diff --git a/tests/PHPUnit/Unit/Config/IniFileChainCacheTest.php b/tests/PHPUnit/Unit/Config/IniFileChainCacheTest.php
index 7d13559914..9ab66d3c3a 100644
--- a/tests/PHPUnit/Unit/Config/IniFileChainCacheTest.php
+++ b/tests/PHPUnit/Unit/Config/IniFileChainCacheTest.php
@@ -45,7 +45,7 @@ class IniFileChainCacheTest extends IniFileChainTest
private $testHost = 'mytest.matomo.org';
- public function setUp()
+ public function setUp(): void
{
$GLOBALS['ENABLE_CONFIG_PHP_CACHE'] = true;
$_SERVER['HTTP_HOST'] = $this->testHost;
@@ -59,7 +59,7 @@ class IniFileChainCacheTest extends IniFileChainTest
Config::setSetting('General', 'trusted_hosts', array($this->testHost, 'foonot.exists'));
}
- public function tearDown()
+ public function tearDown(): void
{
$this->cache->doDelete(IniFileChain::CONFIG_CACHE_KEY);
unset($GLOBALS['ENABLE_CONFIG_PHP_CACHE']);
diff --git a/tests/PHPUnit/Unit/ConfigTest.php b/tests/PHPUnit/Unit/ConfigTest.php
index b10c8fbf4d..8938724fae 100644
--- a/tests/PHPUnit/Unit/ConfigTest.php
+++ b/tests/PHPUnit/Unit/ConfigTest.php
@@ -8,9 +8,9 @@
namespace Piwik\Tests\Unit;
+use PHPUnit\Framework\TestCase;
use Piwik\Application\Kernel\GlobalSettingsProvider;
use Piwik\Config;
-use Piwik\Tests\Framework\Mock\TestConfig;
class DumpConfigTestMockIniFileChain extends Config\IniFileChain
{
@@ -51,7 +51,7 @@ class DumpConfigTestMockConfig extends Config
/**
* @group Core
*/
-class ConfigTest extends \PHPUnit\Framework\TestCase
+class ConfigTest extends TestCase
{
public function testUserConfigOverwritesSectionGlobalConfigValue()
{
diff --git a/tests/PHPUnit/Unit/Container/IniConfigDefinitionSourceTest.php b/tests/PHPUnit/Unit/Container/IniConfigDefinitionSourceTest.php
index 8835a9f89f..32b0918668 100644
--- a/tests/PHPUnit/Unit/Container/IniConfigDefinitionSourceTest.php
+++ b/tests/PHPUnit/Unit/Container/IniConfigDefinitionSourceTest.php
@@ -77,7 +77,7 @@ class IniConfigDefinitionSourceTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($definition instanceof ValueDefinition);
$this->assertEquals('ini.General', $definition->getName());
- $this->assertInternalType('array', $definition->getValue());
+ self::assertIsArray($definition->getValue());
$this->assertEquals(array('foo' => 'bar'), $definition->getValue());
}
@@ -103,10 +103,11 @@ class IniConfigDefinitionSourceTest extends \PHPUnit\Framework\TestCase
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject|GlobalSettingsProvider
+ * @return \PHPUnit\Framework\MockObject\MockObject|GlobalSettingsProvider
*/
private function createConfig()
{
- return $this->getMock('Piwik\Application\Kernel\GlobalSettingsProvider', array(), array(), '', false);
+ return $this->getMockBuilder('Piwik\Application\Kernel\GlobalSettingsProvider')
+ ->disableOriginalConstructor()->getMock();
}
}
diff --git a/tests/PHPUnit/Unit/CookieTest.php b/tests/PHPUnit/Unit/CookieTest.php
index ccf534cec8..738229e520 100644
--- a/tests/PHPUnit/Unit/CookieTest.php
+++ b/tests/PHPUnit/Unit/CookieTest.php
@@ -44,7 +44,7 @@ class CookieTest extends \PHPUnit\Framework\TestCase
*
* @dataProvider getJsonSerializeData
*/
- public function testJsonSerialize($testData, $id)
+ public function testJsonSerialize($id, $testData)
{
$this->assertEquals($testData, json_decode(json_encode($testData), $assoc = true), $id);
}
diff --git a/tests/PHPUnit/Unit/CronArchive/FixedSiteIdsTest.php b/tests/PHPUnit/Unit/CronArchive/FixedSiteIdsTest.php
index 1295c48245..6349db258a 100644
--- a/tests/PHPUnit/Unit/CronArchive/FixedSiteIdsTest.php
+++ b/tests/PHPUnit/Unit/CronArchive/FixedSiteIdsTest.php
@@ -20,7 +20,7 @@ class FixedSiteIdsTest extends \PHPUnit\Framework\TestCase
*/
private $fixedSiteIds;
- public function setUp()
+ public function setUp(): void
{
$this->fixedSiteIds = new FixedSiteIds(array(1,2,5,9));
}
diff --git a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
index 3690899ffd..63896a96fc 100644
--- a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
+++ b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
@@ -20,7 +20,7 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit\Framework\TestCase
private $mockSegmentEntries;
- public function setUp()
+ public function setUp(): void
{
Config::getInstance()->General['enabled_periods_API'] = 'day,week,month,year,range';
@@ -247,7 +247,7 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit\Framework\TestCase
private function createUrlProviderToTest($processNewSegmentsFrom)
{
- $mockSegmentEditorModel = $this->getMock('Piwik\Plugins\SegmentEditor\Model', array('getAllSegmentsAndIgnoreVisibility'));
+ $mockSegmentEditorModel = $this->createPartialMock('Piwik\Plugins\SegmentEditor\Model', array('getAllSegmentsAndIgnoreVisibility'));
$mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($this->mockSegmentEntries));
return new SegmentArchivingRequestUrlProvider($processNewSegmentsFrom, $mockSegmentEditorModel, null, Date::factory(self::TEST_NOW));
diff --git a/tests/PHPUnit/Unit/DataAccess/ArchiveTableCreatorTest.php b/tests/PHPUnit/Unit/DataAccess/ArchiveTableCreatorTest.php
index ed4419a229..0107bd4642 100644
--- a/tests/PHPUnit/Unit/DataAccess/ArchiveTableCreatorTest.php
+++ b/tests/PHPUnit/Unit/DataAccess/ArchiveTableCreatorTest.php
@@ -17,7 +17,7 @@ class ArchiveTableCreatorTest extends \PHPUnit\Framework\TestCase
{
private $tables;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -33,7 +33,7 @@ class ArchiveTableCreatorTest extends \PHPUnit\Framework\TestCase
);
}
- public function tearDown()
+ public function tearDown(): void
{
ArchiveTableCreator::clear();
diff --git a/tests/PHPUnit/Unit/DataAccess/ArchiveWriterTest.php b/tests/PHPUnit/Unit/DataAccess/ArchiveWriterTest.php
index fc76be4363..3814c0ffc1 100644
--- a/tests/PHPUnit/Unit/DataAccess/ArchiveWriterTest.php
+++ b/tests/PHPUnit/Unit/DataAccess/ArchiveWriterTest.php
@@ -97,7 +97,10 @@ class ArchiveWriterTest extends \PHPUnit\Framework\TestCase
private function assertInsertBlobRecordInsertedRecordsInBulk($expectedBlobs, $blobs)
{
- $writer = $this->getMock('Piwik\DataAccess\ArchiveWriter', array('insertRecord', 'compress'), array(), '', false);
+ $writer = $this->getMockBuilder('Piwik\DataAccess\ArchiveWriter')
+ ->disableOriginalConstructor()
+ ->onlyMethods(array('insertRecord', 'compress'))
+ ->getMock();
$writer->expects($this->exactly(count($expectedBlobs)))
->method('compress')
->will($this->returnArgument(0));
@@ -114,7 +117,10 @@ class ArchiveWriterTest extends \PHPUnit\Framework\TestCase
private function assertInsertBlobRecordInsertedASingleRecord($expectedBlob, $blob)
{
- $writer = $this->getMock('Piwik\DataAccess\ArchiveWriter', array('insertRecord', 'compress'), array(), '', false);
+ $writer = $this->getMockBuilder('Piwik\DataAccess\ArchiveWriter')
+ ->disableOriginalConstructor()
+ ->onlyMethods(array('insertRecord', 'compress'))
+ ->getMock();
$writer->expects($this->once())
->method('compress')
->will($this->returnArgument(0));
diff --git a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php
index f0c818802b..e16796c9bb 100644
--- a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php
+++ b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php
@@ -23,7 +23,7 @@ class JoinGeneratorTest extends \PHPUnit\Framework\TestCase
*/
private $generator;
- public function setUp()
+ public function setUp(): void
{
$this->generator = $this->makeTables(array(
'log_visit',
@@ -100,14 +100,14 @@ class JoinGeneratorTest extends \PHPUnit\Framework\TestCase
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage Table 'log_visit' can't be joined for segmentation
- *
* Note: the exception reports `log_visit` and not `log_custom` as it resolves the dependencies as so resolves
* from `log_custom` to `log_visit` but is then not able to find a way to join `log_visit` with `log_action`
*/
public function test_generate_getJoinString_CustomVisitTableCantBeJoinedWithAction()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Table \'log_visit\' can\'t be joined for segmentation');
+
$generator = $this->generate(array('log_action', 'log_custom'));
$generator->getJoinString();
}
@@ -161,12 +161,11 @@ class JoinGeneratorTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($expected, $generator->getJoinString());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Please reorganize the joined tables as the table log_conversion in {"0":"log_visit","1":"log_conversion","2":"log_link_visit_action","3":{"table":"log_conversion","joinOn":"log_link_visit_action.idvisit2 = log_conversion.idvisit2"}} cannot be joined correctly.
- */
public function test_generate_getJoinString_manuallyJoinedAlreadyWithCustomConditionInArrayInverted()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Please reorganize the joined tables as the table log_conversion in {"0":"log_visit","1":"log_conversion","2":"log_link_visit_action","3":{"table":"log_conversion","joinOn":"log_link_visit_action.idvisit2 = log_conversion.idvisit2"}} cannot be joined correctly.');
+
$generator = $this->generate(array(
'log_visit',
'log_conversion',
diff --git a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinTablesTest.php b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinTablesTest.php
index 16419c8c3f..a5961697e8 100644
--- a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinTablesTest.php
+++ b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinTablesTest.php
@@ -22,7 +22,7 @@ class JoinTablesTest extends \PHPUnit\Framework\TestCase
*/
private $tables;
- public function setUp()
+ public function setUp(): void
{
$this->tables = $this->makeTables(array(
'log_visit',
@@ -30,12 +30,11 @@ class JoinTablesTest extends \PHPUnit\Framework\TestCase
'log_action'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Table 'log_foo_bar_baz' can't be used for segmentation
- */
public function test_construct_shouldThrowException_IfTableIsNotPossibleToJoin()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Table \'log_foo_bar_baz\' can\'t be used for segmentation');
+
$this->makeTables(array('log_visit', 'log_foo_bar_baz'));
}
@@ -72,12 +71,11 @@ class JoinTablesTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($this->tables->hasJoinedTable($table));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Table 'log_foo_bar_baz' can't be used for segmentation
- */
public function test_addTableToJoin_shouldCheckIfTableCanBeUsedForSegmentation()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Table \'log_foo_bar_baz\' can\'t be used for segmentation');
+
$table = 'log_foo_bar_baz';
$this->assertFalse($this->tables->hasJoinedTable($table));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterByLabelMappingTest.php b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterByLabelMappingTest.php
index e529701732..3690ef16a2 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterByLabelMappingTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterByLabelMappingTest.php
@@ -25,7 +25,7 @@ class AddSegmentByLabelMappingTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php
index 5d18a00fd3..9dcfa9ebc0 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php
@@ -33,7 +33,7 @@ class AddSegmentBySegmentValueTest extends \PHPUnit\Framework\TestCase
private $report;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterTest.php b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterTest.php
index 4ba4bcc5c1..531f533195 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterTest.php
@@ -25,7 +25,7 @@ class AddSegmentByLabelTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRow(array('label' => 'http://piwik.org/test'));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentValueTest.php b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentValueTest.php
index c3a5398a13..7f7848ab73 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentValueTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentValueTest.php
@@ -25,7 +25,7 @@ class AddSegmentValueTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRow(array('label' => 'http://piwik.org/test'));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/ColumnCallbackDeleteMetadataTest.php b/tests/PHPUnit/Unit/DataTable/Filter/ColumnCallbackDeleteMetadataTest.php
index 71b0f2c59c..cf2258715c 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/ColumnCallbackDeleteMetadataTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/ColumnCallbackDeleteMetadataTest.php
@@ -25,7 +25,7 @@ class ColumnCallbackDeleteMetadataTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRowWithMetadata(array('test' => '1'));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php b/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php
index 0bff3b3b12..d128ff7615 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php
@@ -25,7 +25,7 @@ class PrependSegmentTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRowWithMetadata(array('test' => '1'));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/PrependValueToMetadataTest.php b/tests/PHPUnit/Unit/DataTable/Filter/PrependValueToMetadataTest.php
index 4d82a28cf0..7d26799a3d 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/PrependValueToMetadataTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/PrependValueToMetadataTest.php
@@ -25,7 +25,7 @@ class PrependValueToMetadataTest extends \PHPUnit\Framework\TestCase
*/
private $table;
- public function setUp()
+ public function setUp(): void
{
$this->table = new DataTable();
$this->addRowWithMetadata(array('test' => '1'));
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/TruncateTest.php b/tests/PHPUnit/Unit/DataTable/Filter/TruncateTest.php
index 06c462afff..29104c71b6 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/TruncateTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/TruncateTest.php
@@ -22,7 +22,7 @@ class DataTable_Filter_TruncateTest extends \PHPUnit\Framework\TestCase
{
// remark: this unit test would become invalid and would need to be rewritten if
// Truncate filter stops calling getRowsCount() on the DataTable being filtered.
- $mockedDataTable = $this->getMock('\Piwik\DataTable', array('getRowsCount'));
+ $mockedDataTable = $this->createPartialMock('\Piwik\DataTable', array('getRowsCount'));
$mockedDataTable->expects($this->never())->method('getRowsCount');
$dataTableBeingFiltered = new DataTable();
@@ -46,7 +46,7 @@ class DataTable_Filter_TruncateTest extends \PHPUnit\Framework\TestCase
// remark: this unit test would become invalid and would need to be rewritten if
// Truncate filter stops calling getIdSubDataTable() on rows associated with a SubDataTable
- $rowBeingFiltered = $this->getMock('\Piwik\DataTable\Row', array('getIdSubDataTable'));
+ $rowBeingFiltered = $this->createPartialMock('\Piwik\DataTable\Row', array('getIdSubDataTable'));
$rowBeingFiltered->expects($this->never())->method('getIdSubDataTable');
$dataTableBeingFiltered->addRow($rowBeingFiltered);
diff --git a/tests/PHPUnit/Unit/DataTable/ManagerTest.php b/tests/PHPUnit/Unit/DataTable/ManagerTest.php
index 74eac55054..7c482a585d 100644
--- a/tests/PHPUnit/Unit/DataTable/ManagerTest.php
+++ b/tests/PHPUnit/Unit/DataTable/ManagerTest.php
@@ -19,7 +19,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
*/
private $manager;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->manager = new Manager();
@@ -30,12 +30,11 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
return new DataTable();
}
- /**
- * @expectedException \Piwik\DataTable\TableNotFoundException
- * @expectedExceptionMessage table id 1 not found in memory
- */
public function test_getTable_shouldThrowException_IfTableIdDoesNotExist()
{
+ $this->expectException(\Piwik\DataTable\TableNotFoundException::class);
+ $this->expectExceptionMessage('table id 1 not found in memory');
+
$this->manager->getTable(1);
}
diff --git a/tests/PHPUnit/Unit/DataTable/MapTest.php b/tests/PHPUnit/Unit/DataTable/MapTest.php
index 4b7ea7336e..615c2a6c93 100644
--- a/tests/PHPUnit/Unit/DataTable/MapTest.php
+++ b/tests/PHPUnit/Unit/DataTable/MapTest.php
@@ -13,7 +13,7 @@ use Piwik\Tests\Framework\Mock\TestConfig;
*/
class Test_DataTable_Map extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php
index e68c4aa7af..efadd0be40 100644
--- a/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php
@@ -19,7 +19,7 @@ use Piwik\DataTable\Simple;
*/
class DataTable_Renderer_CSVTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/ConsoleTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/ConsoleTest.php
index 42bf85b010..817e8b86df 100644
--- a/tests/PHPUnit/Unit/DataTable/Renderer/ConsoleTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Renderer/ConsoleTest.php
@@ -18,7 +18,7 @@ use Piwik\DataTable\Row;
*/
class DataTable_Renderer_ConsoleTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php
index 3d724d3382..12df8d4daf 100644
--- a/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php
@@ -19,7 +19,7 @@ use Piwik\DataTable\Simple;
*/
class DataTable_Renderer_JSONTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/PHPTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/PHPTest.php
index cf80b1cb8d..863a9b91e1 100644
--- a/tests/PHPUnit/Unit/DataTable/Renderer/PHPTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Renderer/PHPTest.php
@@ -19,7 +19,7 @@ use Piwik\DataTable\Simple;
*/
class DataTable_Renderer_PHPTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php
index 80910c0f0a..8670d05425 100644
--- a/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php
@@ -19,7 +19,7 @@ use Piwik\DataTable\Simple;
*/
class DataTable_Renderer_XMLTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Manager::getInstance()->deleteAll();
diff --git a/tests/PHPUnit/Unit/DataTable/RowTest.php b/tests/PHPUnit/Unit/DataTable/RowTest.php
index 456a4f87b0..33445df8cf 100644
--- a/tests/PHPUnit/Unit/DataTable/RowTest.php
+++ b/tests/PHPUnit/Unit/DataTable/RowTest.php
@@ -21,7 +21,7 @@ class RowTest extends \PHPUnit\Framework\TestCase
*/
private $row;
- public function setUp()
+ public function setUp(): void
{
$this->row = new Row();
}
@@ -421,12 +421,11 @@ class RowTest extends \PHPUnit\Framework\TestCase
$this->assertSame(array('my_array' => $arrayValue), $this->row->getMetadata());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Trying to sum unsupported operands for column mycol in row with label = row1: array + integer
- */
public function test_sumRow_throwsIfAddingUnsupportedTypes()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Trying to sum unsupported operands for column mycol in row with label = row1: array + integer');
+
$row1 = new Row();
$row1->addColumn('label', 'row1');
$row1->addColumn('mycol', ['a']);
diff --git a/tests/PHPUnit/Unit/DataTableTest.php b/tests/PHPUnit/Unit/DataTableTest.php
index f48af916d2..fae8bee986 100644
--- a/tests/PHPUnit/Unit/DataTableTest.php
+++ b/tests/PHPUnit/Unit/DataTableTest.php
@@ -396,12 +396,11 @@ class DataTableTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(array(5, 145), $finalRow->getColumn('test_int'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Unknown operation 'foobarinvalid'
- */
public function testSumRow_ShouldThrowExceptionIfInvalidOperationIsGiven()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Unknown operation \'foobarinvalid\'');
+
$row1 = new Row(array(Row::COLUMNS => array('test_int' => 145)));
$finalRow = new Row(array(Row::COLUMNS => array('test_int' => 5)));
$finalRow->sumRow($row1, $copyMetadata = true, $operation = array('test_int' => 'fooBarInvalid'));
@@ -442,11 +441,11 @@ class DataTableTest extends \PHPUnit\Framework\TestCase
/**
* Test serialize with an infinite recursion (a row linked to a table in the parent hierarchy)
* After 100 recursion must throw an exception
- *
- * @expectedException \Exception
*/
public function testSerializeWithInfiniteRecursion()
{
+ $this->expectException(\Exception::class);
+
$table = new DataTable;
$table->addRowFromArray(array(Row::COLUMNS => array('visits' => 245, 'visitors' => 245),
Row::DATATABLE_ASSOCIATED => $table));
@@ -938,7 +937,7 @@ class DataTableTest extends \PHPUnit\Framework\TestCase
public function testUnrelatedDataTableNotDestructed()
{
- $mockedDataTable = $this->getMock('\Piwik\DataTable', array('__destruct'));
+ $mockedDataTable = $this->createPartialMock('\Piwik\DataTable', array('__destruct'));
$mockedDataTable->expects($this->never())->method('__destruct');
$rowBeingDestructed = new Row();
@@ -982,7 +981,9 @@ class DataTableTest extends \PHPUnit\Framework\TestCase
*/
public function testSubDataTableIsDestructed()
{
- $mockedDataTable = $this->getMock('\Piwik\DataTable', array('__destruct'));
+ $mockedDataTable = $this->getMockBuilder('\Piwik\DataTable')
+ ->onlyMethods(['__destruct'])
+ ->getMock();
$mockedDataTable->expects($this->once())->method('__destruct');
$rowBeingDestructed = new Row();
diff --git a/tests/PHPUnit/Unit/DateTest.php b/tests/PHPUnit/Unit/DateTest.php
index 3cc586d3e0..abd6f2653a 100644
--- a/tests/PHPUnit/Unit/DateTest.php
+++ b/tests/PHPUnit/Unit/DateTest.php
@@ -18,7 +18,7 @@ use Piwik\Tests\Framework\Fixture;
*/
class DateTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -26,7 +26,7 @@ class DateTest extends \PHPUnit\Framework\TestCase
date_default_timezone_set('UTC');
}
- public function tearDown()
+ public function tearDown(): void
{
Date::$now = null;
date_default_timezone_set('UTC');
@@ -77,12 +77,8 @@ class DateTest extends \PHPUnit\Framework\TestCase
*/
public function testInvalidDateThrowsException()
{
- try {
- Date::factory('0001-01-01');
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+ Date::factory('0001-01-01');
}
public function getTimezoneOffsets()
@@ -466,21 +462,19 @@ class DateTest extends \PHPUnit\Framework\TestCase
];
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Date::factoryInTimezone() should not be used with
- */
public function test_factoryInTimezone_doesNotWorkWithNormalDates()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Date::factoryInTimezone() should not be used with');
+
Date::factoryInTimezone('2012-02-03', 'America/Toronto');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Date::factoryInTimezone() should not be used with
- */
public function test_factoryInTimezone_doesNotWorkWithTimestamps()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Date::factoryInTimezone() should not be used with');
+
Date::factoryInTimezone(time(), 'America/Toronto');
}
}
diff --git a/tests/PHPUnit/Unit/FactoryTest.php b/tests/PHPUnit/Unit/FactoryTest.php
index 416a6a38a6..b19e8f4700 100644
--- a/tests/PHPUnit/Unit/FactoryTest.php
+++ b/tests/PHPUnit/Unit/FactoryTest.php
@@ -23,12 +23,11 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
$this->assertInstanceOf('Piwik\Timer', $instance);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid class ID
- */
public function testCreatingInvalidClassThrows()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid class ID');
+
BaseFactory::factory("This\\Class\\Does\\Not\\Exist");
}
}
diff --git a/tests/PHPUnit/Unit/FilesystemTest.php b/tests/PHPUnit/Unit/FilesystemTest.php
index 66e8808c7b..a815ec551c 100644
--- a/tests/PHPUnit/Unit/FilesystemTest.php
+++ b/tests/PHPUnit/Unit/FilesystemTest.php
@@ -19,14 +19,14 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase
{
private $testPath;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->testPath = PIWIK_INCLUDE_PATH . '/tmp/filesystemtest';
Filesystem::mkdir($this->testPath);
}
- public function tearDown()
+ public function tearDown(): void
{
Filesystem::unlinkRecursive($this->testPath, true);
@@ -173,6 +173,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase
$target = $this->createEmptyTarget();
Filesystem::unlinkTargetFilesNotPresentInSource($source, $target);
+ $this->assertTrue(true);
}
public function test_unlinkTargetFilesNotPresentInSource_shouldUnlinkAllTargetFiles_IfSourceIsEmpty()
@@ -188,7 +189,7 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase
// make sure there is no longer a difference
$result = Filesystem::directoryDiff($source, $target);
- $this->assertEquals(array(), $result);
+ $this->assertEquals([], $result);
$result = Filesystem::directoryDiff($target, $source);
$this->assertEquals(array(), $result);
@@ -348,12 +349,11 @@ class FilesystemTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(1, $size);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid unit given
- */
public function test_getFileSize_ShouldThrowException_IfInvalidUnit()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid unit given');
+
Filesystem::getFileSize(__FILE__, 'iV');
}
diff --git a/tests/PHPUnit/Unit/LegacyAutoLoaderTest.php b/tests/PHPUnit/Unit/LegacyAutoLoaderTest.php
index 3456145d5d..5387daff25 100644
--- a/tests/PHPUnit/Unit/LegacyAutoLoaderTest.php
+++ b/tests/PHPUnit/Unit/LegacyAutoLoaderTest.php
@@ -39,19 +39,17 @@ class LegacyAutoLoaderTest extends \PHPUnit\Framework\TestCase
$this->assertInstanceOf(\Matomo\DummyClass::class, $class);
}
- /**
- * @expectedException \Error
- */
public function testNotExistingMatomoClassStillFails()
{
+ $this->expectException(\Error::class);
+
$class = new \Matomo\ClassNotFound();
}
- /**
- * @expectedException \Error
- */
public function testNotExistingPiwikClassStillFails()
{
+ $this->expectException(\Error::class);
+
$class = new \Piwik\ClassNotFound();
}
}
diff --git a/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php b/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php
index 387ea4bbd3..656200e030 100644
--- a/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php
+++ b/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php
@@ -24,7 +24,7 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
private $sitesInfo;
- public function setUp()
+ public function setUp(): void
{
$this->sitesInfo = array(
1 => array(
@@ -39,7 +39,7 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
$this->setSiteManagerApiMock();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
$this->unsetSiteManagerApiMock();
@@ -96,7 +96,7 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
{
$sitesInfo = $this->sitesInfo;
- $mock = $this->getMock('stdClass', array('getSiteFromId'));
+ $mock = $this->getMockBuilder('stdClass')->addMethods(['getSiteFromId'])->getMock();
$mock->expects($this->any())->method('getSiteFromId')->willReturnCallback(function ($idSite) use ($sitesInfo) {
return $sitesInfo[$idSite];
});
diff --git a/tests/PHPUnit/Unit/Metrics/FormatterTest.php b/tests/PHPUnit/Unit/Metrics/FormatterTest.php
index adf5b5ab96..2e62fbc9d1 100644
--- a/tests/PHPUnit/Unit/Metrics/FormatterTest.php
+++ b/tests/PHPUnit/Unit/Metrics/FormatterTest.php
@@ -25,7 +25,7 @@ class FormatterTest extends \PHPUnit\Framework\TestCase
private $sitesInfo;
- public function setUp()
+ public function setUp(): void
{
$this->sitesInfo = array(
1 => array(
@@ -56,7 +56,7 @@ class FormatterTest extends \PHPUnit\Framework\TestCase
$this->setSiteManagerApiMock();
}
- public function tearDown()
+ public function tearDown(): void
{
Fixture::resetTranslations();
NumberFormatter::getInstance()->clearCache();
@@ -225,7 +225,7 @@ class FormatterTest extends \PHPUnit\Framework\TestCase
{
$sitesInfo = $this->sitesInfo;
- $mock = $this->getMock('stdClass', array('getSiteFromId'));
+ $mock = $this->getMockBuilder('stdClass')->addMethods(['getSiteFromId'])->getMock();
$mock->expects($this->any())->method('getSiteFromId')->willReturnCallback(function ($idSite) use ($sitesInfo) {
return $sitesInfo[$idSite];
});
diff --git a/tests/PHPUnit/Unit/Metrics/SorterTest.php b/tests/PHPUnit/Unit/Metrics/SorterTest.php
index 9c1b3540f6..8006fb9576 100644
--- a/tests/PHPUnit/Unit/Metrics/SorterTest.php
+++ b/tests/PHPUnit/Unit/Metrics/SorterTest.php
@@ -30,7 +30,7 @@ class SorterTest extends UnitTestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Unit/Period/BasePeriodTest.php b/tests/PHPUnit/Unit/Period/BasePeriodTest.php
index d1834b0f42..f90473aaab 100644
--- a/tests/PHPUnit/Unit/Period/BasePeriodTest.php
+++ b/tests/PHPUnit/Unit/Period/BasePeriodTest.php
@@ -12,14 +12,14 @@ use Piwik\Tests\Framework\Fixture;
abstract class BasePeriodTest extends \PHPUnit\Framework\TestCase
{
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
Fixture::loadAllTranslations();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/PHPUnit/Unit/Period/DayTest.php b/tests/PHPUnit/Unit/Period/DayTest.php
index cf4d4ff59d..0cc544398b 100644
--- a/tests/PHPUnit/Unit/Period/DayTest.php
+++ b/tests/PHPUnit/Unit/Period/DayTest.php
@@ -19,14 +19,9 @@ class DayTest extends BasePeriodTest
*/
public function testInvalidDate()
{
- try {
- new Day('Invalid Date');
- } catch (\Exception $e) {
- return;
- } catch (\Throwable $e) {
- return;
- }
- $this->fail('Expected Exception not raised');
+ $this->expectException(\TypeError::class);
+
+ new Day('Invalid Date');
}
/**
@@ -200,16 +195,12 @@ class DayTest extends BasePeriodTest
*/
public function testAddSubperiodFails()
{
+ $this->expectException(\Exception::class);
+
// create the period
$period = new Day(Date::factory("2007-12-31"));
- try {
- $period->addSubperiod('');
- } catch (\Exception $e) {
- return;
- }
- // expected string
- $this->fail('Exception not raised');
+ $period->addSubperiod('');
}
public function getLocalizedShortStrings()
diff --git a/tests/PHPUnit/Unit/Period/RangeTest.php b/tests/PHPUnit/Unit/Period/RangeTest.php
index 2fb27457df..b90f6618c3 100644
--- a/tests/PHPUnit/Unit/Period/RangeTest.php
+++ b/tests/PHPUnit/Unit/Period/RangeTest.php
@@ -1165,16 +1165,13 @@ class RangeTest extends BasePeriodTest
public function testCustomRangeBeforeIsAfterYearRight()
{
- try {
- $range = new Range('range', '2007-02-09,2007-02-01');
- $this->assertEquals(0, $range->getNumberOfSubperiods());
- $this->assertEquals(array(), $range->toString());
-
- $range->getPrettyString();
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $range = new Range('range', '2007-02-09,2007-02-01');
+ $this->assertEquals(0, $range->getNumberOfSubperiods());
+ $this->assertEquals(array(), $range->toString());
+
+ $range->getPrettyString();
}
public function testCustomRangeLastN()
@@ -1218,13 +1215,10 @@ class RangeTest extends BasePeriodTest
public function testInvalidRangeThrows()
{
- try {
- $range = new Range('range', '0001-01-01,today');
- $range->getLocalizedLongString();
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $range = new Range('range', '0001-01-01,today');
+ $range->getLocalizedLongString();
}
public function testGetLocalizedShortString()
diff --git a/tests/PHPUnit/Unit/PeriodTest.php b/tests/PHPUnit/Unit/PeriodTest.php
index 7fbebdcb19..2d90fdbfdc 100644
--- a/tests/PHPUnit/Unit/PeriodTest.php
+++ b/tests/PHPUnit/Unit/PeriodTest.php
@@ -37,19 +37,19 @@ class PeriodTest extends \PHPUnit\Framework\TestCase
{
$period = new Day(Date::today());
$label = $period->getLabel();
- $this->assertInternalType('string', $label);
+ self::assertIsString($label);
$this->assertNotEmpty($label);
$period = new Week(Date::today());
$label = $period->getLabel();
- $this->assertInternalType('string', $label);
+ self::assertIsString($label);
$this->assertNotEmpty($label);
$period = new Month(Date::today());
$label = $period->getLabel();
- $this->assertInternalType('string', $label);
+ self::assertIsString($label);
$this->assertNotEmpty($label);
$period = new Year(Date::today());
$label = $period->getLabel();
- $this->assertInternalType('string', $label);
+ self::assertIsString($label);
$this->assertNotEmpty($label);
}
@@ -65,15 +65,18 @@ class PeriodTest extends \PHPUnit\Framework\TestCase
Period::checkDateFormat('previous30');
Period::checkDateFormat('+1 day');
Period::checkDateFormat('next Thursday');
+
+ $this->assertTrue(true);
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage Date format must be: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http://php.net/strtotime for more information):
* @dataProvider getInvalidDateFormats
*/
public function testValidate_InvalidDates($invalidDateFormat)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Date format must be: YYYY-MM-DD, or \'today\' or \'yesterday\' or any keyword supported by the strtotime function (see http://php.net/strtotime for more information):');
+
Period::checkDateFormat($invalidDateFormat);
}
@@ -148,12 +151,13 @@ class PeriodTest extends \PHPUnit\Framework\TestCase
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage is a date before first website was online. Try date that's after
* @dataProvider getInvalidDatesBeforeFirstWebsite
*/
public function testValidate_InvalidDatesBeforeFirstWebsite($invalidDatesBeforeFirstWebsite)
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('is a date before first website was online. Try date that\'s after');
+
Period::checkDateFormat($invalidDatesBeforeFirstWebsite);
}
diff --git a/tests/PHPUnit/Unit/Plugin/ComponentFactoryTest.php b/tests/PHPUnit/Unit/Plugin/ComponentFactoryTest.php
index 1380007900..628155c18a 100644
--- a/tests/PHPUnit/Unit/Plugin/ComponentFactoryTest.php
+++ b/tests/PHPUnit/Unit/Plugin/ComponentFactoryTest.php
@@ -12,7 +12,6 @@ use Piwik\Config;
use Piwik\Plugin\ComponentFactory;
use Piwik\Plugin\Manager as PluginManager;
use Piwik\Plugin\Report;
-use Piwik\Tests\Framework\Mock\TestConfig;
/**
* @group Core
@@ -21,7 +20,7 @@ class ComponentFactoryTest extends TestCase
{
const REPORT_CLASS_NAME = 'Piwik\\Plugin\\Report';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Unit/Report/ReportWidgetConfigTest.php b/tests/PHPUnit/Unit/Report/ReportWidgetConfigTest.php
index a9b3a255cb..d301beea72 100644
--- a/tests/PHPUnit/Unit/Report/ReportWidgetConfigTest.php
+++ b/tests/PHPUnit/Unit/Report/ReportWidgetConfigTest.php
@@ -23,7 +23,7 @@ class ReportWidgetConfigTest extends \PHPUnit\Framework\TestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->config = new ReportWidgetConfig();
@@ -216,13 +216,14 @@ class ReportWidgetConfigTest extends \PHPUnit\Framework\TestCase
{
$this->config->enable();
$this->config->checkIsEnabled();
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Exception
- */
public function test_checkIsEnabled_shouldThrowException_IfDisabled()
{
+ $this->expectException(\Exception::class);
+
$this->config->disable();
$this->config->checkIsEnabled();
}
diff --git a/tests/PHPUnit/Unit/Report/ReportWidgetFactoryTest.php b/tests/PHPUnit/Unit/Report/ReportWidgetFactoryTest.php
index 3e1c17044a..339f66e696 100644
--- a/tests/PHPUnit/Unit/Report/ReportWidgetFactoryTest.php
+++ b/tests/PHPUnit/Unit/Report/ReportWidgetFactoryTest.php
@@ -49,7 +49,7 @@ class ReportWidgetFactoryTest extends \PHPUnit\Framework\TestCase
*/
private $factory;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/PHPUnit/Unit/Scheduler/Schedule/DailyTest.php b/tests/PHPUnit/Unit/Scheduler/Schedule/DailyTest.php
index 1528d1d908..7af354eb45 100644
--- a/tests/PHPUnit/Unit/Scheduler/Schedule/DailyTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/Schedule/DailyTest.php
@@ -23,7 +23,7 @@ class DailyTest extends \PHPUnit\Framework\TestCase
private static $_JANUARY_02_1971_00_00_00;
private static $_JANUARY_02_1971_09_00_00;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$_JANUARY_01_1971_09_00_00 = mktime(9, 00, 00, 1, 1, 1971);
@@ -38,14 +38,10 @@ class DailyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetHourScheduledTimeDailyNegative()
{
- try {
- $dailySchedule = Schedule::factory('daily');
- $dailySchedule->setHour(-1);
-
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $dailySchedule = Schedule::factory('daily');
+ $dailySchedule->setHour(-1);
}
/**
@@ -53,13 +49,10 @@ class DailyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetHourScheduledTimeDailyOver24()
{
- try {
- $dailySchedule = Schedule::factory('daily');
- $dailySchedule->setHour(25);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $dailySchedule = Schedule::factory('daily');
+ $dailySchedule->setHour(25);
}
/**
@@ -67,13 +60,10 @@ class DailyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetDayScheduledTimeDaily()
{
- try {
- $dailySchedule = Schedule::factory('daily');
- $dailySchedule->setDay(1);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $dailySchedule = Schedule::factory('daily');
+ $dailySchedule->setDay(1);
}
/**
@@ -167,7 +157,7 @@ class DailyTest extends \PHPUnit\Framework\TestCase
*/
private function getDailyMock($currentTime)
{
- $mock = $this->getMock('Piwik\Scheduler\Schedule\Daily', array('getTime'));
+ $mock = $this->createPartialMock('Piwik\Scheduler\Schedule\Daily', array('getTime'));
$mock->expects($this->any())
->method('getTime')
->will($this->returnValue($currentTime));
diff --git a/tests/PHPUnit/Unit/Scheduler/Schedule/HourlyTest.php b/tests/PHPUnit/Unit/Scheduler/Schedule/HourlyTest.php
index 1aea2973ea..dfaf39da64 100644
--- a/tests/PHPUnit/Unit/Scheduler/Schedule/HourlyTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/Schedule/HourlyTest.php
@@ -20,7 +20,7 @@ class HourlyTest extends \PHPUnit\Framework\TestCase
private static $_JANUARY_01_1971_09_10_00;
private static $_JANUARY_01_1971_10_00_00;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$_JANUARY_01_1971_09_00_00 = mktime(9, 00, 00, 1, 1, 1971);
@@ -34,13 +34,10 @@ class HourlyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetHourScheduledTimeHourly()
{
- try {
- $hourlySchedule = new Hourly();
- $hourlySchedule->setHour(0);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $hourlySchedule = new Hourly();
+ $hourlySchedule->setHour(0);
}
/**
@@ -49,13 +46,10 @@ class HourlyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetDayScheduledTimeHourly()
{
- try {
- $hourlySchedule = new Hourly();
- $hourlySchedule->setDay(1);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $hourlySchedule = new Hourly();
+ $hourlySchedule->setDay(1);
}
/**
@@ -73,7 +67,7 @@ class HourlyTest extends \PHPUnit\Framework\TestCase
* Expected :
* getRescheduledTime returns Friday January 1 1971 10:00:00 GMT
*/
- $mock = $this->getMock('Piwik\Scheduler\Schedule\Hourly', array('getTime'));
+ $mock = $this->createPartialMock('Piwik\Scheduler\Schedule\Hourly', array('getTime'));
$mock->expects($this->any())
->method('getTime')
->will($this->returnValue(self::$_JANUARY_01_1971_09_00_00));
@@ -88,7 +82,7 @@ class HourlyTest extends \PHPUnit\Framework\TestCase
* Expected :
* getRescheduledTime returns Friday January 1 1971 10:00:00 GMT
*/
- $mock = $this->getMock('Piwik\Scheduler\Schedule\Hourly', array('getTime'));
+ $mock = $this->createPartialMock('Piwik\Scheduler\Schedule\Hourly', array('getTime'));
$mock->expects($this->any())
->method('getTime')
->will($this->returnValue(self::$_JANUARY_01_1971_09_10_00));
diff --git a/tests/PHPUnit/Unit/Scheduler/Schedule/MonthlyTest.php b/tests/PHPUnit/Unit/Scheduler/Schedule/MonthlyTest.php
index c66065679c..cd90ebb002 100644
--- a/tests/PHPUnit/Unit/Scheduler/Schedule/MonthlyTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/Schedule/MonthlyTest.php
@@ -25,47 +25,51 @@ class MonthlyTest extends \PHPUnit\Framework\TestCase
public static $_FEBRUARY_21_1971_09_00_00;
public static $_FEBRUARY_28_1971_00_00_00;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
}
/**
* Tests invalid call to setHour on Monthly
- * @expectedException \Exception
*/
public function testSetHourScheduledTimeMonthlyNegative()
{
+ $this->expectException(\Exception::class);
+
$monthlySchedule = new Monthly();
$monthlySchedule->setHour(-1);
}
/**
* Tests invalid call to setHour on Monthly
- * @expectedException \Exception
*/
public function testSetHourScheduledTimMonthlyOver24()
{
+ $this->expectException(\Exception::class);
+
$monthlySchedule = new Monthly();
$monthlySchedule->setHour(25);
}
/**
* Tests invalid call to setDay on Monthly
- * @expectedException \Exception
*/
public function testSetDayScheduledTimeMonthlyDay0()
{
+ $this->expectException(\Exception::class);
+
$monthlySchedule = new Monthly();
$monthlySchedule->setDay(0);
}
/**
* Tests invalid call to setDay on Monthly
- * @expectedException \Exception
*/
public function testSetDayScheduledTimeMonthlyOver31()
{
+ $this->expectException(\Exception::class);
+
$monthlySchedule = new Monthly();
$monthlySchedule->setDay(32);
}
@@ -239,10 +243,11 @@ class MonthlyTest extends \PHPUnit\Framework\TestCase
* _Monthly
*
* @dataProvider getInvalidDayOfWeekData
- * @expectedException \Exception
*/
public function testMonthlyDayOfWeekInvalid($day, $week)
{
+ $this->expectException(\Exception::class);
+
$mock = $this->getMonthlyMock(self::$_JANUARY_15_1971_09_00_00);
$mock->setDayOfWeek($day, $week);
}
@@ -271,7 +276,7 @@ class MonthlyTest extends \PHPUnit\Framework\TestCase
*/
private function getMonthlyMock($currentTime)
{
- $mock = $this->getMock('Piwik\Scheduler\Schedule\Monthly', array('getTime'));
+ $mock = $this->createPartialMock('Piwik\Scheduler\Schedule\Monthly', array('getTime'));
$mock->expects($this->any())
->method('getTime')
->will($this->returnValue($currentTime));
diff --git a/tests/PHPUnit/Unit/Scheduler/Schedule/WeeklyTest.php b/tests/PHPUnit/Unit/Scheduler/Schedule/WeeklyTest.php
index b2c53dec3c..41f418fb51 100644
--- a/tests/PHPUnit/Unit/Scheduler/Schedule/WeeklyTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/Schedule/WeeklyTest.php
@@ -24,7 +24,7 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
public static $_JANUARY_15_1971_00_00_00;
public static $_JANUARY_08_1971_00_00_00;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
}
@@ -34,13 +34,10 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetHourScheduledTimeWeeklyNegative()
{
- try {
- $weeklySchedule = new Weekly();
- $weeklySchedule->setHour(-1);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $weeklySchedule = new Weekly();
+ $weeklySchedule->setHour(-1);
}
/**
@@ -48,13 +45,10 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetHourScheduledTimeWeeklyOver24()
{
- try {
- $weeklySchedule = new Weekly();
- $weeklySchedule->setHour(25);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $weeklySchedule = new Weekly();
+ $weeklySchedule->setHour(25);
}
/**
@@ -62,13 +56,10 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetDayScheduledTimeWeeklyDay0()
{
- try {
- $weeklySchedule = new Weekly();
- $weeklySchedule->setDay(0);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $weeklySchedule = new Weekly();
+ $weeklySchedule->setDay(0);
}
/**
@@ -76,13 +67,10 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
*/
public function testSetDayScheduledTimeWeeklyOver7()
{
- try {
- $weeklySchedule = new Weekly();
- $weeklySchedule->setDay(8);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised');
+ $this->expectException(Exception::class);
+
+ $weeklySchedule = new Weekly();
+ $weeklySchedule->setDay(8);
}
/**
@@ -182,7 +170,7 @@ class WeeklyTest extends \PHPUnit\Framework\TestCase
*/
private function getWeeklyMock($currentTime)
{
- $mock = $this->getMock('Piwik\Scheduler\Schedule\Weekly', array('getTime'));
+ $mock = $this->createPartialMock('Piwik\Scheduler\Schedule\Weekly', array('getTime'));
$mock->expects($this->any())
->method('getTime')
->will($this->returnValue($currentTime));
diff --git a/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php b/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
index 2db0dfaad6..76ebe1b37f 100644
--- a/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
@@ -51,7 +51,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
{
self::stubPiwikOption($timetable);
- $taskLoader = $this->getMock('Piwik\Scheduler\TaskLoader');
+ $taskLoader = $this->createMock('Piwik\Scheduler\TaskLoader');
$scheduler = new Scheduler($taskLoader, new NullLogger());
$this->assertEquals($expectedTime, $scheduler->getScheduledTimeForMethod($className, $methodName, $methodParameter));
@@ -84,7 +84,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
{
$now = time();
- $dailySchedule = $this->getMock('Piwik\Scheduler\Schedule\Daily', array('getTime'));
+ $dailySchedule = $this->createPartialMock('Piwik\Scheduler\Schedule\Daily', array('getTime'));
$dailySchedule->expects($this->any())
->method('getTime')
->will($this->returnValue($now));
@@ -171,7 +171,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
*/
public function testRun($expectedTimetable, $expectedExecutedTasks, $timetableBeforeTaskExecution, $configuredTasks)
{
- $taskLoader = $this->getMock('Piwik\Scheduler\TaskLoader');
+ $taskLoader = $this->createMock('Piwik\Scheduler\TaskLoader');
$taskLoader->expects($this->atLeastOnce())
->method('loadTasks')
->willReturn($configuredTasks);
@@ -204,7 +204,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
*/
public function testRunTaskNow($expectedTimetable, $expectedExecutedTasks, $timetableBeforeTaskExecution, $configuredTasks)
{
- $taskLoader = $this->getMock('Piwik\Scheduler\TaskLoader');
+ $taskLoader = $this->createMock('Piwik\Scheduler\TaskLoader');
$taskLoader->expects($this->atLeastOnce())
->method('loadTasks')
->willReturn($configuredTasks);
diff --git a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
index 853339671d..63b769a0ea 100644
--- a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
@@ -25,7 +25,7 @@ class TimetableTest extends \PHPUnit\Framework\TestCase
'PrivacyManager.deleteReportData_1' => 1322229607,
);
- public function tearDown()
+ public function tearDown(): void
{
self::resetPiwikOption();
}
diff --git a/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php b/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
index 3351d42b4b..3003f56716 100644
--- a/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
+++ b/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
@@ -136,14 +136,11 @@ class SegmentExpressionTest extends \PHPUnit\Framework\TestCase
*/
public function testBogusFiltersExpectExceptionThrown($bogus)
{
- try {
- $segment = new SegmentExpression($bogus);
- $segment->parseSubExpressions();
- $segment->getSql();
- } catch (\Exception $e) {
- return;
- }
- $this->fail('Expected exception not raised for:' . var_export($segment->getSql(), true));
+ $this->expectException(\Exception::class);
+
+ $segment = new SegmentExpression($bogus);
+ $segment->parseSubExpressions();
+ $segment->getSql();
}
/**
diff --git a/tests/PHPUnit/Unit/Session/SessionFingerprintTest.php b/tests/PHPUnit/Unit/Session/SessionFingerprintTest.php
index 0756f26952..62c50bd062 100644
--- a/tests/PHPUnit/Unit/Session/SessionFingerprintTest.php
+++ b/tests/PHPUnit/Unit/Session/SessionFingerprintTest.php
@@ -22,14 +22,14 @@ class SessionFingerprintTest extends \PHPUnit\Framework\TestCase
*/
private $testInstance;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->testInstance = new SessionFingerprint();
}
- public function tearDown()
+ public function tearDown(): void
{
Date::$now = null;
diff --git a/tests/PHPUnit/Unit/Session/SessionInitializerTest.php b/tests/PHPUnit/Unit/Session/SessionInitializerTest.php
index 87fe033126..b000437f4d 100644
--- a/tests/PHPUnit/Unit/Session/SessionInitializerTest.php
+++ b/tests/PHPUnit/Unit/Session/SessionInitializerTest.php
@@ -18,7 +18,7 @@ class SessionInitializerTest extends \PHPUnit\Framework\TestCase
{
private $oldUnitTestValue;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -26,27 +26,22 @@ class SessionInitializerTest extends \PHPUnit\Framework\TestCase
\Zend_Session::$_unitTestEnabled = true;
}
- public function tearDown()
+ public function tearDown(): void
{
\Zend_Session::$_unitTestEnabled = $this->oldUnitTestValue;
parent::tearDown();
}
- /**
- * @dataProvider getTestDataForInitSession
- * @expectedExceptionMessage Login_LoginPasswordNotCorrect
- */
- public function test_initSession_Throws_IfAuthenticationFailed($rememberMe)
+ public function test_initSession_Throws_IfAuthenticationFailed()
{
+ $this->expectExceptionMessage('Login_LoginPasswordNotCorrect');
+
$sessionInitializer = new TestSessionInitializer();
- $sessionInitializer->initSession($this->makeMockAuth(AuthResult::SUCCESS));
+ $sessionInitializer->initSession($this->makeMockAuth(AuthResult::FAILURE));
}
- /**
- * @dataProvider getTestDataForInitSession
- */
- public function test_initSession_InitializesTheSessionCorrectly_IfAuthenticationSucceeds($rememberMe)
+ public function test_initSession_InitializesTheSessionCorrectly_IfAuthenticationSucceeds()
{
$sessionInitializer = new TestSessionInitializer();
$sessionInitializer->initSession($this->makeMockAuth(AuthResult::SUCCESS));
@@ -54,14 +49,6 @@ class SessionInitializerTest extends \PHPUnit\Framework\TestCase
$this->assertSessionCreatedCorrectly();
}
- public function getTestDataForInitSession()
- {
- return [
- [true],
- [false],
- ];
- }
-
private function makeMockAuth($resultCode)
{
return new MockAuth($resultCode);
diff --git a/tests/PHPUnit/Unit/Tracker/RequestSetTest.php b/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
index da3b044eb4..be87334388 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
@@ -23,7 +23,7 @@ class RequestSetTest extends \PHPUnit\Framework\TestCase
private $requestSet;
private $time;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -209,7 +209,7 @@ class RequestSetTest extends \PHPUnit\Framework\TestCase
public function test_intertnalFakeEnvironment_shouldActuallyReturnAValue()
{
$myEnv = $this->getFakeEnvironment();
- $this->assertInternalType('array', $myEnv);
+ self::assertIsArray($myEnv);
$this->assertNotEmpty($myEnv);
}
diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php
index b5563f5bd1..365b4bc828 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php
@@ -29,7 +29,7 @@ class RequestTest extends UnitTestCase
private $request;
private $time;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -284,12 +284,11 @@ class RequestTest extends UnitTestCase
$this->assertEquals('05:20:17', $request->getLocalTime());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Requested parameter myCustomFaKeParaM is not a known Tracking API Parameter
- */
public function test_getParam_shouldThrowException_IfTryingToAccessInvalidParam()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Requested parameter myCustomFaKeParaM is not a known Tracking API Parameter');
+
$this->request->getParam('myCustomFaKeParaM');
}
@@ -433,7 +432,7 @@ class RequestTest extends UnitTestCase
private function assertCookieContains($needle, Cookie $cookie)
{
- $this->assertContains($needle, $cookie . '');
+ self::assertStringContainsString($needle, $cookie . '');
}
public function test_getLocalTime()
diff --git a/tests/PHPUnit/Unit/Tracker/ResponseTest.php b/tests/PHPUnit/Unit/Tracker/ResponseTest.php
index 22075008bd..c5583a49b9 100644
--- a/tests/PHPUnit/Unit/Tracker/ResponseTest.php
+++ b/tests/PHPUnit/Unit/Tracker/ResponseTest.php
@@ -40,7 +40,7 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
*/
private $response;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->response = new TestResponse();
@@ -65,8 +65,8 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
$content = $this->response->getOutput();
- $this->assertContains('<title>Matomo &rsaquo; Error</title>', $content);
- $this->assertContains('<p>My Custom Message', $content);
+ self::assertStringContainsString('<title>Matomo &rsaquo; Error</title>', $content);
+ self::assertStringContainsString('<p>My Custom Message', $content);
}
public function test_outputResponse_shouldOutputStandardApiResponse()
@@ -143,7 +143,7 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
public function test_getMessageFromException_ShouldReturnMessageAndTrace_InCaseIsCli()
{
$message = $this->response->getMessageFromException(new Exception('Test Message', 8150));
- $this->assertStringStartsWith("Test Message\n#0 [internal function]", $message);
+ $this->assertStringStartsWith("Test Message\n#0 ", $message);
}
public function test_getMessageFromException_ShouldOnlyReturnMessage_InCaseIsNotCli()
diff --git a/tests/PHPUnit/Unit/TrackerTest.php b/tests/PHPUnit/Unit/TrackerTest.php
index d0de76435d..1040f4f2dc 100644
--- a/tests/PHPUnit/Unit/TrackerTest.php
+++ b/tests/PHPUnit/Unit/TrackerTest.php
@@ -36,7 +36,7 @@ class TrackerTest extends \PHPUnit\Framework\TestCase
private $time;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -157,12 +157,11 @@ class TrackerTest extends \PHPUnit\Framework\TestCase
$this->assertFalse($this->handler->isOnException);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage My Exception During Process
- */
public function test_track_shouldNotCatchAnyException_IfExceptionWasThrown()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('My Exception During Process');
+
$this->handler->enableTriggerExceptionInProcess();
$this->tracker->track($this->handler, $this->requestSet);
}
diff --git a/tests/PHPUnit/Unit/Translation/Loader/LoaderCacheTest.php b/tests/PHPUnit/Unit/Translation/Loader/LoaderCacheTest.php
index 9fc4f43f5a..03350e6e87 100644
--- a/tests/PHPUnit/Unit/Translation/Loader/LoaderCacheTest.php
+++ b/tests/PHPUnit/Unit/Translation/Loader/LoaderCacheTest.php
@@ -19,7 +19,7 @@ class LoaderCacheTest extends \PHPUnit\Framework\TestCase
{
public function test_shouldNotLoad_ifInCache()
{
- $cache = $this->getMock('Matomo\Cache\Lazy', array(), array(), '', false);
+ $cache = $this->getMockBuilder('Matomo\Cache\Lazy')->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('fetch')
->willReturn(array('translations!'));
@@ -35,7 +35,7 @@ class LoaderCacheTest extends \PHPUnit\Framework\TestCase
public function test_shouldLoad_ifNotInCache()
{
- $cache = $this->getMock('Matomo\Cache\Lazy', array(), array(), '', false);
+ $cache = $this->getMockBuilder('Matomo\Cache\Lazy')->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('fetch')
->willReturn(null);
diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php
index e02b7edd28..8b5f47d60c 100644
--- a/tests/PHPUnit/Unit/UrlHelperTest.php
+++ b/tests/PHPUnit/Unit/UrlHelperTest.php
@@ -8,9 +8,7 @@
namespace Piwik\Tests\Unit;
-use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\UrlHelper;
-use Spyc;
class UrlHelperTest extends \PHPUnit\Framework\TestCase
{
diff --git a/tests/PHPUnit/Unit/Validator/CharacterLengthTest.php b/tests/PHPUnit/Unit/Validator/CharacterLengthTest.php
index 53842bdebc..6992d17d0b 100644
--- a/tests/PHPUnit/Unit/Validator/CharacterLengthTest.php
+++ b/tests/PHPUnit/Unit/Validator/CharacterLengthTest.php
@@ -24,32 +24,28 @@ class CharacterLengthTest extends \PHPUnit\Framework\TestCase
$this->validate('mytest', 6, 6);
$this->validate('', 0, 6);
$this->validate('testwewe', 0, 10);
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorCharacterTooShort
- */
public function test_validate_failValueIsTooShort()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorCharacterTooShort');
$this->validate('myte', 5);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorCharacterTooLong
- */
public function test_validate_failValueIsTooLong()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorCharacterTooLong');
$this->validate('mytestfoo', null, 4);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorCharacterTooLong
- */
public function test_validate_failValueIsTooNotInRange()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorCharacterTooLong');
$this->validate('mytestfoobar', 5, 8);
}
diff --git a/tests/PHPUnit/Unit/Validator/DateTimeTest.php b/tests/PHPUnit/Unit/Validator/DateTimeTest.php
index 6a56a02254..607cebf736 100644
--- a/tests/PHPUnit/Unit/Validator/DateTimeTest.php
+++ b/tests/PHPUnit/Unit/Validator/DateTimeTest.php
@@ -23,21 +23,25 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase
$this->validate('2014-05-06T10:13:14');
$this->validate('2014-05-06 10:13:14Z');
$this->validate('2014-05-06T10:13:14Z');
+
+ $this->assertTrue(true);
}
public function test_validate_successValueMayBeEmpty()
{
$this->validate(false);
$this->validate('');
+
+ $this->assertTrue(true);
}
/**
* @dataProvider getWrongFormat
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorInvalidDateTimeFormat
*/
public function test_validate_failInvalidFormat($date)
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorInvalidDateTimeFormat');
$this->validate($date);
}
@@ -56,12 +60,10 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase
);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ExceptionInvalidDateFormat
- */
public function test_validate_invalidDate()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ExceptionInvalidDateFormat');
$this->validate('2014-15-26 90:43:32');
}
diff --git a/tests/PHPUnit/Unit/Validator/EmailTest.php b/tests/PHPUnit/Unit/Validator/EmailTest.php
index d24d867d5c..3a5f701e79 100644
--- a/tests/PHPUnit/Unit/Validator/EmailTest.php
+++ b/tests/PHPUnit/Unit/Validator/EmailTest.php
@@ -37,11 +37,12 @@ class EmailTest extends \PHPUnit\Framework\TestCase
/**
* @dataProvider getFailedEmails
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage ValidatorErrorNotEmailLike
*/
public function test_validate_failValueIsNotValidEmail($email)
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('ValidatorErrorNotEmailLike');
+
$this->validate($email);
}
diff --git a/tests/PHPUnit/Unit/Validator/IpRangesTest.php b/tests/PHPUnit/Unit/Validator/IpRangesTest.php
index 92e05b51c3..6d7b244048 100644
--- a/tests/PHPUnit/Unit/Validator/IpRangesTest.php
+++ b/tests/PHPUnit/Unit/Validator/IpRangesTest.php
@@ -28,14 +28,14 @@ class IpRangesTest extends \PHPUnit\Framework\TestCase
$this->validate(false);
$this->validate('');
$this->validate(null);
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage SitesManager_ExceptionInvalidIPFormat
- */
public function test_validate_failNotValidIpRange()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('SitesManager_ExceptionInvalidIPFormat');
$this->validate(array('127.0.0.1', 'foo'));
}
diff --git a/tests/PHPUnit/Unit/Validator/NotEmptyTest.php b/tests/PHPUnit/Unit/Validator/NotEmptyTest.php
index 2722a4b929..188932bebf 100644
--- a/tests/PHPUnit/Unit/Validator/NotEmptyTest.php
+++ b/tests/PHPUnit/Unit/Validator/NotEmptyTest.php
@@ -27,11 +27,12 @@ class NotEmptyTest extends \PHPUnit\Framework\TestCase
/**
* @dataProvider getFailValues
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorEmptyValue
*/
public function test_validate_failValueIsEmpty($value)
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorEmptyValue');
+
$this->validate($value);
}
diff --git a/tests/PHPUnit/Unit/Validator/NumberRangeTest.php b/tests/PHPUnit/Unit/Validator/NumberRangeTest.php
index 3f596955c8..a906109771 100644
--- a/tests/PHPUnit/Unit/Validator/NumberRangeTest.php
+++ b/tests/PHPUnit/Unit/Validator/NumberRangeTest.php
@@ -29,50 +29,42 @@ class NumberRangeTest extends \PHPUnit\Framework\TestCase
$this->validate('5', 4);
$this->validate('5', null, '6');
$this->validate('-5', -10, '-4');
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorNumberTooLow
- */
public function test_validate_failValueIsTooLow()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorNumberTooLow');
$this->validate(3, 5);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorNumberTooHigh
- */
public function test_validate_failValueIsTooHigh()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorNumberTooHigh');
$this->validate(10, null, 8);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorNumberTooHigh
- */
public function test_validate_failValueIsTooNotInRange()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorNumberTooHigh');
$this->validate(10, 5, 8);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorNumberTooLow
- */
public function test_validate_failValueIsTooNotInRangeFloat()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorNumberTooLow');
$this->validate(5.43, 5.44, 8);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorNotANumber
- */
public function test_validate_failValueIsNotNumber()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorNotANumber');
$this->validate('foo');
}
diff --git a/tests/PHPUnit/Unit/Validator/UrlLikeTest.php b/tests/PHPUnit/Unit/Validator/UrlLikeTest.php
index c7ad364cac..76f8caf061 100644
--- a/tests/PHPUnit/Unit/Validator/UrlLikeTest.php
+++ b/tests/PHPUnit/Unit/Validator/UrlLikeTest.php
@@ -52,11 +52,12 @@ class UrlLikeTest extends \PHPUnit\Framework\TestCase
/**
* @dataProvider getFailedUrls
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage ValidatorErrorNotUrlLike
*/
public function test_validate_failValueIsNotUrlLike($url)
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('ValidatorErrorNotUrlLike');
+
$this->validate($url);
}
diff --git a/tests/PHPUnit/Unit/Validator/WhiteListedValueTest.php b/tests/PHPUnit/Unit/Validator/WhiteListedValueTest.php
index 860b24ef1d..b4ebdcf870 100644
--- a/tests/PHPUnit/Unit/Validator/WhiteListedValueTest.php
+++ b/tests/PHPUnit/Unit/Validator/WhiteListedValueTest.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Unit\Translation\Loader;
+namespace Piwik\Tests\Unit\Validator;
use Piwik\Validators\WhitelistedValue;
@@ -23,15 +23,17 @@ class WhiteListedValueTest extends \PHPUnit\Framework\TestCase
$this->validate('bar');
$this->validate('baz');
$this->validate('lorem');
+
+ $this->assertTrue(true);
}
/**
* @dataProvider getInvalidValues
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage General_ValidatorErrorXNotWhitelisted
*/
public function test_validate_failInvalidFormat($date)
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('General_ValidatorErrorXNotWhitelisted');
$this->validate($date);
}
@@ -46,12 +48,10 @@ class WhiteListedValueTest extends \PHPUnit\Framework\TestCase
);
}
- /**
- * @expectedException \Piwik\Validators\Exception
- * @expectedExceptionMessage The whitelisted values need to be an array
- */
public function test_construct_throwsExceptionIfParamIsNotAnArray()
{
+ $this->expectException(\Piwik\Validators\Exception::class);
+ $this->expectExceptionMessage('The whitelisted values need to be an array');
new WhitelistedValue('foobar');
}
diff --git a/tests/PHPUnit/Unit/VersionTest.php b/tests/PHPUnit/Unit/VersionTest.php
index 286f612cba..ebd791e7c0 100644
--- a/tests/PHPUnit/Unit/VersionTest.php
+++ b/tests/PHPUnit/Unit/VersionTest.php
@@ -17,7 +17,7 @@ class VersionTest extends \PHPUnit\Framework\TestCase
*/
private $version;
- public function setUp()
+ public function setUp(): void
{
$this->version = new Version();
}
diff --git a/tests/PHPUnit/Unit/Widget/WidgetConfigTest.php b/tests/PHPUnit/Unit/Widget/WidgetConfigTest.php
index 5549f3432c..9e8b441a41 100644
--- a/tests/PHPUnit/Unit/Widget/WidgetConfigTest.php
+++ b/tests/PHPUnit/Unit/Widget/WidgetConfigTest.php
@@ -22,7 +22,7 @@ class WidgetConfigTest extends \PHPUnit\Framework\TestCase
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->config = new WidgetConfig();
@@ -189,13 +189,14 @@ class WidgetConfigTest extends \PHPUnit\Framework\TestCase
{
$this->config->enable();
$this->config->checkIsEnabled();
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Exception
- */
public function test_checkIsEnabled_shouldThrowException_IfDisabled()
{
+ $this->expectException(\Exception::class);
+
$this->config->disable();
$this->config->checkIsEnabled();
}
diff --git a/tests/PHPUnit/Unit/Widget/WidgetContainerConfigTest.php b/tests/PHPUnit/Unit/Widget/WidgetContainerConfigTest.php
index 55c1ece71c..c74d402c64 100644
--- a/tests/PHPUnit/Unit/Widget/WidgetContainerConfigTest.php
+++ b/tests/PHPUnit/Unit/Widget/WidgetContainerConfigTest.php
@@ -25,7 +25,7 @@ class WidgetContainerConfigTest extends \PHPUnit\Framework\TestCase
private $id = 'MyTestContainer';
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->config = new WidgetContainerConfig();
@@ -216,13 +216,14 @@ class WidgetContainerConfigTest extends \PHPUnit\Framework\TestCase
{
$this->config->enable();
$this->config->checkIsEnabled();
+
+ $this->assertTrue(true);
}
- /**
- * @expectedException \Exception
- */
public function test_checkIsEnabled_shouldThrowException_IfDisabled()
{
+ $this->expectException(\Exception::class);
+
$this->config->disable();
$this->config->checkIsEnabled();
}
diff --git a/tests/PHPUnit/Unit/Widget/WidgetsListTest.php b/tests/PHPUnit/Unit/Widget/WidgetsListTest.php
index 09910a6b61..f2dc9bd3a6 100644
--- a/tests/PHPUnit/Unit/Widget/WidgetsListTest.php
+++ b/tests/PHPUnit/Unit/Widget/WidgetsListTest.php
@@ -24,7 +24,7 @@ class WidgetsListTest extends \PHPUnit\Framework\TestCase
*/
private $list;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
$this->list = new WidgetsList();
diff --git a/tests/PHPUnit/phpunit.xml.dist b/tests/PHPUnit/phpunit.xml.dist
index 7fc355465f..37c283e87f 100644
--- a/tests/PHPUnit/phpunit.xml.dist
+++ b/tests/PHPUnit/phpunit.xml.dist
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="bootstrap.php"
@@ -10,7 +10,6 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
- mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
index f5d58969d0..0e347b16e4 100644
--- a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Fixtures/SimpleFixtureTrackFewVisits.php
@@ -14,12 +14,12 @@ class SimpleFixtureTrackFewVisits extends Fixture
public $dateTime = '2013-01-23 01:23:45';
public $idSite = 1;
- public function setUp()
+ public function setUp(): void
{
$this->setUpWebsite();
}
- public function tearDown()
+ public function tearDown(): void
{
// empty
}
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php
index 3e9537b85a..a930a56798 100644
--- a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Integration/SystemSettingsTest.php
@@ -23,7 +23,7 @@ class SystemSettingsTest extends IntegrationTestCase
*/
private $settings;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php
index 20251d9326..00c6b06f7f 100644
--- a/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php
+++ b/tests/resources/custompluginsdir/CustomDirPlugin/tests/Unit/CustomClassTest.php
@@ -16,12 +16,12 @@ use Piwik\Plugins\CustomDirPlugin\CustomClass;
*/
class CustomClassTest 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
}