TimeTrex Community Edition v16.2.0
This commit is contained in:
50
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/CookieTest.php
vendored
Normal file
50
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/CookieTest.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Selenium2TestCase\Coverage;
|
||||
|
||||
use PHPUnit\Framework\TestResult;
|
||||
use Tests\Selenium2TestCase\BaseTestCase;
|
||||
|
||||
class CookieTest extends BaseTestCase
|
||||
{
|
||||
// this is a dummy URL (returns down coverage data in HTML), but Firefox still sets domain cookie, which is what's needed
|
||||
protected $coverageScriptUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL .'/coverage/dummy.html';
|
||||
|
||||
public function run(TestResult $result = NULL): TestResult
|
||||
{
|
||||
// make sure code coverage collection is enabled
|
||||
if ($result === NULL) {
|
||||
$result = $this->createResult();
|
||||
}
|
||||
if (!$result->getCollectCodeCoverageInformation()) {
|
||||
$result->setCodeCoverage(new \SebastianBergmann\CodeCoverage\CodeCoverage());
|
||||
}
|
||||
|
||||
parent::run($result);
|
||||
|
||||
$result->getCodeCoverage()->clear();
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getTestIdCookie()
|
||||
{
|
||||
return $this->prepareSession()->cookie()->get('PHPUNIT_SELENIUM_TEST_ID');
|
||||
}
|
||||
|
||||
public function testTestIdCookieIsSet()
|
||||
{
|
||||
$this->url('/');
|
||||
$testIdCookie = $this->getTestIdCookie();
|
||||
$this->assertNotEmpty($testIdCookie);
|
||||
return $testIdCookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testTestIdCookieIsSet
|
||||
*/
|
||||
public function testTestsHaveUniqueTestIdCookies($previousTestIdCookie)
|
||||
{
|
||||
$this->url('/');
|
||||
$this->assertNotEquals($this->getTestIdCookie(), $previousTestIdCookie);
|
||||
}
|
||||
}
|
13
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/DummyClass.php
vendored
Normal file
13
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/DummyClass.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
class DummyClass
|
||||
{
|
||||
public function coveredMethod()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function uncoveredMethod()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
40
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/RemoteCoverageTest.php
vendored
Normal file
40
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/RemoteCoverageTest.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Selenium2TestCase\Coverage;
|
||||
|
||||
use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RemoteCoverageTest extends TestCase
|
||||
{
|
||||
public function testObtainsCodeCoverageInformationFromAPossiblyRemoteHttpServer()
|
||||
{
|
||||
$coverageScriptUrl = PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL . '/coverage/dummy.txt';
|
||||
$coverage = new RemoteCoverage(
|
||||
$coverageScriptUrl,
|
||||
'dummyTestId'
|
||||
);
|
||||
$content = $coverage->get();
|
||||
$dummyClassSourceFile = $this->classSourceFile('DummyClass', $content);
|
||||
$expectedCoverage = array(
|
||||
3 => 1,
|
||||
6 => 1,
|
||||
7 => -2,
|
||||
11 => -1,
|
||||
12 => -2,
|
||||
14 => 1
|
||||
);
|
||||
$this->assertTrue(isset($content[$dummyClassSourceFile]), "Coverage: " . var_export($content, true));
|
||||
$this->assertEquals($expectedCoverage, $content[$dummyClassSourceFile]);
|
||||
}
|
||||
|
||||
private function classSourceFile($className, array $content)
|
||||
{
|
||||
foreach ($content as $file => $coverage) {
|
||||
if (strstr($file, $className)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
$this->fail("Class $className not found in coverage: " . var_export($content, true));
|
||||
}
|
||||
}
|
63
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/SingleFileTest.php
vendored
Normal file
63
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/SingleFileTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Selenium2TestCase\Coverage;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SingleFileTest extends TestCase
|
||||
{
|
||||
private $dummyTestId = 'ns_dummyTestId';
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('xdebug')) {
|
||||
$this->markTestSkipped('Needs xdebug to run');
|
||||
}
|
||||
$this->coverageFilePattern = __DIR__ . '/*.' . $this->dummyTestId;
|
||||
$this->dummyClassSourceFile = __DIR__ . '/DummyClass.php';
|
||||
}
|
||||
|
||||
public function testExecutingAFileWithThePrependedAndAppendedCoverageScriptsProducesACoverageData()
|
||||
{
|
||||
$this->clearCoverageFiles();
|
||||
|
||||
exec('php ' . __DIR__ . '/singleFile.php');
|
||||
$coverageFiles = glob($this->coverageFilePattern);
|
||||
$this->assertEquals(1, count($coverageFiles));
|
||||
|
||||
$content = unserialize(file_get_contents($coverageFiles[0]));
|
||||
$dummyClassCoverage = $content[$this->dummyClassSourceFile];
|
||||
$this->assertCovered(6, $dummyClassCoverage);
|
||||
$this->assertNotCovered(11, $dummyClassCoverage);
|
||||
|
||||
return $dummyClassCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testExecutingAFileWithThePrependedAndAppendedCoverageScriptsProducesACoverageData
|
||||
*/
|
||||
public function testTheCoverageScriptReturnsTheContentOfASpecificCoverageFile($expectedDummyClassCoverage)
|
||||
{
|
||||
$coverage = unserialize(exec('php ' . __DIR__ . '/singleFileCoverage.php ' . $this->dummyTestId));
|
||||
$dummyClassCoverage = $coverage[$this->dummyClassSourceFile];
|
||||
$this->assertEquals($expectedDummyClassCoverage, $dummyClassCoverage['coverage']);
|
||||
}
|
||||
|
||||
private function clearCoverageFiles()
|
||||
{
|
||||
$coverageFiles = glob($this->coverageFilePattern);
|
||||
foreach ($coverageFiles as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
private function assertCovered($line, array $fileCoverage)
|
||||
{
|
||||
$this->assertEquals(1, $fileCoverage[$line]);
|
||||
}
|
||||
|
||||
private function assertNotCovered($line, array $fileCoverage)
|
||||
{
|
||||
$this->assertEquals(-1, $fileCoverage[$line]);
|
||||
}
|
||||
}
|
9
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFile.php
vendored
Normal file
9
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFile.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$_COOKIE['PHPUNIT_SELENIUM_TEST_ID'] = 'ns\\dummyTestId';
|
||||
require __DIR__ . '/../../../PHPUnit/Extensions/SeleniumCommon/prepend.php';
|
||||
|
||||
require_once 'DummyClass.php';
|
||||
$object = new DummyClass();
|
||||
$object->coveredMethod();
|
||||
|
||||
require __DIR__ . '/../../../PHPUnit/Extensions/SeleniumCommon/append.php';
|
3
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFileCoverage.php
vendored
Normal file
3
vendor/phpunit/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFileCoverage.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$_GET['PHPUNIT_SELENIUM_TEST_ID'] = $argv[1];
|
||||
require __DIR__ . '/../../../PHPUnit/Extensions/SeleniumCommon/phpunit_coverage.php';
|
Reference in New Issue
Block a user