diff options
58 files changed, 141 insertions, 128 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a058ea81bf..315d4afa47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)* * The deprecated Platform API class `\Piwik\Registry` has been removed. Use `\Piwik\Container\StaticContainer` instead * The deprecated Platform API class `\Piwik\TaskScheduler` has been removed. Use `\Piwik\Scheduler\Scheduler` instead * The deprecated Platform API class `\Piwik\DeviceDetectorFactory` has been removed. Use `\Piwik\DeviceDetector\DeviceDetectorFactory` instead +* The deprecated Platform API class `\Piwik\Translate` has been removed. Use `\Piwik\Translation\Translator` instead. * The JavaScript tracker now uses `sendBeacon` by default if supported by the browser. You can disable this by calling the tracker method `disableAlwaysUseSendBeacon`. As a result, callback parameters won't work anymore and a tracking request might not appear in the developer tools. * The console option `--piwik-domain` has been removed. Use `--matomo-domain` instead * The core plugin `CustomPiwikJs` has been renamed to `CustomJsTracker` diff --git a/core/AssetManager.php b/core/AssetManager.php index 3581822a41..4e4628db39 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -139,7 +139,7 @@ class AssetManager extends Singleton */ public function getJsInclusionDirective() { - $result = "<script type=\"text/javascript\">\n" . Translate::getJavascriptTranslations() . "\n</script>"; + $result = "<script type=\"text/javascript\">\n" . StaticContainer::get('Piwik\Translation\Translator')->getJavascriptTranslations() . "\n</script>"; if ($this->isMergedAssetsDisabled()) { $this->getMergedCoreJSAsset()->delete(); diff --git a/core/CacheId.php b/core/CacheId.php index efc3857b1f..0119c458c6 100644 --- a/core/CacheId.php +++ b/core/CacheId.php @@ -8,13 +8,14 @@ */ namespace Piwik; +use Piwik\Container\StaticContainer; use Piwik\Plugin\Manager; class CacheId { public static function languageAware($cacheId) { - return $cacheId . '-' . Translate::getLanguageLoaded(); + return $cacheId . '-' . StaticContainer::get('Piwik\Translation\Translator')->getCurrentLanguage(); } public static function pluginAware($cacheId) diff --git a/core/Piwik.php b/core/Piwik.php index 285557ea47..32520ffec4 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -19,11 +19,6 @@ use Piwik\Plugins\UsersManager\API as APIUsersManager; use Piwik\Translation\Translator; /** - * @see core/Translate.php - */ -require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; - -/** * Main piwik helper class. * * Contains helper methods for a variety of common tasks. Plugin developers are diff --git a/core/Translate.php b/core/Translate.php index 73cd53c92e..84c46f38da 100644 --- a/core/Translate.php +++ b/core/Translate.php @@ -27,7 +27,8 @@ class Translate */ public static function clean($s) { - return html_entity_decode(trim($s), ENT_QUOTES, 'UTF-8'); + self::triggerDeprecationNotice(); + return self::getTranslator()->clean($s); } /** @@ -51,6 +52,7 @@ class Translate */ public static function reloadLanguage($language = false) { + self::triggerDeprecationNotice(); } /** @@ -61,6 +63,7 @@ class Translate */ public static function loadCoreTranslation($language = false) { + self::triggerDeprecationNotice(); self::getTranslator()->addDirectory(PIWIK_INCLUDE_PATH . '/lang'); } @@ -69,6 +72,7 @@ class Translate */ public static function mergeTranslationArray($translation) { + self::triggerDeprecationNotice(); } /** @@ -77,12 +81,14 @@ class Translate */ public static function getLanguageToLoad() { + self::triggerDeprecationNotice(); return self::getTranslator()->getCurrentLanguage(); } /** Reset the cached language to load. Used in tests. */ public static function reset() { + self::triggerDeprecationNotice(); self::getTranslator()->reset(); } @@ -92,11 +98,13 @@ class Translate */ public static function getLanguageLoaded() { + self::triggerDeprecationNotice(); return self::getTranslator()->getCurrentLanguage(); } public static function getLanguageDefault() { + self::triggerDeprecationNotice(); return self::getTranslator()->getDefaultLanguage(); } @@ -105,11 +113,13 @@ class Translate */ public static function getJavascriptTranslations() { + self::triggerDeprecationNotice(); return self::getTranslator()->getJavascriptTranslations(); } public static function findTranslationKeyForTranslation($translation) { + self::triggerDeprecationNotice(); return self::getTranslator()->findTranslationKeyForTranslation($translation); } @@ -123,7 +133,15 @@ class Translate public static function loadAllTranslations() { + self::triggerDeprecationNotice(); self::loadCoreTranslation(); Manager::getInstance()->loadPluginTranslations(); } + + protected static function triggerDeprecationNotice() + { + if (Development::isEnabled()) { + Log::warning('Using \Piwik\Translate is deprecated. Use \Piwik\Translation\Translator instead.'); + } + } } diff --git a/core/Translation/Translator.php b/core/Translation/Translator.php index 4d8f6932c6..e58998c803 100644 --- a/core/Translation/Translator.php +++ b/core/Translation/Translator.php @@ -61,6 +61,17 @@ class Translator } /** + * Clean a string that may contain HTML special chars, single/double quotes, HTML entities, leading/trailing whitespace + * + * @param string $s + * @return string + */ + public static function clean($s) + { + return html_entity_decode(trim($s), ENT_QUOTES, 'UTF-8'); + } + + /** * Returns an internationalized string using a translation ID. If a translation * cannot be found for the ID, the ID is returned. * diff --git a/core/Twig.php b/core/Twig.php index afb6a1cdc2..4a9200c691 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -240,7 +240,7 @@ class Twig { $getJavascriptTranslations = new Twig_SimpleFunction( 'getJavascriptTranslations', - array('Piwik\\Translate', 'getJavascriptTranslations') + array(StaticContainer::get('Piwik\Translation\Translator'), 'getJavascriptTranslations') ); $this->twig->addFunction($getJavascriptTranslations); } @@ -46,7 +46,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/SettingsPiwik.php'; require_once PIWIK_INCLUDE_PATH . '/core/SettingsServer.php'; require_once PIWIK_INCLUDE_PATH . '/core/Tracker.php'; require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Cache.php'; require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Request.php'; require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php'; diff --git a/plugins/Actions/tests/Unit/ArchiverTest.php b/plugins/Actions/tests/Unit/ArchiverTest.php index d0f7d42543..9c7cae8f7e 100644 --- a/plugins/Actions/tests/Unit/ArchiverTest.php +++ b/plugins/Actions/tests/Unit/ArchiverTest.php @@ -9,8 +9,8 @@ namespace Piwik\Plugins\Actions\tests\Unit; use Piwik\Plugins\Actions\ArchivingHelper; +use Piwik\Tests\Framework\Fixture; use Piwik\Tracker\Action; -use Piwik\Translate; require_once PIWIK_INCLUDE_PATH . '/plugins/Actions/Actions.php'; @@ -23,12 +23,12 @@ class ArchiverTests extends \PHPUnit\Framework\TestCase { public function setUp() { - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); } public function getActionNameTestData() diff --git a/plugins/Contents/tests/System/ContentsTest.php b/plugins/Contents/tests/System/ContentsTest.php index 06061fe605..363463b4da 100644 --- a/plugins/Contents/tests/System/ContentsTest.php +++ b/plugins/Contents/tests/System/ContentsTest.php @@ -7,9 +7,9 @@ */ namespace Piwik\Plugins\Contents\tests\System; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Plugins\Contents\tests\Fixtures\TwoVisitsWithContents; -use Piwik\Translate; /** * Testing Contents @@ -48,13 +48,13 @@ class ContentsTest extends SystemTestCase protected function setup() { parent::setup(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } protected function tearDown() { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } public function getApiForTesting() diff --git a/plugins/CoreConsole/Commands/GenerateReport.php b/plugins/CoreConsole/Commands/GenerateReport.php index a7e3af28d0..d9bad9f209 100644 --- a/plugins/CoreConsole/Commands/GenerateReport.php +++ b/plugins/CoreConsole/Commands/GenerateReport.php @@ -10,11 +10,10 @@ namespace Piwik\Plugins\CoreConsole\Commands; use Piwik\Columns\Dimension; +use Piwik\Container\StaticContainer; use Piwik\Piwik; use Piwik\Plugin\Manager; -use Piwik\Plugin\Report; use Piwik\Plugin\ReportsProvider; -use Piwik\Translate; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -210,7 +209,7 @@ class GenerateReport extends GeneratePluginBase $validate($category); } - $translationKey = Translate::findTranslationKeyForTranslation($category); + $translationKey = StaticContainer::get('Piwik\Translation\Translator')->findTranslationKeyForTranslation($category); if (!empty($translationKey)) { return $translationKey; } diff --git a/plugins/CoreConsole/Commands/GenerateWidget.php b/plugins/CoreConsole/Commands/GenerateWidget.php index 5968ea8a04..20624b3ba0 100644 --- a/plugins/CoreConsole/Commands/GenerateWidget.php +++ b/plugins/CoreConsole/Commands/GenerateWidget.php @@ -9,9 +9,9 @@ namespace Piwik\Plugins\CoreConsole\Commands; +use Piwik\Container\StaticContainer; use Piwik\Piwik; use Piwik\Plugin\Manager; -use Piwik\Translate; use Piwik\Widget\WidgetsList; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -125,7 +125,7 @@ class GenerateWidget extends GeneratePluginBase /** * @param InputInterface $input * @param OutputInterface $output - * @return array + * @return string * @throws \RuntimeException */ protected function getCategory(InputInterface $input, OutputInterface $output) @@ -148,7 +148,7 @@ class GenerateWidget extends GeneratePluginBase $validate($category); } - $translationKey = Translate::findTranslationKeyForTranslation($category); + $translationKey = StaticContainer::get('Piwik\Translation\Translator')->findTranslationKeyForTranslation($category); if (!empty($translationKey)) { return $translationKey; } @@ -161,7 +161,7 @@ class GenerateWidget extends GeneratePluginBase /** * @param InputInterface $input * @param OutputInterface $output - * @return array + * @return string * @throws \RuntimeException */ protected function getPluginName(InputInterface $input, OutputInterface $output) diff --git a/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php b/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php index 6847ac7b2c..5ab9f88296 100644 --- a/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php +++ b/plugins/CoreVisualizations/tests/Integration/SparklinesConfigTest.php @@ -12,7 +12,6 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines\Config; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group CoreVisualizations @@ -37,12 +36,12 @@ class SparklinesConfigTest extends IntegrationTestCase $this->config = new Config(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/plugins/CustomAlerts b/plugins/CustomAlerts -Subproject 3a785ec4bb71dcdeebca941bd76098b22299916 +Subproject 5633bb4bb70d1c3fd99bef6ecd7cb32b52f7a92 diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions -Subproject 16cda6608a317c283521b35bed014f8d1a2b22d +Subproject b410ab4d5c2e8e3f0a5236a887627f49198554e diff --git a/plugins/DeviceDetectorCache b/plugins/DeviceDetectorCache -Subproject e69f4eb28eec088fce7062bc4041f644f1a251a +Subproject 9564937792966a0df33ed03fd6035bbac81e4d4 diff --git a/plugins/Feedback/API.php b/plugins/Feedback/API.php index fdfe0adc43..de32971f16 100644 --- a/plugins/Feedback/API.php +++ b/plugins/Feedback/API.php @@ -9,10 +9,10 @@ namespace Piwik\Plugins\Feedback; use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\IP; use Piwik\Mail; use Piwik\Piwik; -use Piwik\Translate; use Piwik\Url; use Piwik\Version; @@ -80,11 +80,13 @@ class API extends \Piwik\Plugin\API private function getEnglishTranslationForFeatureName($featureName) { - if (Translate::getLanguageLoaded() == 'en') { + $translator = StaticContainer::get('Piwik\Translation\Translator'); + + if ($translator->getCurrentLanguage() == 'en') { return $featureName; } - $translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName); + $translationKeyForFeature = $translator->findTranslationKeyForTranslation($featureName); return Piwik::translate($translationKeyForFeature, array(), 'en'); } diff --git a/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php b/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php index 06b0cc1d2f..abf144ec40 100644 --- a/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php +++ b/plugins/GeoIp2/tests/System/ConvertRegionCodesToIsoTest.php @@ -14,7 +14,6 @@ use Piwik\Plugins\UserCountry\LocationProvider; use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -126,7 +125,7 @@ class ConvertRegionCodesToIsoTest extends IntegrationTestCase ); // we need to manually reload the translations since they get reset for some reason in IntegrationTestCase::tearDown(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->assertApiResponseEqualsExpected("UserCountry.getRegion", $queryParams); $this->assertApiResponseEqualsExpected("UserCountry.getCountry", $queryParams); diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php index e0e064a591..1fa00cca13 100644 --- a/plugins/ImageGraph/API.php +++ b/plugins/ImageGraph/API.php @@ -12,12 +12,12 @@ use Exception; use Piwik\API\Request; use Piwik\Archive\DataTableFactory; use Piwik\Common; +use Piwik\Container\StaticContainer; use Piwik\DataTable\Map; use Piwik\Filesystem; use Piwik\Period; use Piwik\Piwik; use Piwik\SettingsServer; -use Piwik\Translate; /** * The ImageGraph.get API call lets you generate beautiful static PNG Graphs for any existing Matomo report. @@ -139,7 +139,7 @@ class API extends \Piwik\Plugin\API $useUnicodeFont = array( 'am', 'ar', 'el', 'fa', 'fi', 'he', 'ja', 'ka', 'ko', 'te', 'th', 'zh-cn', 'zh-tw', ); - $languageLoaded = Translate::getLanguageLoaded(); + $languageLoaded = StaticContainer::get('Piwik\Translation\Translator')->getCurrentLanguage(); $font = self::getFontPath(self::DEFAULT_FONT); if (in_array($languageLoaded, $useUnicodeFont)) { $unicodeFontPath = self::getFontPath(self::UNICODE_FONT); diff --git a/plugins/Insights/tests/Integration/ApiTest.php b/plugins/Insights/tests/Integration/ApiTest.php index 5c3f616513..774a9e54c5 100644 --- a/plugins/Insights/tests/Integration/ApiTest.php +++ b/plugins/Insights/tests/Integration/ApiTest.php @@ -11,11 +11,10 @@ namespace Piwik\Plugins\Insights\tests\Integration; use Piwik\API\Request as ApiRequest; use Piwik\Cache as PiwikCache; use Piwik\DataTable; -use Piwik\DataTable\Row; use Piwik\Plugins\Insights\API; use Piwik\Plugins\Insights\tests\Fixtures\SomeVisitsDifferentPathsOnTwoDays; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; -use Piwik\Translate; /** * @group Insights @@ -42,7 +41,7 @@ class ApiTest extends SystemTestCase PiwikCache::flushAll(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->api = API::getInstance(); } @@ -50,7 +49,7 @@ class ApiTest extends SystemTestCase { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } /** diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index e24651d4b7..d38176377b 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -15,11 +15,9 @@ use Piwik\Common; use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\Cookie; -use Piwik\Db; use Piwik\Intl\Locale; use Piwik\Piwik; use Piwik\ProxyHttp; -use Piwik\Translate; use Piwik\Translation\Translator; use Piwik\View; @@ -156,7 +154,7 @@ class LanguagesManager extends \Piwik\Plugin $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages()); } if (!API::getInstance()->isLanguageAvailable($languageCode)) { - $languageCode = Translate::getLanguageDefault(); + $languageCode = StaticContainer::get('Piwik\Translation\Translator')->getDefaultLanguage(); } return $languageCode; } diff --git a/plugins/LanguagesManager/TranslationWriter/Filter/EncodedEntities.php b/plugins/LanguagesManager/TranslationWriter/Filter/EncodedEntities.php index dd1146f581..3e2c9dbb5b 100644 --- a/plugins/LanguagesManager/TranslationWriter/Filter/EncodedEntities.php +++ b/plugins/LanguagesManager/TranslationWriter/Filter/EncodedEntities.php @@ -9,7 +9,7 @@ namespace Piwik\Plugins\LanguagesManager\TranslationWriter\Filter; -use Piwik\Translate; +use Piwik\Container\StaticContainer; class EncodedEntities extends FilterAbstract { @@ -38,12 +38,12 @@ class EncodedEntities extends FilterAbstract foreach ($pluginTranslations as $key => $translation) { if (isset($this->baseTranslations[$pluginName][$key]) && - $this->baseTranslations[$pluginName][$key] != Translate::clean($this->baseTranslations[$pluginName][$key])) { + $this->baseTranslations[$pluginName][$key] != StaticContainer::get('Piwik\Translation\Translator')->clean($this->baseTranslations[$pluginName][$key])) { continue; // skip if base translation already contains encoded entities } // remove encoded entities - $decoded = Translate::clean($translation); + $decoded = StaticContainer::get('Piwik\Translation\Translator')->clean($translation); if ($translation != $decoded) { $this->filteredData[$pluginName][$key] = $translation; $translations[$pluginName][$key] = $decoded; diff --git a/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php b/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php index 4fb839a3d1..60501c6b49 100644 --- a/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php +++ b/plugins/LanguagesManager/tests/Integration/LanguagesManagerTest.php @@ -20,7 +20,7 @@ use Piwik\Plugins\LanguagesManager\TranslationWriter\Filter\UnnecassaryWhitespac use Piwik\Plugins\LanguagesManager\TranslationWriter\Validate\CoreTranslations; use Piwik\Plugins\LanguagesManager\TranslationWriter\Validate\NoScripts; use Piwik\Plugins\LanguagesManager\TranslationWriter\Writer; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; /** * @group LanguagesManager @@ -145,7 +145,7 @@ class LanguagesManagerTest extends \PHPUnit\Framework\TestCase Cache::flushAll(); $translator = StaticContainer::get('Piwik\Translation\Translator'); $translator->reset(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $translations = $translator->getAllTranslations(); foreach ($translations AS $plugin => $pluginTranslations) { foreach ($pluginTranslations as $key => $pluginTranslation) { @@ -166,7 +166,7 @@ class LanguagesManagerTest extends \PHPUnit\Framework\TestCase Cache::flushAll(); $translator = StaticContainer::get('Piwik\Translation\Translator'); $translator->reset(); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $translations = $translator->getAllTranslations(); foreach ($translations AS $plugin => $pluginTranslations) { if ($plugin == 'Intl') { diff --git a/plugins/LogViewer b/plugins/LogViewer -Subproject 689930e54b95baa34b4221a769ed1ebedb410d2 +Subproject 3eced789364b3762e8365805164c94d1255324a diff --git a/plugins/LoginLdap b/plugins/LoginLdap -Subproject 8c8e16cd01dcfc3363cbe43e135de60c6bc17f4 +Subproject 79c85ea17b40484454665d0a93e3dfd43fb2c63 diff --git a/plugins/MarketingCampaignsReporting b/plugins/MarketingCampaignsReporting -Subproject 6c8d9a33be10675d3d46632a0d185f18053ebb9 +Subproject 1ba5f4eb0169aaf0670f6ab3d4b1153b6114f31 diff --git a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php index 1d3203548b..1508ba67eb 100644 --- a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php +++ b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php @@ -14,9 +14,9 @@ use Piwik\Container\StaticContainer; use Piwik\Plugins\Marketplace\Consumer; use Piwik\Plugins\Marketplace\Plugins; use Piwik\Plugins\Marketplace\Plugins\InvalidLicenses; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; use Piwik\Plugins\Marketplace\tests\Framework\Mock\Consumer as ConsumerBuilder; -use Piwik\Translate; class CustomInvalidLicenses extends InvalidLicenses { private $isActivated = true; @@ -51,14 +51,14 @@ class InvalidLicensesTest extends IntegrationTestCase { parent::setUp(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); $this->cache = new Eager(new ArrayCache(), 'test'); } public function tearDown() { - Translate::unloadEnglishTranslation(); + Fixture::resetTranslations(); parent::tearDown(); } diff --git a/plugins/MultiSites/tests/Integration/DashboardTest.php b/plugins/MultiSites/tests/Integration/DashboardTest.php index 782d98e372..b892e230e2 100644 --- a/plugins/MultiSites/tests/Integration/DashboardTest.php +++ b/plugins/MultiSites/tests/Integration/DashboardTest.php @@ -13,7 +13,6 @@ use Piwik\Period; use Piwik\Plugins\MultiSites\Dashboard; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; /** * @group MultiSites @@ -38,7 +37,7 @@ class DashboardTest extends IntegrationTestCase Fixture::createWebsite('2012-12-12 00:00:00', $ecommerce = 0, 'Site ' . $i); } - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->dashboard = $this->getMockBuilder('Piwik\Plugins\MultiSites\Dashboard') ->setMethods(null) diff --git a/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php b/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php index c5b50bdd1d..56a4b251b5 100644 --- a/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php +++ b/plugins/PrivacyManager/tests/Integration/Dao/LogDataAnonymizerTest.php @@ -16,9 +16,9 @@ use Piwik\Plugins\PrivacyManager\API; use Piwik\Plugins\PrivacyManager\Dao\LogDataAnonymizer; use Piwik\Plugins\PrivacyManager\PrivacyManager; use Piwik\Plugins\PrivacyManager\tests\Fixtures\MultipleSitesMultipleVisitsFixture; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; use Piwik\Tracker\Cache; -use Piwik\Translate; /** * Class LogDataAnonymizationsTest @@ -42,7 +42,7 @@ class LogDataAnonymizerTest extends IntegrationTestCase Option::set(PrivacyManager::OPTION_USERID_SALT, 'simpleuseridsalt1'); Cache::clearCacheGeneral(); - Translate::loadEnglishTranslation(); + Fixture::loadAllTranslations(); $this->anonymizer = new LogDataAnonymizer(); $this->theFixture = new MultipleSitesMultipleVisitsFixture(); diff --git a/plugins/Provider b/plugins/Provider -Subproject 597b20133c351b142cb5d57acdcf719e6bdd226 +Subproject 65ad2d63ab289ca3dc032a3e4dc4d28c35582cc diff --git a/plugins/QueuedTracking b/plugins/QueuedTracking -Subproject 0ac5129edc1cde7e5c379c75615f9d4068ec384 +Subproject 58a0d80f275d3f413ba25d0a5a6ec8856273346 diff --git a/plugins/ScheduledReports/API.php b/plugins/ScheduledReports/API.php index 3143bcd294..bbc800fd20 100644 --- a/plugins/ScheduledReports/API.php +++ b/plugins/ScheduledReports/API.php @@ -30,7 +30,6 @@ use Piwik\Plugins\SitesManager\API as SitesManagerApi; use Piwik\ReportRenderer; use Piwik\Scheduler\Schedule\Schedule; use Piwik\Site; -use Piwik\Translate; use Piwik\Translation\Translator; use Psr\Log\LoggerInterface; @@ -323,13 +322,14 @@ class API extends \Piwik\Plugin\API $outputType = self::OUTPUT_DOWNLOAD; } + /** @var Translator $translator */ + $translator = StaticContainer::get('Piwik\Translation\Translator'); + // load specified language if (empty($language)) { - $language = Translate::getLanguageDefault(); + $language = $translator->getDefaultLanguage(); } - /** @var Translator $translator */ - $translator = StaticContainer::get('Piwik\Translation\Translator'); $translator->setCurrentLanguage($language); $reports = $this->getReports($idSite = false, $_period = false, $idReport); diff --git a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php index 9d314fd930..8d03a23c38 100644 --- a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php +++ b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php @@ -12,8 +12,6 @@ use Piwik\Plugins\SegmentEditor\SegmentFormatter; use Piwik\Plugins\SegmentEditor\SegmentList; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; -use Exception; /** * @group SegmentFormatterTest @@ -37,12 +35,12 @@ class SegmentFormatterTest extends IntegrationTestCase $this->idSite = Fixture::createWebsite('2012-01-01 00:00:00'); $this->formatter = new SegmentFormatter(new SegmentList()); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); } public function tearDown() { - Translate::reset(); + Fixture::resetTranslations(); } public function test_getHumanReadable_noSegmentGiven_ShouldReturnDefaultSegment() diff --git a/plugins/SitesManager/tests/Integration/ApiTest.php b/plugins/SitesManager/tests/Integration/ApiTest.php index 2f178434fa..90493fb7cf 100644 --- a/plugins/SitesManager/tests/Integration/ApiTest.php +++ b/plugins/SitesManager/tests/Integration/ApiTest.php @@ -18,9 +18,9 @@ use Piwik\Plugins\SitesManager\Model; use Piwik\Plugins\UsersManager\API as APIUsersManager; use Piwik\Measurable\Measurable; use Piwik\Site; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; use Exception; use PHPUnit_Framework_Constraint_IsType; @@ -47,7 +47,7 @@ class ApiTest extends IntegrationTestCase { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } /** @@ -558,7 +558,7 @@ class ApiTest extends IntegrationTestCase API::getInstance()->addSite("site2", array("http://piwik.com/test/")); API::getInstance()->addSite("site3", array("http://piwik.org"), null, null, null, null, null, null, 'Asia/Tokyo'); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $resultWanted = array( 0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 0, "excluded_ips" => "", 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'timezone_name' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0, 'type' => 'website', 'exclude_unknown_urls' => 0, 'currency_name' => 'US Dollar'), diff --git a/plugins/SitesManager/tests/Unit/APITest.php b/plugins/SitesManager/tests/Unit/APITest.php index 30f6a3497d..564bc977ec 100644 --- a/plugins/SitesManager/tests/Unit/APITest.php +++ b/plugins/SitesManager/tests/Unit/APITest.php @@ -11,7 +11,7 @@ namespace Piwik\Plugins\SitesManager\tests\Unit; use Piwik\Container\StaticContainer; use Piwik\Plugins\SitesManager\API; use Piwik\SettingsServer; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; /** * @group SitesManaager @@ -33,7 +33,7 @@ class APITest extends \PHPUnit\Framework\TestCase $this->markTestSkipped('timezones needs to be supported'); } - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->api = API::getInstance(); } @@ -42,7 +42,7 @@ class APITest extends \PHPUnit\Framework\TestCase { parent::tearDown(); - Translate::reset(); + Fixture::resetTranslations(); } public function getTimezoneNameTestData() diff --git a/plugins/TagManager b/plugins/TagManager -Subproject 6ba750183db9ca2e3ea64751dee592c6f7b7afa +Subproject 935593de7f19e908024cd13ee4f561ca96be1db diff --git a/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php b/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php index 6e3d7060f8..e039502239 100644 --- a/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php +++ b/plugins/UserCountry/tests/System/AttributeHistoricalDataWithLocationsTest.php @@ -10,11 +10,10 @@ namespace Piwik\Plugins\UserCountry\tests\System; use Piwik\Common; use Piwik\Db; -use Piwik\Plugin; use Piwik\Plugins\UserCountry\Commands\AttributeHistoricalDataWithLocations; use Piwik\Tests\Fixtures\ManyVisitsWithGeoIP; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Translate; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -109,7 +108,7 @@ class AttributeHistoricalDataWithLocationsTest extends IntegrationTestCase // if we do not load translations, a DataTable\Map containing multiple periods will contain only one DataTable having // the label `General_DateRangeFromTo` instead of many like `From 2010-01-04 to 2010-01-11`, ' `From 2010-01-11 to 2010-01-18` // As those data tables would all have the same prettyfied period label they would overwrite each other. - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); $this->assertApiResponseEqualsExpected("UserCountry.getCountry", $queryParams); $this->assertApiResponseEqualsExpected("UserCountry.getContinent", $queryParams); diff --git a/plugins/UserCountry/tests/Unit/UserCountryTest.php b/plugins/UserCountry/tests/Unit/UserCountryTest.php index ecae4a28cd..b28c5fc9d1 100644 --- a/plugins/UserCountry/tests/Unit/UserCountryTest.php +++ b/plugins/UserCountry/tests/Unit/UserCountryTest.php @@ -12,9 +12,9 @@ use Piwik\Container\StaticContainer; use Piwik\Intl\Data\Provider\RegionDataProvider; use Piwik\Plugins\UserCountry\GeoIPAutoUpdater; use Piwik\Plugins\UserCountry\LocationProvider\GeoIp; -use Piwik\Plugins\UserCountry; use Piwik\Plugins\UserCountry\LocationProvider; use Exception; +use Piwik\Tests\Framework\Fixture; require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/UserCountry.php'; require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php'; @@ -110,7 +110,7 @@ class UserCountryTest extends \PHPUnit\Framework\TestCase public function testGeoIpDownloadInvalidUrl($url) { // unset translations, otherwise Exception message will be translated - StaticContainer::get('Piwik\Translation\Translator')->reset(); + Fixture::resetTranslations(); $updater = new Piwik_UserCountry_GeoIPAutoUpdater_publictest(); try { diff --git a/plugins/VisitorGenerator b/plugins/VisitorGenerator -Subproject 2f671813cd59b9d89745f6157ae71e84496a8ea +Subproject 055f3fd695ba386c8de871a849ffd90ba4cb528 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 |