/** * @dataProvider getPrettyNumberLocaleTestData */ public function test_getPrettyNumber_ReturnsCorrectResult_WhenLocaleIsEuropean($number, $expected) { $locale = setlocale(LC_ALL, array('de', 'de_DE', 'ge', 'de_DE.utf8')); if (empty($locale)) { $this->markTestSkipped("de_DE locale is not present on this system"); } $this->assertEquals($expected, $this->formatter->getPrettyNumber($number, 2)); Locale::setDefaultLocale(); }
$vars = new TestingEnvironmentVariables(); $vars->delete(); Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator($vars)); $rootTestEnvironment = new \Piwik\Application\Environment(null); $rootTestEnvironment->init(); } setupRootContainer(); // do it in a function so it doesn't appear in $_GLOBALS and so PHPUnit won't try to serialize it. // require test fixtures $fixturesToLoad = array('/tests/UI/Fixtures/*.php', '/plugins/*/tests/Fixtures/*.php', '/plugins/*/Test/Fixtures/*.php'); foreach ($fixturesToLoad as $fixturePath) { foreach (glob(PIWIK_INCLUDE_PATH . $fixturePath) as $file) { require_once $file; } } Locale::setDefaultLocale(); function prepareServerVariables(Config $config) { $testConfig = $config->tests; if ('@REQUEST_URI@' === $testConfig['request_uri']) { // config not done yet, if Piwik is installed we can automatically configure request_uri and http_host $url = \Piwik\SettingsPiwik::getPiwikUrl(); if (!empty($url)) { $parsedUrl = parse_url($url); $testConfig['request_uri'] = $parsedUrl['path']; $testConfig['http_host'] = $parsedUrl['host']; $config->tests = $testConfig; $config->forceSave(); } } $_SERVER['HTTP_HOST'] = $testConfig['http_host'];