Skip to content

Instantly share code, notes, and snippets.

@openbrian
Created November 10, 2015 19:37
Show Gist options
  • Save openbrian/e5429eaf3600c1669696 to your computer and use it in GitHub Desktop.
Save openbrian/e5429eaf3600c1669696 to your computer and use it in GitHub Desktop.
<?php
abstract class curlTest
extends rimsTestCase
{
/**
* @var string override to provide code coverage data from the server
*/
protected $coverageScriptUrl;
/**
* @var boolean
*/
private $collectCodeCoverageInformation;
public function __construct( $name = NULL, array $data = array(), $dataName = '' )
{
parent::__construct($name, $data, $dataName);
$this->coverageScriptUrl = buildUrl( '/phpunit_coverage.php' );
}
public function run( PHPUnit_Framework_TestResult $result = NULL )
{
$this->testId = get_class($this) . '__' . $this->getName();
if ($result === NULL)
{
$result = $this->createResult();
}
$this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
parent::run( $result );
if ($this->collectCodeCoverageInformation)
{
$coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage
( $this->coverageScriptUrl
, $this->testId
);
$result->getCodeCoverage()->append( $coverage->get(), $this );
}
return $result;
}
function getCookie()
{
return 'PHPUNIT_SELENIUM_TEST_ID=' . $this->testId;
}
}
@openbrian
Copy link
Author

The parent class will buildUrl() and call the post method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment