configFileGlobal = null; $testingEnvironment->configFileLocal = null; $testingEnvironment->configFileCommon = null; $testingEnvironment->loadRealTranslations = true; $testingEnvironment->save(); } /** * @dataProvider getEntryPointsToTest */ public function test_NoGlobalConfigFile_TriggersError($entryPoint) { $this->simulateAbsentConfigFile('global.ini.php'); $output = $this->triggerPiwikFrom($entryPoint); $this->assertOutputContainsConfigFileMissingError('global.ini.php', $output); } public function test_NoLocalConfigFile_TriggersError_inTracker() { $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); } public function test_NoLocalConfigFile_TriggersError_inConsole() { $this->simulateAbsentConfigFile('config.ini.php'); $output = $this->triggerPiwikFrom('console'); $this->assertOutputContainsConfigFileMissingError('config.ini.php', $output); } public function test_NoLocalConfigFile_StartsInstallation_PiwikAccessedThroughWeb() { $this->simulateAbsentConfigFile('config.ini.php'); $output = $this->triggerPiwikFrom('web'); $this->assertInstallationProcessStarted($output); } public function getEntryPointsAndConfigFilesToTest() { return array( array('global.ini.php', 'tracker'), array('global.ini.php', 'web'), array('global.ini.php', 'console'), array('global.ini.php', 'archive_web'), array('config.ini.php', 'tracker'), array('config.ini.php', 'web'), array('config.ini.php', 'console'), array('config.ini.php', 'archive_web'), array('common.config.ini.php', 'tracker'), array('common.config.ini.php', 'web'), array('common.config.ini.php', 'console'), array('common.config.ini.php', 'archive_web'), ); } /** * @dataProvider getEntryPointsAndConfigFilesToTest */ public function test_BadConfigFile_TriggersError($configFile, $entryPoint) { $this->simulateBadConfigFile($configFile); $output = $this->triggerPiwikFrom($entryPoint); $this->assertOutputContainsBadConfigFileError($output); } /** * @dataProvider getEntryPointsToTest */ public function test_BadDomainSpecificLocalConfigFile_TriggersError($entryPoint) { $this->simulateHost('piwik.kobra.org'); $configFile = 'piwik.kobra.org.config.ini.php'; $this->simulateBadConfigFile($configFile); $output = $this->triggerPiwikFrom($entryPoint); $this->assertOutputContainsBadConfigFileError($output); } private function assertOutputContainsConfigFileMissingError($fileName, $output) { $this->assertRegExp("/.*The configuration file \\{.*\\/" . preg_quote($fileName) . "\\} has not been found or could not be read\\..*/", $output, "Output did not contain the expected exception for $fileName --- Output was --- $output"); } private function assertOutputContainsBadConfigFileError($output) { $this->assertRegExp("/Unable to read INI file \\{.*\\/matomo.php\\}:/", $output); $this->assertRegExp("/Your host may have disabled parse_ini_file\\(\\)/", $output); } private function assertInstallationProcessStarted($output) { $this->assertContains('