init
This commit is contained in:
212
vendor/phpunit/php-code-coverage/tests/tests/BuilderTest.php
vendored
Normal file
212
vendor/phpunit/php-code-coverage/tests/tests/BuilderTest.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
use SebastianBergmann\CodeCoverage\Node\Builder;
|
||||
|
||||
class BuilderTest extends TestCase
|
||||
{
|
||||
protected $factory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->factory = new Builder;
|
||||
}
|
||||
|
||||
public function testSomething()
|
||||
{
|
||||
$root = $this->getCoverageForBankAccount()->getReport();
|
||||
|
||||
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
|
||||
$this->assertEquals($expectedPath, $root->getName());
|
||||
$this->assertEquals($expectedPath, $root->getPath());
|
||||
$this->assertEquals(10, $root->getNumExecutableLines());
|
||||
$this->assertEquals(5, $root->getNumExecutedLines());
|
||||
$this->assertEquals(1, $root->getNumClasses());
|
||||
$this->assertEquals(0, $root->getNumTestedClasses());
|
||||
$this->assertEquals(4, $root->getNumMethods());
|
||||
$this->assertEquals(3, $root->getNumTestedMethods());
|
||||
$this->assertEquals('0.00%', $root->getTestedClassesPercent());
|
||||
$this->assertEquals('75.00%', $root->getTestedMethodsPercent());
|
||||
$this->assertEquals('50.00%', $root->getLineExecutedPercent());
|
||||
$this->assertEquals(0, $root->getNumFunctions());
|
||||
$this->assertEquals(0, $root->getNumTestedFunctions());
|
||||
$this->assertNull($root->getParent());
|
||||
$this->assertEquals([], $root->getDirectories());
|
||||
#$this->assertEquals(array(), $root->getFiles());
|
||||
#$this->assertEquals(array(), $root->getChildNodes());
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'BankAccount' => [
|
||||
'methods' => [
|
||||
'getBalance' => [
|
||||
'signature' => 'getBalance()',
|
||||
'startLine' => 6,
|
||||
'endLine' => 9,
|
||||
'executableLines' => 1,
|
||||
'executedLines' => 1,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#6',
|
||||
'methodName' => 'getBalance',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
'setBalance' => [
|
||||
'signature' => 'setBalance($balance)',
|
||||
'startLine' => 11,
|
||||
'endLine' => 18,
|
||||
'executableLines' => 5,
|
||||
'executedLines' => 0,
|
||||
'ccn' => 2,
|
||||
'coverage' => 0,
|
||||
'crap' => 6,
|
||||
'link' => 'BankAccount.php.html#11',
|
||||
'methodName' => 'setBalance',
|
||||
'visibility' => 'protected',
|
||||
],
|
||||
'depositMoney' => [
|
||||
'signature' => 'depositMoney($balance)',
|
||||
'startLine' => 20,
|
||||
'endLine' => 25,
|
||||
'executableLines' => 2,
|
||||
'executedLines' => 2,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#20',
|
||||
'methodName' => 'depositMoney',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
'withdrawMoney' => [
|
||||
'signature' => 'withdrawMoney($balance)',
|
||||
'startLine' => 27,
|
||||
'endLine' => 32,
|
||||
'executableLines' => 2,
|
||||
'executedLines' => 2,
|
||||
'ccn' => 1,
|
||||
'coverage' => 100,
|
||||
'crap' => '1',
|
||||
'link' => 'BankAccount.php.html#27',
|
||||
'methodName' => 'withdrawMoney',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
],
|
||||
'startLine' => 2,
|
||||
'executableLines' => 10,
|
||||
'executedLines' => 5,
|
||||
'ccn' => 5,
|
||||
'coverage' => 50,
|
||||
'crap' => '8.12',
|
||||
'package' => [
|
||||
'namespace' => '',
|
||||
'fullPackage' => '',
|
||||
'category' => '',
|
||||
'package' => '',
|
||||
'subpackage' => ''
|
||||
],
|
||||
'link' => 'BankAccount.php.html#2',
|
||||
'className' => 'BankAccount'
|
||||
]
|
||||
],
|
||||
$root->getClasses()
|
||||
);
|
||||
|
||||
$this->assertEquals([], $root->getFunctions());
|
||||
}
|
||||
|
||||
public function testBuildDirectoryStructure()
|
||||
{
|
||||
$method = new \ReflectionMethod(
|
||||
Builder::class,
|
||||
'buildDirectoryStructure'
|
||||
);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'src' => [
|
||||
'Money.php/f' => [],
|
||||
'MoneyBag.php/f' => []
|
||||
]
|
||||
],
|
||||
$method->invoke(
|
||||
$this->factory,
|
||||
['src/Money.php' => [], 'src/MoneyBag.php' => []]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider reducePathsProvider
|
||||
*/
|
||||
public function testReducePaths($reducedPaths, $commonPath, $paths)
|
||||
{
|
||||
$method = new \ReflectionMethod(
|
||||
Builder::class,
|
||||
'reducePaths'
|
||||
);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$_commonPath = $method->invokeArgs($this->factory, [&$paths]);
|
||||
|
||||
$this->assertEquals($reducedPaths, $paths);
|
||||
$this->assertEquals($commonPath, $_commonPath);
|
||||
}
|
||||
|
||||
public function reducePathsProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
[
|
||||
'Money.php' => [],
|
||||
'MoneyBag.php' => []
|
||||
],
|
||||
'/home/sb/Money',
|
||||
[
|
||||
'/home/sb/Money/Money.php' => [],
|
||||
'/home/sb/Money/MoneyBag.php' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'Money.php' => []
|
||||
],
|
||||
'/home/sb/Money/',
|
||||
[
|
||||
'/home/sb/Money/Money.php' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
[],
|
||||
'.',
|
||||
[]
|
||||
],
|
||||
[
|
||||
[
|
||||
'Money.php' => [],
|
||||
'MoneyBag.php' => [],
|
||||
'Cash.phar/Cash.php' => [],
|
||||
],
|
||||
'/home/sb/Money',
|
||||
[
|
||||
'/home/sb/Money/Money.php' => [],
|
||||
'/home/sb/Money/MoneyBag.php' => [],
|
||||
'phar:///home/sb/Money/Cash.phar/Cash.php' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
49
vendor/phpunit/php-code-coverage/tests/tests/CloverTest.php
vendored
Normal file
49
vendor/phpunit/php-code-coverage/tests/tests/CloverTest.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Report\Clover
|
||||
*/
|
||||
class CloverTest extends TestCase
|
||||
{
|
||||
public function testCloverForBankAccountTest()
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-clover.xml',
|
||||
$clover->process($this->getCoverageForBankAccount(), null, 'BankAccount')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForFileWithIgnoredLines()
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-clover.xml',
|
||||
$clover->process($this->getCoverageForFileWithIgnoredLines())
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForClassWithAnonymousFunction()
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-clover.xml',
|
||||
$clover->process($this->getCoverageForClassWithAnonymousFunction())
|
||||
);
|
||||
}
|
||||
}
|
||||
560
vendor/phpunit/php-code-coverage/tests/tests/CodeCoverageTest.php
vendored
Normal file
560
vendor/phpunit/php-code-coverage/tests/tests/CodeCoverageTest.php
vendored
Normal file
@@ -0,0 +1,560 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
|
||||
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\CodeCoverage
|
||||
*/
|
||||
class CodeCoverageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var CodeCoverage
|
||||
*/
|
||||
private $coverage;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->coverage = new CodeCoverage;
|
||||
}
|
||||
|
||||
public function testCanBeConstructedForXdebugWithoutGivenFilterObject()
|
||||
{
|
||||
if (PHP_SAPI == 'phpdbg') {
|
||||
$this->markTestSkipped('Requires PHP CLI and Xdebug');
|
||||
}
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
Xdebug::class,
|
||||
'driver',
|
||||
$this->coverage
|
||||
);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
Filter::class,
|
||||
'filter',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeConstructedForXdebugWithGivenFilterObject()
|
||||
{
|
||||
if (PHP_SAPI == 'phpdbg') {
|
||||
$this->markTestSkipped('Requires PHP CLI and Xdebug');
|
||||
}
|
||||
|
||||
$filter = new Filter;
|
||||
$coverage = new CodeCoverage(null, $filter);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
Xdebug::class,
|
||||
'driver',
|
||||
$coverage
|
||||
);
|
||||
|
||||
$this->assertSame($filter, $coverage->filter());
|
||||
}
|
||||
|
||||
public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject()
|
||||
{
|
||||
if (PHP_SAPI != 'phpdbg') {
|
||||
$this->markTestSkipped('Requires PHPDBG');
|
||||
}
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
PHPDBG::class,
|
||||
'driver',
|
||||
$this->coverage
|
||||
);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
Filter::class,
|
||||
'filter',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeConstructedForPhpdbgWithGivenFilterObject()
|
||||
{
|
||||
if (PHP_SAPI != 'phpdbg') {
|
||||
$this->markTestSkipped('Requires PHPDBG');
|
||||
}
|
||||
|
||||
$filter = new Filter;
|
||||
$coverage = new CodeCoverage(null, $filter);
|
||||
|
||||
$this->assertAttributeInstanceOf(
|
||||
PHPDBG::class,
|
||||
'driver',
|
||||
$coverage
|
||||
);
|
||||
|
||||
$this->assertSame($filter, $coverage->filter());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testCannotStartWithInvalidArgument()
|
||||
{
|
||||
$this->coverage->start(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testCannotStopWithInvalidFirstArgument()
|
||||
{
|
||||
$this->coverage->stop(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testCannotStopWithInvalidSecondArgument()
|
||||
{
|
||||
$this->coverage->stop(true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testCannotAppendWithInvalidArgument()
|
||||
{
|
||||
$this->coverage->append([], null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetCacheTokensThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCacheTokens(null);
|
||||
}
|
||||
|
||||
public function testSetCacheTokens()
|
||||
{
|
||||
$this->coverage->setCacheTokens(true);
|
||||
$this->assertAttributeEquals(true, 'cacheTokens', $this->coverage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetCheckForUnintentionallyCoveredCodeThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCheckForUnintentionallyCoveredCode(null);
|
||||
}
|
||||
|
||||
public function testSetCheckForUnintentionallyCoveredCode()
|
||||
{
|
||||
$this->coverage->setCheckForUnintentionallyCoveredCode(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForUnintentionallyCoveredCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setForceCoversAnnotation(null);
|
||||
}
|
||||
|
||||
public function testSetCheckForMissingCoversAnnotation()
|
||||
{
|
||||
$this->coverage->setCheckForMissingCoversAnnotation(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForMissingCoversAnnotation',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetCheckForMissingCoversAnnotationThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCheckForMissingCoversAnnotation(null);
|
||||
}
|
||||
|
||||
public function testSetForceCoversAnnotation()
|
||||
{
|
||||
$this->coverage->setForceCoversAnnotation(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'forceCoversAnnotation',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetCheckForUnexecutedCoveredCodeThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setCheckForUnexecutedCoveredCode(null);
|
||||
}
|
||||
|
||||
public function testSetCheckForUnexecutedCoveredCode()
|
||||
{
|
||||
$this->coverage->setCheckForUnexecutedCoveredCode(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForUnexecutedCoveredCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetAddUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setAddUncoveredFilesFromWhitelist(null);
|
||||
}
|
||||
|
||||
public function testSetAddUncoveredFilesFromWhitelist()
|
||||
{
|
||||
$this->coverage->setAddUncoveredFilesFromWhitelist(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'addUncoveredFilesFromWhitelist',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setProcessUncoveredFilesFromWhitelist(null);
|
||||
}
|
||||
|
||||
public function testSetProcessUncoveredFilesFromWhitelist()
|
||||
{
|
||||
$this->coverage->setProcessUncoveredFilesFromWhitelist(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'processUncoveredFilesFromWhitelist',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetIgnoreDeprecatedCode()
|
||||
{
|
||||
$this->coverage->setIgnoreDeprecatedCode(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'ignoreDeprecatedCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\Exception
|
||||
*/
|
||||
public function testSetIgnoreDeprecatedCodeThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setIgnoreDeprecatedCode(null);
|
||||
}
|
||||
|
||||
public function testClear()
|
||||
{
|
||||
$this->coverage->clear();
|
||||
|
||||
$this->assertAttributeEquals(null, 'currentId', $this->coverage);
|
||||
$this->assertAttributeEquals([], 'data', $this->coverage);
|
||||
$this->assertAttributeEquals([], 'tests', $this->coverage);
|
||||
}
|
||||
|
||||
public function testCollect()
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccount();
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => null],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => null],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => null],
|
||||
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => null]
|
||||
],
|
||||
$coverage->getTests()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForFirstTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge2()
|
||||
{
|
||||
$coverage = new CodeCoverage(
|
||||
$this->createMock(Xdebug::class),
|
||||
new Filter
|
||||
);
|
||||
|
||||
$coverage->merge($this->getCoverageForBankAccount());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
1,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored2()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[1, 5],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_without_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored3()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
8,
|
||||
11,
|
||||
15,
|
||||
16,
|
||||
19,
|
||||
20
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnoredOneLineAnnotations()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
18,
|
||||
20,
|
||||
21,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
37
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_oneline_annotations.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ReflectionMethod
|
||||
*/
|
||||
private function getLinesToBeIgnored()
|
||||
{
|
||||
$getLinesToBeIgnored = new \ReflectionMethod(
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage',
|
||||
'getLinesToBeIgnored'
|
||||
);
|
||||
|
||||
$getLinesToBeIgnored->setAccessible(true);
|
||||
|
||||
return $getLinesToBeIgnored;
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled()
|
||||
{
|
||||
$this->coverage->setDisableIgnoredLines(true);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
7,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
26,
|
||||
27,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
37
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException
|
||||
*/
|
||||
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted()
|
||||
{
|
||||
$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' => [
|
||||
22,
|
||||
24
|
||||
]
|
||||
];
|
||||
|
||||
$linesToBeUsed = [];
|
||||
|
||||
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SebastianBergmann\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);
|
||||
}
|
||||
}
|
||||
49
vendor/phpunit/php-code-coverage/tests/tests/Crap4jTest.php
vendored
Normal file
49
vendor/phpunit/php-code-coverage/tests/tests/Crap4jTest.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Report\Crap4j
|
||||
*/
|
||||
class Crap4jTest extends TestCase
|
||||
{
|
||||
public function testForBankAccountTest()
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount')
|
||||
);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines')
|
||||
);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction')
|
||||
);
|
||||
}
|
||||
}
|
||||
196
vendor/phpunit/php-code-coverage/tests/tests/FilterTest.php
vendored
Normal file
196
vendor/phpunit/php-code-coverage/tests/tests/FilterTest.php
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Filter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $files = [];
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}');
|
||||
|
||||
$this->files = [
|
||||
TEST_FILES_PATH . 'BankAccount.php',
|
||||
TEST_FILES_PATH . 'BankAccountTest.php',
|
||||
TEST_FILES_PATH . 'CoverageClassExtendedTest.php',
|
||||
TEST_FILES_PATH . 'CoverageClassTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php',
|
||||
TEST_FILES_PATH . 'CoverageFunctionTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php',
|
||||
TEST_FILES_PATH . 'CoverageMethodTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNoneTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotPrivateTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotProtectedTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNotPublicTest.php',
|
||||
TEST_FILES_PATH . 'CoverageNothingTest.php',
|
||||
TEST_FILES_PATH . 'CoveragePrivateTest.php',
|
||||
TEST_FILES_PATH . 'CoverageProtectedTest.php',
|
||||
TEST_FILES_PATH . 'CoveragePublicTest.php',
|
||||
TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php',
|
||||
TEST_FILES_PATH . 'CoveredClass.php',
|
||||
TEST_FILES_PATH . 'CoveredFunction.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageClassTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php',
|
||||
TEST_FILES_PATH . 'NamespaceCoveredClass.php',
|
||||
TEST_FILES_PATH . 'NotExistingCoveredElementTest.php',
|
||||
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php',
|
||||
TEST_FILES_PATH . 'source_with_ignore.php',
|
||||
TEST_FILES_PATH . 'source_with_namespace.php',
|
||||
TEST_FILES_PATH . 'source_with_oneline_annotations.php',
|
||||
TEST_FILES_PATH . 'source_without_ignore.php',
|
||||
TEST_FILES_PATH . 'source_without_namespace.php'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testAddingAFileToTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
|
||||
$this->assertEquals(
|
||||
[$this->files[0]],
|
||||
$this->filter->getWhitelist()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::removeFileFromWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testRemovingAFileFromTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->filter->removeFileFromWhitelist($this->files[0]);
|
||||
|
||||
$this->assertEquals([], $this->filter->getWhitelist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addDirectoryToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
* @depends testAddingAFileToTheWhitelistWorks
|
||||
*/
|
||||
public function testAddingADirectoryToTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addFilesToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testAddingFilesToTheWhitelistWorks()
|
||||
{
|
||||
$facade = new \File_Iterator_Facade;
|
||||
|
||||
$files = $facade->getFilesAsArray(
|
||||
TEST_FILES_PATH,
|
||||
$suffixes = '.php'
|
||||
);
|
||||
|
||||
$this->filter->addFilesToWhitelist($files);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::removeDirectoryFromWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
* @depends testAddingADirectoryToTheWhitelistWorks
|
||||
*/
|
||||
public function testRemovingADirectoryFromTheWhitelistWorks()
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
$this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH);
|
||||
|
||||
$this->assertEquals([], $this->filter->getWhitelist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
|
||||
*/
|
||||
public function testIsFile()
|
||||
{
|
||||
$this->assertFalse($this->filter->isFile('vfs://root/a/path'));
|
||||
$this->assertFalse($this->filter->isFile('xdebug://debug-eval'));
|
||||
$this->assertFalse($this->filter->isFile('eval()\'d code'));
|
||||
$this->assertFalse($this->filter->isFile('runtime-created function'));
|
||||
$this->assertFalse($this->filter->isFile('assert code'));
|
||||
$this->assertFalse($this->filter->isFile('regexp code'));
|
||||
$this->assertTrue($this->filter->isFile(__FILE__));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
*/
|
||||
public function testWhitelistedFileIsNotFiltered()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertFalse($this->filter->isFiltered($this->files[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
*/
|
||||
public function testNotWhitelistedFileIsFiltered()
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertTrue($this->filter->isFiltered($this->files[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
|
||||
*/
|
||||
public function testNonFilesAreFiltered()
|
||||
{
|
||||
$this->assertTrue($this->filter->isFiltered('vfs://root/a/path'));
|
||||
$this->assertTrue($this->filter->isFiltered('xdebug://debug-eval'));
|
||||
$this->assertTrue($this->filter->isFiltered('eval()\'d code'));
|
||||
$this->assertTrue($this->filter->isFiltered('runtime-created function'));
|
||||
$this->assertTrue($this->filter->isFiltered('assert code'));
|
||||
$this->assertTrue($this->filter->isFiltered('regexp code'));
|
||||
}
|
||||
}
|
||||
103
vendor/phpunit/php-code-coverage/tests/tests/HTMLTest.php
vendored
Normal file
103
vendor/phpunit/php-code-coverage/tests/tests/HTMLTest.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report\Html;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
class HTMLTest extends TestCase
|
||||
{
|
||||
private static $TEST_REPORT_PATH_SOURCE;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
$tmpFilesIterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator(self::$TEST_TMP_PATH, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
|
||||
foreach ($tmpFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$pathname = $fileInfo->getPathname();
|
||||
$fileInfo->isDir() ? rmdir($pathname) : unlink($pathname);
|
||||
}
|
||||
}
|
||||
|
||||
public function testForBankAccountTest()
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
{
|
||||
$expectedFilesPath =
|
||||
self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expectedFilesPath
|
||||
* @param string $actualFilesPath
|
||||
*/
|
||||
private function assertFilesEquals($expectedFilesPath, $actualFilesPath)
|
||||
{
|
||||
$expectedFilesIterator = new \FilesystemIterator($expectedFilesPath);
|
||||
$actualFilesIterator = new \RegexIterator(new \FilesystemIterator($actualFilesPath), '/.html/');
|
||||
|
||||
$this->assertEquals(
|
||||
iterator_count($expectedFilesIterator),
|
||||
iterator_count($actualFilesIterator),
|
||||
'Generated files and expected files not match'
|
||||
);
|
||||
|
||||
foreach ($expectedFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$filename = $fileInfo->getFilename();
|
||||
|
||||
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
$this->assertFileExists($actualFile);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
$fileInfo->getPathname(),
|
||||
str_replace(PHP_EOL, "\n", file_get_contents($actualFile)),
|
||||
"${filename} not match"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
vendor/phpunit/php-code-coverage/tests/tests/TextTest.php
vendored
Normal file
49
vendor/phpunit/php-code-coverage/tests/tests/TextTest.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Report\Text
|
||||
*/
|
||||
class TextTest extends TestCase
|
||||
{
|
||||
public function testTextForBankAccountTest()
|
||||
{
|
||||
$text = new Text(50, 90, false, false);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-text.txt',
|
||||
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
|
||||
);
|
||||
}
|
||||
|
||||
public function testTextForFileWithIgnoredLines()
|
||||
{
|
||||
$text = new Text(50, 90, false, false);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-text.txt',
|
||||
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
|
||||
);
|
||||
}
|
||||
|
||||
public function testTextForClassWithAnonymousFunction()
|
||||
{
|
||||
$text = new Text(50, 90, false, false);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-text.txt',
|
||||
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
|
||||
);
|
||||
}
|
||||
}
|
||||
29
vendor/phpunit/php-code-coverage/tests/tests/UtilTest.php
vendored
Normal file
29
vendor/phpunit/php-code-coverage/tests/tests/UtilTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Util
|
||||
*/
|
||||
class UtilTest extends TestCase
|
||||
{
|
||||
public function testPercent()
|
||||
{
|
||||
$this->assertEquals(100, Util::percent(100, 0));
|
||||
$this->assertEquals(100, Util::percent(100, 100));
|
||||
$this->assertEquals(
|
||||
'100.00%',
|
||||
Util::percent(100, 100, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
98
vendor/phpunit/php-code-coverage/tests/tests/XMLTest.php
vendored
Normal file
98
vendor/phpunit/php-code-coverage/tests/tests/XMLTest.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Report\Xml;
|
||||
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
class XMLTest extends TestCase
|
||||
{
|
||||
private static $TEST_REPORT_PATH_SOURCE;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
$tmpFilesIterator = new \FilesystemIterator(self::$TEST_TMP_PATH);
|
||||
|
||||
foreach ($tmpFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
unlink($fileInfo->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
public function testForBankAccountTest()
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
|
||||
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expectedFilesPath
|
||||
* @param string $actualFilesPath
|
||||
*/
|
||||
private function assertFilesEquals($expectedFilesPath, $actualFilesPath)
|
||||
{
|
||||
$expectedFilesIterator = new \FilesystemIterator($expectedFilesPath);
|
||||
$actualFilesIterator = new \FilesystemIterator($actualFilesPath);
|
||||
|
||||
$this->assertEquals(
|
||||
iterator_count($expectedFilesIterator),
|
||||
iterator_count($actualFilesIterator),
|
||||
'Generated files and expected files not match'
|
||||
);
|
||||
|
||||
foreach ($expectedFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$filename = $fileInfo->getFilename();
|
||||
|
||||
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
$this->assertFileExists($actualFile);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
$fileInfo->getPathname(),
|
||||
file_get_contents($actualFile),
|
||||
"${filename} not match"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user