Skip to content

Commit

Permalink
refs #6661 added a test to make sure it works
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Nov 13, 2014
1 parent 1430870 commit d0929e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/Tracker.php
Expand Up @@ -669,7 +669,8 @@ private function sendResponse()
$request = $_GET + $_POST;

if (array_key_exists('send_image', $request) && $request['send_image'] === '0') {
Common::sendHeader("HTTP/1.1 204 No Response");
Common::sendResponseCode(204);

return;
}

Expand Down
7 changes: 5 additions & 2 deletions tests/PHPUnit/Framework/Constraint/ResponseCode.php
Expand Up @@ -9,6 +9,7 @@

class ResponseCode extends \PHPUnit_Framework_Constraint
{
private $actualCode;

/**
* @param integer $value Expected response code
Expand Down Expand Up @@ -41,7 +42,9 @@ public function matches($other)
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

return $this->value === (int) $responseCode;
$this->actualCode = (int) $responseCode;

return $this->value === $this->actualCode;
}

/**
Expand All @@ -51,6 +54,6 @@ public function matches($other)
*/
public function toString()
{
return 'does not return response code ' . $this->exporter->export($this->value);
return 'does not return response code ' . $this->exporter->export($this->value) . ' it is ' . $this->actualCode;
}
}?>
8 changes: 8 additions & 0 deletions tests/PHPUnit/System/TrackerTest.php
Expand Up @@ -69,4 +69,12 @@ public function test_response_ShouldSend204ResponseCode_IfImageIsDisabled()
$this->assertResponseCode(204, $url);
}

public function test_response_ShouldSend400ResponseCode_IfSiteIdIsInvalid()
{
$url = $this->tracker->getUrlTrackPageView('Test');
$url .= '&idsite=100';

$this->assertResponseCode(400, $url);
}

}

0 comments on commit d0929e8

Please sign in to comment.