本文整理汇总了PHP中PHP_CodeCoverage::append方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeCoverage::append方法的具体用法?PHP PHP_CodeCoverage::append怎么用?PHP PHP_CodeCoverage::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeCoverage
的用法示例。
在下文中一共展示了PHP_CodeCoverage::append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSimpleMergeLegacy
/**
* Test merge for code coverage library 3 version
*
* @requires function \PHP_CodeCoverage::merge
*/
public function testSimpleMergeLegacy()
{
$firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
$secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
$filter = new \PHP_CodeCoverage_Filter();
$filter->addFilesToWhitelist([$firstFile, $secondFile]);
$coverage1 = new \PHP_CodeCoverage(null, $filter);
$coverage1->append(array($firstFile => array(35 => 1), $secondFile => array(34 => 1)), 'Test1');
$coverage2 = new \PHP_CodeCoverage(null, $filter);
$coverage2->append(array($firstFile => array(35 => 1, 36 => 1)), 'Test2');
$merger = new CoverageMerger();
$this->call($merger, 'addCoverage', $coverage1);
$this->call($merger, 'addCoverage', $coverage2);
/** @var \PHP_CodeCoverage $coverage */
$coverage = $this->getObjectValue($merger, 'coverage');
$this->assertInstanceOf('\\PHP_CodeCoverage', $coverage);
$data = $coverage->getData();
$this->assertCount(2, $data[$firstFile][35]);
$this->assertEquals('Test1', $data[$firstFile][35][0]);
$this->assertEquals('Test2', $data[$firstFile][35][1]);
$this->assertCount(1, $data[$firstFile][36]);
$this->assertEquals('Test2', $data[$firstFile][36][0]);
$this->assertCount(1, $data[$secondFile][34]);
$this->assertEquals('Test1', $data[$secondFile][34][0]);
}
示例2: testAppendThrowsExceptionIfUsedCodeWasNotExecuted
/**
* @covers PHP_CodeCoverage::performUnexecutedCoveredCodeCheck
* @expectedException PHP_CodeCoverage_CoveredCodeNotExecutedException
*/
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted()
{
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH);
$this->coverage->setCheckForUnexecutedCoveredCode(true);
$data = [TEST_FILES_PATH . 'BankAccount.php' => [29 => -1, 31 => -1]];
$linesToBeCovered = [TEST_FILES_PATH . 'BankAccount.php' => [29, 31]];
$linesToBeUsed = [TEST_FILES_PATH . 'BankAccount.php' => [22, 24]];
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
}
示例3: testSimpleMerge
public function testSimpleMerge()
{
$firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
$secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
$coverage1 = new \PHP_CodeCoverage();
$coverage1->append(array($firstFile => array(35 => 1), $secondFile => array(34 => 1)), 'Test1');
$coverage2 = new \PHP_CodeCoverage();
$coverage2->append(array($firstFile => array(35 => 1, 36 => 1)), 'Test2');
$merger = new CoverageMerger();
$merger->addCoverage($coverage1);
$merger->addCoverage($coverage2);
$coverage = $merger->getCoverage();
$data = $coverage->getData();
$this->assertEquals(2, count($data[$firstFile][35]));
$this->assertEquals('Test1', $data[$firstFile][35][0]);
$this->assertEquals('Test2', $data[$firstFile][35][1]);
$this->assertEquals(1, count($data[$firstFile][36]));
$this->assertEquals('Test2', $data[$firstFile][36][0]);
$this->assertEquals(1, count($data[$secondFile][34]));
$this->assertEquals('Test1', $data[$secondFile][34][0]);
}
示例4: testAppendThrowsExceptionForInvalidArgument
/**
* @covers PHP_CodeCoverage::append
* @expectedException PHP_CodeCoverage_Exception
*/
public function testAppendThrowsExceptionForInvalidArgument()
{
$this->coverage->append(array(), null);
}
示例5: testAppendThrowsExceptionForInvalidArgument
/**
* @covers PHP_CodeCoverage::append
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionForInvalidArgument()
{
$coverage = new PHP_CodeCoverage();
$coverage->append(array(), NULL);
}
示例6: rebuildCoverageData
/**
* This method takes a coverage report and then rebuilds the raw coverage
* data based on the report data and the change history of the covered files.
*
* @param PHP_ChangeCoverage_Report $report The coverage report data.
*
* @return PHP_CodeCoverage
*/
protected function rebuildCoverageData(PHP_ChangeCoverage_Report $report)
{
$codeCoverage = new PHP_CodeCoverage();
$factory = new PHP_ChangeCoverage_ChangeSet_Factory();
vcsCache::initialize($this->tempDirectory);
$this->writeLine();
$this->writeLine('Collecting commits and meta data, this may take a moment.');
$this->writeLine();
$xdebug = new PHP_ChangeCoverage_Xdebug();
if ($this->unmodifiedAsCovered) {
$xdebug->setUnmodifiedAsCovered();
}
foreach ($report->getFiles() as $file) {
$changeSet = $factory->create($file);
$changeSet->setStartDate($this->modifiedSince);
foreach ($xdebug->generateData($changeSet->calculate()) as $data) {
$codeCoverage->append($data, md5(microtime()));
}
}
return $codeCoverage;
}
示例7: tearDown
/**
* Collect code coverage after the suite has been run
*
* @AfterSuite
*/
public static function tearDown(SuiteEvent $event)
{
$parameters = $event->getContextParameters();
if ($parameters['enableCodeCoverage']) {
$client = new Client($parameters['url']);
$response = $client->get('/', array('X-Enable-Coverage' => 1, 'X-Test-Session-Id' => self::$testSessionId, 'X-Collect-Coverage' => 1))->send();
$data = unserialize((string) $response->getBody());
$filter = new PHP_CodeCoverage_Filter();
foreach ($parameters['whitelist'] as $dir) {
$filter->addDirectoryToWhitelist($dir);
}
$coverage = new PHP_CodeCoverage(null, $filter);
$coverage->append($data, 'behat-suite');
$report = new PHP_CodeCoverage_Report_HTML();
$report->process($coverage, $parameters['coveragePath']);
}
}
示例8: generateCoverageForFixture
/**
* @return \PHP_CodeCoverage
*/
public function generateCoverageForFixture()
{
$coverage = new \PHP_CodeCoverage(null, null);
$coverage->append(array(__DIR__ . '/../../fixture/NoNamespace/ExampleTest.php' => array(8 => 1, 9 => 1)), 'Nonamespace\\ExampleTest::testSomethingVerySpecial', true);
return $coverage;
}