Newer
Older
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Integration;
Thomas Steur
a validé
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group Core
*/
class JsProxyTest extends \PHPUnit_Framework_TestCase
{
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $this->getStaticSrvUrl() . '/js/');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$fullResponse = curl_exec($curlHandle);
$responseInfo = curl_getinfo($curlHandle);
curl_close($curlHandle);
diosmosis
a validé
$this->assertEquals(200, $responseInfo["http_code"], 'Ok response');
$piwik_js = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/piwik.js');
diosmosis
a validé
$this->assertEquals($piwik_js, $fullResponse, 'script content');
}
public function testPiwikJsNoComment()
diosmosis
a validé
{
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $this->getStaticSrvUrl() . '/js/tracker.php');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$fullResponse = curl_exec($curlHandle);
$responseInfo = curl_getinfo($curlHandle);
curl_close($curlHandle);
$this->assertEquals(200, $responseInfo["http_code"], 'Ok response');
$piwikJs = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/piwik.js');
$piwikNoCommentJs = substr($piwikJs, strpos($piwikJs, "*/\n") + 3);
$this->assertEquals($piwikNoCommentJs, $fullResponse, 'script content (if comment shows, $byteStart value in /js/tracker.php)');
if(IntegrationTestCase::isMysqli()) {
$this->markTestSkipped('Sometimes fails with 500 error');
}
$url = $this->getStaticSrvUrl() . '/js/?idsite=1';
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$fullResponse = curl_exec($curlHandle);
$responseInfo = curl_getinfo($curlHandle);
curl_close($curlHandle);
$this->assertEquals(200, $responseInfo["http_code"], var_export($responseInfo, true));
$expected = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
$processed = base64_encode($fullResponse);
if ($expected != $processed) {
$this->markTestSkipped("testPiwikPhp invalid response content: " . $fullResponse);
Benaka Moorthi
a validé
}
$this->assertEquals(
$expected,
$processed,
'checking for image content' . "\n\n\n\nRaw content: \n\n\n" . $fullResponse
);
}
/**
* Helper methods
*/
private function getStaticSrvUrl()
{