blob: c3b7125eed0abb75ed71e61692bf346859d296a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
/**
* 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\System;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
/**
* @group TrackerTest
* @group Plugins
*/
class TrackerTest extends SystemTestCase
{
public static $fixture = null;
/**
* @var \PiwikTracker
*/
private $tracker;
public function setUp()
{
parent::setUp();
$idSite = 1;
$dateTime = '2014-01-01 00:00:01';
if (!Fixture::siteCreated($idSite)) {
Fixture::createWebsite($dateTime);
}
$this->tracker = Fixture::getTracker($idSite, $dateTime, $defaultInit = true);
}
public function test_response_ShouldContainAnImage()
{
$response = $this->tracker->doTrackPageView('Test');
Fixture::checkResponse($response);
$this->assertNotEmpty($response);
}
public function test_response_ShouldBeEmpty_IfImageIsDisabled()
{
$this->tracker->disableSendImageResponse();
$response = $this->tracker->doTrackPageView('Test');
$this->assertSame('', $response);
}
public function test_response_ShouldSend200ResponseCode_IfImageIsEnabled()
{
$url = $this->tracker->getUrlTrackPageView('Test');
$this->assertResponseCode(200, $url);
}
public function test_response_ShouldSend204ResponseCode_IfImageIsDisabled()
{
$url = $this->tracker->getUrlTrackPageView('Test');
$url .= '&send_image=0';
$this->assertResponseCode(204, $url);
}
}
|