diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-02-20 15:44:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 15:44:10 +0300 |
commit | fa23dc76e4ed1ba729a45d51da76edf7c0202eec (patch) | |
tree | 5ae8bb1d47f953cac06b3963526b292abb903dd0 /tests | |
parent | 361bc551294d313631a3c61e07ddf65b97e72041 (diff) |
Removes deprecated class Piwik\Translate (#15586)
* Removes deprecated class Piwik\Translate
* use submodule branches
* adjust test
* fix typo
* readd deprecated Piwik\Translate
* submodule updates
Diffstat (limited to 'tests')
19 files changed, 52 insertions, 56 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index 7172779871..6f9a54ed7c 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -29,10 +29,8 @@ use Matomo\Ini\IniReader; use Piwik\Log; use Piwik\NumberFormatter; use Piwik\Option; -use Piwik\Piwik; use Piwik\Plugin; use Piwik\Plugin\Manager; -use Piwik\Plugins\API\ProcessedReport; use Piwik\Plugins\LanguagesManager\API as APILanguagesManager; use Piwik\Plugins\MobileMessaging\MobileMessaging; use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker; @@ -48,11 +46,11 @@ use Piwik\SettingsPiwik; use Piwik\SettingsServer; use Piwik\Singleton; use Piwik\Site; +use Piwik\Tests; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tracker; use Piwik\Tracker\Cache; -use Piwik\Translate; use MatomoTracker; use Matomo_LocalTracker; use Piwik\Updater; @@ -401,12 +399,23 @@ class Fixture extends \PHPUnit_Framework_Assert Plugin\API::unsetAllInstances(); $_GET = $_REQUEST = array(); - Translate::reset(); + self::resetTranslations(); self::getConfig()->Plugins; // make sure Plugins exists in a config object for next tests that use Plugin\Manager // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object } + public static function resetTranslations() + { + StaticContainer::get('Piwik\Translation\Translator')->reset(); + } + + public static function loadAllTranslations() + { + StaticContainer::get('Piwik\Translation\Translator')->addDirectory(PIWIK_INCLUDE_PATH . '/lang'); + Manager::getInstance()->loadPluginTranslations(); + } + protected static function resetPluginsInstalledConfig() { $config = self::getConfig(); diff --git a/tests/PHPUnit/Integration/CacheIdTest.php b/tests/PHPUnit/Integration/CacheIdTest.php index 3795005148..77d150b2d6 100644 --- a/tests/PHPUnit/Integration/CacheIdTest.php +++ b/tests/PHPUnit/Integration/CacheIdTest.php @@ -9,8 +9,8 @@ namespace Piwik\Tests\Integration; use Piwik\CacheId; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group Cache @@ -20,12 +20,12 @@ class CacheIdTest extends IntegrationTestCase { public function setUp() { - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); } public function test_languageAware_shouldAppendTheLoadedLanguage() diff --git a/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php index d83a6f5c9e..8c662fdb33 100644 --- a/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php +++ b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php @@ -11,8 +11,8 @@ namespace Piwik\Tests\Integration\Columns; use Piwik\Columns\ComputedMetricFactory; use Piwik\Columns\MetricsList; use Piwik\Plugin\ComputedMetric; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group Core @@ -28,14 +28,14 @@ class ComputedMetricFactoryTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); $this->factory = new ComputedMetricFactory(MetricsList::get()); } public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php index 0957d64350..d4c4d754e2 100644 --- a/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php +++ b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php @@ -8,15 +8,13 @@ namespace Piwik\Tests\Integration\Columns; -use Piwik\Columns\ComputedMetricFactory; use Piwik\Columns\Dimension; use Piwik\Columns\DimensionMetricFactory; -use Piwik\Columns\MetricsList; use Piwik\Plugin\ArchivedMetric; use Piwik\Plugin\ComputedMetric; use Piwik\Plugins\UserCountry\Columns\Country; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group Core @@ -30,14 +28,14 @@ class DimensionMetricFactoryTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); $this->country = new Country(); } public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/Columns/DimensionTest.php b/tests/PHPUnit/Integration/Columns/DimensionTest.php index c18c9f66fc..6f3e64464c 100644 --- a/tests/PHPUnit/Integration/Columns/DimensionTest.php +++ b/tests/PHPUnit/Integration/Columns/DimensionTest.php @@ -19,7 +19,6 @@ use Piwik\Plugin\Dimension\VisitDimension; use Piwik\Plugin\Manager; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; class CustomDimensionTest extends Dimension { @@ -84,7 +83,7 @@ class ColumnDimensionTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); Fixture::createWebsite('2014-04-05 01:02:03'); @@ -96,7 +95,7 @@ class ColumnDimensionTest extends IntegrationTestCase public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php index 4e72693de4..6d1d5b6eba 100644 --- a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php +++ b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php @@ -9,6 +9,7 @@ namespace Piwik\Tests\Core\DataTable\Filter; use Piwik\API\Proxy; use Piwik\Plugins\CustomVariables\CustomVariables; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; use Piwik\Tracker\Cache; use Piwik\DataTable; @@ -16,7 +17,6 @@ use Piwik\DataTable\Filter\PivotByDimension; use Piwik\DataTable\Row; use Piwik\Plugin\Manager as PluginManager; use Exception; -use Piwik\Translate; /** * @group DataTableTest @@ -43,7 +43,7 @@ class PivotByDimensionTest extends IntegrationTestCase { parent::setUp(); - Translate::reset(); + Fixture::resetTranslations(); Cache::clearCacheGeneral(); \Piwik\Cache::flushAll(); diff --git a/tests/PHPUnit/Integration/FrontControllerTest.php b/tests/PHPUnit/Integration/FrontControllerTest.php index e869c71c8c..a0417c3c43 100644 --- a/tests/PHPUnit/Integration/FrontControllerTest.php +++ b/tests/PHPUnit/Integration/FrontControllerTest.php @@ -48,7 +48,7 @@ FORMAT; $this->assertEquals('error', $response['result']); $expectedFormat = <<<FORMAT -test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(761): Piwik\EventDispatcher->postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(569): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(165): Piwik\FrontController->doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController->dispatch('CoreHome', 'index') #6 {main} +test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(756): Piwik\EventDispatcher->postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(569): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(165): Piwik\FrontController->doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController->dispatch('CoreHome', 'index') #6 {main} FORMAT; $this->assertStringMatchesFormat($expectedFormat, $response['message']); diff --git a/tests/PHPUnit/Integration/PiwikTest.php b/tests/PHPUnit/Integration/PiwikTest.php index d2cfc13543..36564c2501 100644 --- a/tests/PHPUnit/Integration/PiwikTest.php +++ b/tests/PHPUnit/Integration/PiwikTest.php @@ -11,8 +11,6 @@ namespace Piwik\Tests\Integration; use Piwik\Access; use Piwik\AuthResult; use Piwik\Piwik; -use Piwik\Plugins\SitesManager\API; -use Piwik\Translate; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; /** diff --git a/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php index 179419dd50..570a56bcaa 100644 --- a/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php +++ b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php @@ -12,13 +12,10 @@ use Piwik\Columns\Dimension; use Piwik\DataTable; use Piwik\Metrics\Formatter; use Piwik\Plugin\ArchivedMetric; -use Piwik\Plugin\ComputedMetric; -use Piwik\Plugins\UserCountry\Columns\City; use Piwik\Plugins\UserCountry\Columns\Country; use Piwik\Site; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group ArchivedMetric @@ -40,7 +37,7 @@ class ArchivedMetricTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); Fixture::createWebsite('2015-01-01 00:00:00'); @@ -50,7 +47,7 @@ class ArchivedMetricTest extends IntegrationTestCase public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php index 59862bc14f..0d79512d02 100644 --- a/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php +++ b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php @@ -15,7 +15,6 @@ use Piwik\Plugin\ComputedMetric; use Piwik\Site; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group ComputedMetric @@ -27,14 +26,14 @@ class ComputedMetricTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); Fixture::createWebsite('2015-01-01 00:00:00'); } public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/ReportTest.php b/tests/PHPUnit/Integration/ReportTest.php index a8dd543478..eeab859fd6 100644 --- a/tests/PHPUnit/Integration/ReportTest.php +++ b/tests/PHPUnit/Integration/ReportTest.php @@ -19,7 +19,6 @@ use Piwik\Plugins\ExampleTracker\Columns\ExampleDimension; use Piwik\Plugins\Referrers\Columns\Keyword; use Piwik\Plugin\ReportsProvider; use Piwik\Report\ReportWidgetFactory; -use Piwik\Translate; use Piwik\Plugin\Manager as PluginManager; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; @@ -154,9 +153,9 @@ class ReportTest extends IntegrationTestCase public function test_getCategory_shouldReturnTranslatedCategory() { - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->assertEquals('Goals_Goals', $this->advancedReport->getCategoryId()); - Translate::reset(); + Fixture::resetTranslations(); } public function test_getMetrics_shouldUseDefaultMetrics() diff --git a/tests/PHPUnit/Integration/Tracker/ActionTest.php b/tests/PHPUnit/Integration/Tracker/ActionTest.php index ad2bfbd06f..ee071b2467 100644 --- a/tests/PHPUnit/Integration/Tracker/ActionTest.php +++ b/tests/PHPUnit/Integration/Tracker/ActionTest.php @@ -10,11 +10,11 @@ namespace Piwik\Tests\Integration\Tracker; use Piwik\Config; use Piwik\Plugins\SitesManager\API; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tracker\Action; use Piwik\Tracker\PageUrl; use Piwik\Tracker\Request; -use Piwik\Translate; use Piwik\Plugin\Manager as PluginManager; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; @@ -37,14 +37,14 @@ class ActionTest extends IntegrationTestCase PluginManager::getInstance()->loadPlugins(array('SitesManager')); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } protected function setUpRootAccess() diff --git a/tests/PHPUnit/Integration/TravisEnvironmentTest.php b/tests/PHPUnit/Integration/TravisEnvironmentTest.php index 0c3001e2e5..023b2aadd2 100644 --- a/tests/PHPUnit/Integration/TravisEnvironmentTest.php +++ b/tests/PHPUnit/Integration/TravisEnvironmentTest.php @@ -9,7 +9,6 @@ namespace Piwik\Tests\Integration; use Piwik\Db; -use Piwik\Translate; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; /** diff --git a/tests/PHPUnit/Integration/WidgetsListTest.php b/tests/PHPUnit/Integration/WidgetsListTest.php index 1cc5cae17c..5e643d1f81 100644 --- a/tests/PHPUnit/Integration/WidgetsListTest.php +++ b/tests/PHPUnit/Integration/WidgetsListTest.php @@ -10,7 +10,6 @@ namespace Piwik\Tests\Integration; use Piwik\Widget\WidgetConfig; use Piwik\Plugins\Goals\API; -use Piwik\Translate; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Widget\WidgetsList; use Piwik\Tests\Framework\Fixture; @@ -152,7 +151,7 @@ class WidgetsListTest extends IntegrationTestCase public function testIsDefined() { - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); Fixture::createWebsite('2009-01-04 00:11:42', true); @@ -169,7 +168,7 @@ class WidgetsListTest extends IntegrationTestCase $this->assertTrue($list->isDefined('Actions', 'getPageUrls')); $this->assertFalse($list->isDefined('Actions', 'inValiD')); - Translate::reset(); + Fixture::resetTranslations(); } public function provideContainerConfig() diff --git a/tests/PHPUnit/Unit/DateTest.php b/tests/PHPUnit/Unit/DateTest.php index 450b0f11af..3cc586d3e0 100644 --- a/tests/PHPUnit/Unit/DateTest.php +++ b/tests/PHPUnit/Unit/DateTest.php @@ -12,7 +12,7 @@ use Exception; use Piwik\Container\StaticContainer; use Piwik\Date; use Piwik\SettingsServer; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; /** */ @@ -404,14 +404,14 @@ class DateTest extends \PHPUnit\Framework\TestCase */ public function testGetLocalizedTimeFormats($language, $use12HourClock, $time, $shouldBe) { - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); StaticContainer::get('Piwik\Translation\Translator')->setCurrentLanguage($language); StaticContainer::get('Piwik\Intl\Data\Provider\DateTimeFormatProvider')->forceTimeFormat($use12HourClock); $date = Date::factory($time); $this->assertEquals($shouldBe, $date->getLocalized(Date::TIME_FORMAT)); - Translate::reset(); + Fixture::resetTranslations(); } /** diff --git a/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php b/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php index d8bb35a856..387ea4bbd3 100644 --- a/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php +++ b/tests/PHPUnit/Unit/Metrics/Formatter/HtmlTest.php @@ -9,8 +9,7 @@ namespace Piwik\Tests\Unit\Metrics\Formatter; use Piwik\Container\StaticContainer; use Piwik\Metrics\Formatter\Html; -use Piwik\NumberFormatter; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; use Piwik\Plugins\SitesManager\API as SitesManagerAPI; /** @@ -36,13 +35,13 @@ class HtmlTest extends \PHPUnit\Framework\TestCase $this->formatter = new Html(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->setSiteManagerApiMock(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); $this->unsetSiteManagerApiMock(); } diff --git a/tests/PHPUnit/Unit/Metrics/FormatterTest.php b/tests/PHPUnit/Unit/Metrics/FormatterTest.php index 30e6128a1a..adf5b5ab96 100644 --- a/tests/PHPUnit/Unit/Metrics/FormatterTest.php +++ b/tests/PHPUnit/Unit/Metrics/FormatterTest.php @@ -10,7 +10,7 @@ namespace Piwik\Tests\Unit\Metrics; use Piwik\Container\StaticContainer; use Piwik\Metrics\Formatter; use Piwik\NumberFormatter; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; use Piwik\Plugins\SitesManager\API as SitesManagerAPI; /** @@ -52,13 +52,13 @@ class FormatterTest extends \PHPUnit\Framework\TestCase $this->formatter = new Formatter(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->setSiteManagerApiMock(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); NumberFormatter::getInstance()->clearCache(); $this->unsetSiteManagerApiMock(); } diff --git a/tests/PHPUnit/Unit/Period/BasePeriodTest.php b/tests/PHPUnit/Unit/Period/BasePeriodTest.php index ff0c7ee9bc..d1834b0f42 100644 --- a/tests/PHPUnit/Unit/Period/BasePeriodTest.php +++ b/tests/PHPUnit/Unit/Period/BasePeriodTest.php @@ -8,7 +8,7 @@ namespace Piwik\Tests\Unit\Period; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; abstract class BasePeriodTest extends \PHPUnit\Framework\TestCase { @@ -16,13 +16,13 @@ abstract class BasePeriodTest extends \PHPUnit\Framework\TestCase { parent::setUp(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } }
\ No newline at end of file diff --git a/tests/PHPUnit/Unit/TranslateTest.php b/tests/PHPUnit/Unit/TranslateTest.php index e5002b52b6..0d282b3b64 100644 --- a/tests/PHPUnit/Unit/TranslateTest.php +++ b/tests/PHPUnit/Unit/TranslateTest.php @@ -8,7 +8,7 @@ namespace Piwik\Tests\Unit; -use Piwik\Translate; +use Piwik\Container\StaticContainer; /** * @group Translation @@ -42,6 +42,6 @@ class TranslateTest extends \PHPUnit\Framework\TestCase */ public function testClean($data, $expected) { - $this->assertEquals($expected, Translate::clean($data)); + $this->assertEquals($expected, StaticContainer::get('Piwik\Translation\Translator')->clean($data)); } }
\ No newline at end of file |