configFileLocal = PIWIK_INCLUDE_PATH . '/plugins/Installation/tests/resources/config.ini.php'; $testingEnvironment->save(); } public function testShouldReturnHttp500IfWrongDbInfo() { $response = $this->sendHttpRequest($this->getUrl()); $this->assertEquals(500, $response['status']); } public function testShouldReturnValidApiResponseIfWrongDbInfoFormatXML() { $response = $this->sendHttpRequest($this->getUrl()); $data = str_replace("\n", "", $response['data']); $this->assertStringStartsWith(' assertStringEndsWith('', $data); } public function testShouldReturnValidApiResponseIfWrongDbInfoFormatJSON() { $response = $this->sendHttpRequest($this->getUrl() . '&format=json'); $data = str_replace("\n", "", $response['data']); $this->assertStringStartsWith('{"result":"error","message":"', $data); self::assertStringContainsString('Database access denied', $data); } public function testShouldReturnEmptyResultWhenNotInstalledAndDispatchIsDisabled() { $url = Fixture::getTestRootUrl() . 'nodispatchnotinstalled.php'; $response = $this->sendHttpRequest($url); $this->assertSame('', $response['data']); } private function getUrl() { return Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php?module=API&method=API.getPiwikVersion'; } public static function getOutputPrefix() { return ''; } public static function getPathToTestDirectory() { return dirname(__FILE__); } protected function sendHttpRequest($url) { return Http::sendHttpRequest($url, 10, null, null, 0, false, false, true); } }