forked from GNUsocial/gnu-social
[COMPOSER] Add new php-ffmpeg package
This commit is contained in:
246
vendor/phpunit/php-code-coverage/tests/tests/BuilderTest.php
vendored
Normal file
246
vendor/phpunit/php-code-coverage/tests/tests/BuilderTest.php
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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\Node\Builder;
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
class BuilderTest extends TestCase
|
||||
{
|
||||
protected $factory;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->factory = new Builder;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$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 testNotCrashParsing(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForCrashParsing();
|
||||
$root = $coverage->getReport();
|
||||
|
||||
$expectedPath = \rtrim(TEST_FILES_PATH, \DIRECTORY_SEPARATOR);
|
||||
$this->assertEquals($expectedPath, $root->getName());
|
||||
$this->assertEquals($expectedPath, $root->getPath());
|
||||
$this->assertEquals(2, $root->getNumExecutableLines());
|
||||
$this->assertEquals(0, $root->getNumExecutedLines());
|
||||
$data = $coverage->getData();
|
||||
$expectedFile = $expectedPath . \DIRECTORY_SEPARATOR . 'Crash.php';
|
||||
$this->assertSame([$expectedFile => [1 => [], 2 => []]], $data);
|
||||
}
|
||||
|
||||
public function testBuildDirectoryStructure(): void
|
||||
{
|
||||
$s = \DIRECTORY_SEPARATOR;
|
||||
|
||||
$method = new \ReflectionMethod(
|
||||
Builder::class,
|
||||
'buildDirectoryStructure'
|
||||
);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'src' => [
|
||||
'Money.php/f' => [],
|
||||
'MoneyBag.php/f' => [],
|
||||
'Foo' => [
|
||||
'Bar' => [
|
||||
'Baz' => [
|
||||
'Foo.php/f' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
$method->invoke(
|
||||
$this->factory,
|
||||
[
|
||||
"src{$s}Money.php" => [],
|
||||
"src{$s}MoneyBag.php" => [],
|
||||
"src{$s}Foo{$s}Bar{$s}Baz{$s}Foo.php" => [],
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider reducePathsProvider
|
||||
*/
|
||||
public function testReducePaths($reducedPaths, $commonPath, $paths): void
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$s = \DIRECTORY_SEPARATOR;
|
||||
|
||||
yield [
|
||||
[],
|
||||
'.',
|
||||
[],
|
||||
];
|
||||
|
||||
$prefixes = ["C:$s", "$s"];
|
||||
|
||||
foreach ($prefixes as $p) {
|
||||
yield [
|
||||
[
|
||||
'Money.php' => [],
|
||||
],
|
||||
"{$p}home{$s}sb{$s}Money{$s}",
|
||||
[
|
||||
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'Money.php' => [],
|
||||
'MoneyBag.php' => [],
|
||||
],
|
||||
"{$p}home{$s}sb{$s}Money",
|
||||
[
|
||||
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
|
||||
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'Money.php' => [],
|
||||
'MoneyBag.php' => [],
|
||||
"Cash.phar{$s}Cash.php" => [],
|
||||
],
|
||||
"{$p}home{$s}sb{$s}Money",
|
||||
[
|
||||
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
|
||||
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
|
||||
"phar://{$p}home{$s}sb{$s}Money{$s}Cash.phar{$s}Cash.php" => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
48
vendor/phpunit/php-code-coverage/tests/tests/CloverTest.php
vendored
Normal file
48
vendor/phpunit/php-code-coverage/tests/tests/CloverTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-clover.xml',
|
||||
$clover->process($this->getCoverageForBankAccount(), null, 'BankAccount')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForFileWithIgnoredLines(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-clover.xml',
|
||||
$clover->process($this->getCoverageForFileWithIgnoredLines())
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-clover.xml',
|
||||
$clover->process($this->getCoverageForClassWithAnonymousFunction())
|
||||
);
|
||||
}
|
||||
}
|
359
vendor/phpunit/php-code-coverage/tests/tests/CodeCoverageTest.php
vendored
Normal file
359
vendor/phpunit/php-code-coverage/tests/tests/CodeCoverageTest.php
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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\Driver;
|
||||
use SebastianBergmann\Environment\Runtime;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\CodeCoverage
|
||||
*/
|
||||
class CodeCoverageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var CodeCoverage
|
||||
*/
|
||||
private $coverage;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$runtime = new Runtime;
|
||||
|
||||
if (!$runtime->canCollectCodeCoverage()) {
|
||||
$this->markTestSkipped('No code coverage driver available');
|
||||
}
|
||||
|
||||
$this->coverage = new CodeCoverage;
|
||||
}
|
||||
|
||||
public function testCannotStopWithInvalidSecondArgument(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->coverage->stop(true, null);
|
||||
}
|
||||
|
||||
public function testCannotAppendWithInvalidArgument(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->coverage->append([], null);
|
||||
}
|
||||
|
||||
public function testCollect(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccount();
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1],
|
||||
],
|
||||
$coverage->getTests()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForFirstTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMergeReverseOrder(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForLastTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForFirstTwoTests());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccountInReverseOrder(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge2(): void
|
||||
{
|
||||
$coverage = new CodeCoverage(
|
||||
$this->createMock(Driver::class),
|
||||
new Filter
|
||||
);
|
||||
|
||||
$coverage->merge($this->getCoverageForBankAccount());
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getExpectedDataArrayForBankAccount(),
|
||||
$coverage->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[1, 5],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_without_ignore.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored3(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled(): void
|
||||
{
|
||||
$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'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testUseStatementsAreIgnored(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
13,
|
||||
16,
|
||||
23,
|
||||
24,
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
TEST_FILES_PATH . 'source_with_use_statements.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted(): void
|
||||
{
|
||||
$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->expectException(CoveredCodeNotExecutedException::class);
|
||||
|
||||
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
|
||||
}
|
||||
|
||||
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted(): void
|
||||
{
|
||||
$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->expectException(CoveredCodeNotExecutedException::class);
|
||||
|
||||
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ReflectionMethod
|
||||
*/
|
||||
private function getLinesToBeIgnored()
|
||||
{
|
||||
$getLinesToBeIgnored = new \ReflectionMethod(
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage',
|
||||
'getLinesToBeIgnored'
|
||||
);
|
||||
|
||||
$getLinesToBeIgnored->setAccessible(true);
|
||||
|
||||
return $getLinesToBeIgnored;
|
||||
}
|
||||
}
|
48
vendor/phpunit/php-code-coverage/tests/tests/Crap4jTest.php
vendored
Normal file
48
vendor/phpunit/php-code-coverage/tests/tests/Crap4jTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'BankAccount-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount')
|
||||
);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'ignored-lines-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines')
|
||||
);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml',
|
||||
$crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction')
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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\tests\Exception;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use SebastianBergmann\CodeCoverage\RuntimeException;
|
||||
use SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException;
|
||||
|
||||
final class UnintentionallyCoveredCodeExceptionTest extends TestCase
|
||||
{
|
||||
public function testCanConstructWithEmptyArray(): void
|
||||
{
|
||||
$unintentionallyCoveredUnits = [];
|
||||
|
||||
$exception = new UnintentionallyCoveredCodeException($unintentionallyCoveredUnits);
|
||||
|
||||
$this->assertInstanceOf(RuntimeException::class, $exception);
|
||||
$this->assertSame($unintentionallyCoveredUnits, $exception->getUnintentionallyCoveredUnits());
|
||||
$this->assertSame('', $exception->getMessage());
|
||||
}
|
||||
|
||||
public function testCanConstructWithNonEmptyArray(): void
|
||||
{
|
||||
$unintentionallyCoveredUnits = [
|
||||
'foo',
|
||||
'bar',
|
||||
'baz',
|
||||
];
|
||||
|
||||
$exception = new UnintentionallyCoveredCodeException($unintentionallyCoveredUnits);
|
||||
|
||||
$this->assertInstanceOf(RuntimeException::class, $exception);
|
||||
$this->assertSame($unintentionallyCoveredUnits, $exception->getUnintentionallyCoveredUnits());
|
||||
|
||||
$expected = <<<TXT
|
||||
- foo
|
||||
- bar
|
||||
- baz
|
||||
|
||||
TXT;
|
||||
|
||||
$this->assertSame($expected, $exception->getMessage());
|
||||
}
|
||||
}
|
213
vendor/phpunit/php-code-coverage/tests/tests/FilterTest.php
vendored
Normal file
213
vendor/phpunit/php-code-coverage/tests/tests/FilterTest.php
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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;
|
||||
use SebastianBergmann\FileIterator\Facade as FileIteratorFacade;
|
||||
|
||||
class FilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Filter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $files = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$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 . 'Crash.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_with_use_statements.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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$facade = new FileIteratorFacade;
|
||||
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertFalse($this->filter->isFiltered($this->files[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
*/
|
||||
public function testNotWhitelistedFileIsFiltered(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*
|
||||
* @ticket https://github.com/sebastianbergmann/php-code-coverage/issues/664
|
||||
*/
|
||||
public function testTryingToAddFileThatDoesNotExistDoesNotChangeFilter(): void
|
||||
{
|
||||
$filter = new Filter;
|
||||
|
||||
$filter->addFileToWhitelist('does_not_exist');
|
||||
|
||||
$this->assertEmpty($filter->getWhitelistedFiles());
|
||||
}
|
||||
}
|
102
vendor/phpunit/php-code-coverage/tests/tests/HTMLTest.php
vendored
Normal file
102
vendor/phpunit/php-code-coverage/tests/tests/HTMLTest.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'HTML';
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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): void
|
||||
{
|
||||
$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"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
48
vendor/phpunit/php-code-coverage/tests/tests/TextTest.php
vendored
Normal file
48
vendor/phpunit/php-code-coverage/tests/tests/TextTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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()))
|
||||
);
|
||||
}
|
||||
}
|
28
vendor/phpunit/php-code-coverage/tests/tests/UtilTest.php
vendored
Normal file
28
vendor/phpunit/php-code-coverage/tests/tests/UtilTest.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
$this->assertEquals(100, Util::percent(100, 0));
|
||||
$this->assertEquals(100, Util::percent(100, 100));
|
||||
$this->assertEquals(
|
||||
'100.00%',
|
||||
Util::percent(100, 100, true)
|
||||
);
|
||||
}
|
||||
}
|
97
vendor/phpunit/php-code-coverage/tests/tests/XmlTest.php
vendored
Normal file
97
vendor/phpunit/php-code-coverage/tests/tests/XmlTest.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* 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(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'XML';
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
$tmpFilesIterator = new \FilesystemIterator(self::$TEST_TMP_PATH);
|
||||
|
||||
foreach ($tmpFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
\unlink($fileInfo->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
public function testForBankAccountTest(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$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): void
|
||||
{
|
||||
$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