upgrade to laravel 7 and set branch to v2
This commit is contained in:
+33
-37
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,29 +7,25 @@
|
||||
* 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\Driver\Driver;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
use SebastianBergmann\CodeCoverage\Filter;
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
use SebastianBergmann\CodeCoverage\Node\Builder;
|
||||
use SebastianBergmann\CodeCoverage\TestCase;
|
||||
|
||||
class BuilderTest extends TestCase
|
||||
{
|
||||
protected $factory;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->factory = new Builder;
|
||||
}
|
||||
|
||||
public function testSomething()
|
||||
public function testSomething(): void
|
||||
{
|
||||
$root = $this->getCoverageForBankAccount()->getReport();
|
||||
|
||||
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
|
||||
$expectedPath = \rtrim(TEST_FILES_PATH, \DIRECTORY_SEPARATOR);
|
||||
$this->assertEquals($expectedPath, $root->getName());
|
||||
$this->assertEquals($expectedPath, $root->getPath());
|
||||
$this->assertEquals(10, $root->getNumExecutableLines());
|
||||
@@ -116,11 +112,11 @@ class BuilderTest extends TestCase
|
||||
'fullPackage' => '',
|
||||
'category' => '',
|
||||
'package' => '',
|
||||
'subpackage' => ''
|
||||
'subpackage' => '',
|
||||
],
|
||||
'link' => 'BankAccount.php.html#2',
|
||||
'className' => 'BankAccount'
|
||||
]
|
||||
'className' => 'BankAccount',
|
||||
],
|
||||
],
|
||||
$root->getClasses()
|
||||
);
|
||||
@@ -128,22 +124,22 @@ class BuilderTest extends TestCase
|
||||
$this->assertEquals([], $root->getFunctions());
|
||||
}
|
||||
|
||||
public function testNotCrashParsing()
|
||||
public function testNotCrashParsing(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForCrashParsing();
|
||||
$root = $coverage->getReport();
|
||||
$root = $coverage->getReport();
|
||||
|
||||
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
|
||||
$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';
|
||||
$data = $coverage->getData();
|
||||
$expectedFile = $expectedPath . \DIRECTORY_SEPARATOR . 'Crash.php';
|
||||
$this->assertSame([$expectedFile => [1 => [], 2 => []]], $data);
|
||||
}
|
||||
|
||||
public function testBuildDirectoryStructure()
|
||||
public function testBuildDirectoryStructure(): void
|
||||
{
|
||||
$s = \DIRECTORY_SEPARATOR;
|
||||
|
||||
@@ -159,20 +155,20 @@ class BuilderTest extends TestCase
|
||||
'src' => [
|
||||
'Money.php/f' => [],
|
||||
'MoneyBag.php/f' => [],
|
||||
'Foo' => [
|
||||
'Foo' => [
|
||||
'Bar' => [
|
||||
'Baz' => [
|
||||
'Foo.php/f' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
$method->invoke(
|
||||
$this->factory,
|
||||
[
|
||||
"src{$s}Money.php" => [],
|
||||
"src{$s}MoneyBag.php" => [],
|
||||
"src{$s}Money.php" => [],
|
||||
"src{$s}MoneyBag.php" => [],
|
||||
"src{$s}Foo{$s}Bar{$s}Baz{$s}Foo.php" => [],
|
||||
]
|
||||
)
|
||||
@@ -182,7 +178,7 @@ class BuilderTest extends TestCase
|
||||
/**
|
||||
* @dataProvider reducePathsProvider
|
||||
*/
|
||||
public function testReducePaths($reducedPaths, $commonPath, $paths)
|
||||
public function testReducePaths($reducedPaths, $commonPath, $paths): void
|
||||
{
|
||||
$method = new \ReflectionMethod(
|
||||
Builder::class,
|
||||
@@ -203,45 +199,45 @@ class BuilderTest extends TestCase
|
||||
|
||||
yield [
|
||||
[],
|
||||
".",
|
||||
[]
|
||||
'.',
|
||||
[],
|
||||
];
|
||||
|
||||
$prefixes = ["C:$s", "$s"];
|
||||
|
||||
foreach($prefixes as $p){
|
||||
foreach ($prefixes as $p) {
|
||||
yield [
|
||||
[
|
||||
"Money.php" => []
|
||||
'Money.php' => [],
|
||||
],
|
||||
"{$p}home{$s}sb{$s}Money{$s}",
|
||||
[
|
||||
"{$p}home{$s}sb{$s}Money{$s}Money.php" => []
|
||||
]
|
||||
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
"Money.php" => [],
|
||||
"MoneyBag.php" => []
|
||||
'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" => []
|
||||
]
|
||||
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
"Money.php" => [],
|
||||
"MoneyBag.php" => [],
|
||||
'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" => [],
|
||||
"{$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" => [],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -17,7 +16,7 @@ use SebastianBergmann\CodeCoverage\TestCase;
|
||||
*/
|
||||
class CloverTest extends TestCase
|
||||
{
|
||||
public function testCloverForBankAccountTest()
|
||||
public function testCloverForBankAccountTest(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
@@ -27,7 +26,7 @@ class CloverTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForFileWithIgnoredLines()
|
||||
public function testCloverForFileWithIgnoredLines(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
@@ -37,7 +36,7 @@ class CloverTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testCloverForClassWithAnonymousFunction()
|
||||
public function testCloverForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$clover = new Clover;
|
||||
|
||||
|
||||
+78
-218
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,15 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage;
|
||||
|
||||
require __DIR__ . '/../_files/BankAccount.php';
|
||||
require __DIR__ . '/../_files/BankAccountTest.php';
|
||||
|
||||
use SebastianBergmann\CodeCoverage\Driver\Driver;
|
||||
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
|
||||
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
|
||||
use SebastianBergmann\Environment\Runtime;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\CodeCoverage
|
||||
@@ -27,193 +22,32 @@ class CodeCoverageTest extends TestCase
|
||||
*/
|
||||
private $coverage;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$runtime = new Runtime;
|
||||
|
||||
if (!$runtime->canCollectCodeCoverage()) {
|
||||
$this->markTestSkipped('No code coverage driver available');
|
||||
}
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
public function testCannotStopWithInvalidSecondArgument()
|
||||
public function testCannotStopWithInvalidSecondArgument(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->coverage->stop(true, null);
|
||||
}
|
||||
|
||||
public function testCannotAppendWithInvalidArgument()
|
||||
public function testCannotAppendWithInvalidArgument(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->coverage->append([], null);
|
||||
}
|
||||
|
||||
public function testSetCacheTokens()
|
||||
{
|
||||
$this->coverage->setCacheTokens(true);
|
||||
|
||||
$this->assertAttributeEquals(true, 'cacheTokens', $this->coverage);
|
||||
}
|
||||
|
||||
public function testSetCheckForUnintentionallyCoveredCode()
|
||||
{
|
||||
$this->coverage->setCheckForUnintentionallyCoveredCode(true);
|
||||
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForUnintentionallyCoveredCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetCheckForMissingCoversAnnotation()
|
||||
{
|
||||
$this->coverage->setCheckForMissingCoversAnnotation(true);
|
||||
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForMissingCoversAnnotation',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetForceCoversAnnotation()
|
||||
{
|
||||
$this->coverage->setForceCoversAnnotation(true);
|
||||
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'forceCoversAnnotation',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetCheckForUnexecutedCoveredCode()
|
||||
{
|
||||
$this->coverage->setCheckForUnexecutedCoveredCode(true);
|
||||
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'checkForUnexecutedCoveredCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetAddUncoveredFilesFromWhitelist()
|
||||
{
|
||||
$this->coverage->setAddUncoveredFilesFromWhitelist(true);
|
||||
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'addUncoveredFilesFromWhitelist',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
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()
|
||||
public function testCollect(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccount();
|
||||
|
||||
@@ -227,13 +61,13 @@ class CodeCoverageTest extends TestCase
|
||||
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => -1],
|
||||
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1]
|
||||
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1],
|
||||
],
|
||||
$coverage->getTests()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
public function testMerge(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForFirstTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests());
|
||||
@@ -244,7 +78,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testMergeReverseOrder()
|
||||
public function testMergeReverseOrder(): void
|
||||
{
|
||||
$coverage = $this->getCoverageForBankAccountForLastTwoTests();
|
||||
$coverage->merge($this->getCoverageForBankAccountForFirstTwoTests());
|
||||
@@ -255,7 +89,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testMerge2()
|
||||
public function testMerge2(): void
|
||||
{
|
||||
$coverage = new CodeCoverage(
|
||||
$this->createMock(Driver::class),
|
||||
@@ -270,7 +104,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored()
|
||||
public function testGetLinesToBeIgnored(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
@@ -307,7 +141,7 @@ class CodeCoverageTest extends TestCase
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38
|
||||
38,
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
@@ -316,7 +150,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored2()
|
||||
public function testGetLinesToBeIgnored2(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[1, 5],
|
||||
@@ -327,7 +161,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnored3()
|
||||
public function testGetLinesToBeIgnored3(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
@@ -341,7 +175,7 @@ class CodeCoverageTest extends TestCase
|
||||
15,
|
||||
16,
|
||||
19,
|
||||
20
|
||||
20,
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
@@ -350,7 +184,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnoredOneLineAnnotations()
|
||||
public function testGetLinesToBeIgnoredOneLineAnnotations(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
@@ -382,7 +216,7 @@ class CodeCoverageTest extends TestCase
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
37
|
||||
37,
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
@@ -391,22 +225,7 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ReflectionMethod
|
||||
*/
|
||||
private function getLinesToBeIgnored()
|
||||
{
|
||||
$getLinesToBeIgnored = new \ReflectionMethod(
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage',
|
||||
'getLinesToBeIgnored'
|
||||
);
|
||||
|
||||
$getLinesToBeIgnored->setAccessible(true);
|
||||
|
||||
return $getLinesToBeIgnored;
|
||||
}
|
||||
|
||||
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled()
|
||||
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled(): void
|
||||
{
|
||||
$this->coverage->setDisableIgnoredLines(true);
|
||||
|
||||
@@ -431,7 +250,7 @@ class CodeCoverageTest extends TestCase
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
37
|
||||
37,
|
||||
],
|
||||
$this->getLinesToBeIgnored()->invoke(
|
||||
$this->coverage,
|
||||
@@ -440,7 +259,33 @@ class CodeCoverageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted()
|
||||
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);
|
||||
@@ -448,15 +293,15 @@ class CodeCoverageTest extends TestCase
|
||||
$data = [
|
||||
TEST_FILES_PATH . 'BankAccount.php' => [
|
||||
29 => -1,
|
||||
31 => -1
|
||||
]
|
||||
31 => -1,
|
||||
],
|
||||
];
|
||||
|
||||
$linesToBeCovered = [
|
||||
TEST_FILES_PATH . 'BankAccount.php' => [
|
||||
22,
|
||||
24
|
||||
]
|
||||
24,
|
||||
],
|
||||
];
|
||||
|
||||
$linesToBeUsed = [];
|
||||
@@ -466,7 +311,7 @@ class CodeCoverageTest extends TestCase
|
||||
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
|
||||
}
|
||||
|
||||
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted()
|
||||
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted(): void
|
||||
{
|
||||
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
$this->coverage->setCheckForUnexecutedCoveredCode(true);
|
||||
@@ -474,26 +319,41 @@ class CodeCoverageTest extends TestCase
|
||||
$data = [
|
||||
TEST_FILES_PATH . 'BankAccount.php' => [
|
||||
29 => -1,
|
||||
31 => -1
|
||||
]
|
||||
31 => -1,
|
||||
],
|
||||
];
|
||||
|
||||
$linesToBeCovered = [
|
||||
TEST_FILES_PATH . 'BankAccount.php' => [
|
||||
29,
|
||||
31
|
||||
]
|
||||
31,
|
||||
],
|
||||
];
|
||||
|
||||
$linesToBeUsed = [
|
||||
TEST_FILES_PATH . 'BankAccount.php' => [
|
||||
22,
|
||||
24
|
||||
]
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -17,7 +16,7 @@ use SebastianBergmann\CodeCoverage\TestCase;
|
||||
*/
|
||||
class Crap4jTest extends TestCase
|
||||
{
|
||||
public function testForBankAccountTest()
|
||||
public function testForBankAccountTest(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
@@ -27,7 +26,7 @@ class Crap4jTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
public function testForFileWithIgnoredLines(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
@@ -37,7 +36,7 @@ class Crap4jTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
public function testForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$crap4j = new Crap4j;
|
||||
|
||||
|
||||
Vendored
+51
@@ -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());
|
||||
}
|
||||
}
|
||||
+31
-16
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -25,9 +24,9 @@ class FilterTest extends TestCase
|
||||
*/
|
||||
private $files = [];
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}');
|
||||
$this->filter = \unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}');
|
||||
|
||||
$this->files = [
|
||||
TEST_FILES_PATH . 'BankAccount.php',
|
||||
@@ -70,8 +69,9 @@ class FilterTest extends TestCase
|
||||
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'
|
||||
TEST_FILES_PATH . 'source_without_namespace.php',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testAddingAFileToTheWhitelistWorks()
|
||||
public function testAddingAFileToTheWhitelistWorks(): void
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
|
||||
@@ -93,7 +93,7 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::removeFileFromWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testRemovingAFileFromTheWhitelistWorks()
|
||||
public function testRemovingAFileFromTheWhitelistWorks(): void
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->filter->removeFileFromWhitelist($this->files[0]);
|
||||
@@ -106,12 +106,12 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
* @depends testAddingAFileToTheWhitelistWorks
|
||||
*/
|
||||
public function testAddingADirectoryToTheWhitelistWorks()
|
||||
public function testAddingADirectoryToTheWhitelistWorks(): void
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
\sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::addFilesToWhitelist
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
*/
|
||||
public function testAddingFilesToTheWhitelistWorks()
|
||||
public function testAddingFilesToTheWhitelistWorks(): void
|
||||
{
|
||||
$facade = new FileIteratorFacade;
|
||||
|
||||
@@ -132,7 +132,7 @@ class FilterTest extends TestCase
|
||||
$this->filter->addFilesToWhitelist($files);
|
||||
|
||||
$whitelist = $this->filter->getWhitelist();
|
||||
sort($whitelist);
|
||||
\sort($whitelist);
|
||||
|
||||
$this->assertEquals($this->files, $whitelist);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
|
||||
* @depends testAddingADirectoryToTheWhitelistWorks
|
||||
*/
|
||||
public function testRemovingADirectoryFromTheWhitelistWorks()
|
||||
public function testRemovingADirectoryFromTheWhitelistWorks(): void
|
||||
{
|
||||
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
|
||||
$this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH);
|
||||
@@ -153,7 +153,7 @@ class FilterTest extends TestCase
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
|
||||
*/
|
||||
public function testIsFile()
|
||||
public function testIsFile(): void
|
||||
{
|
||||
$this->assertFalse($this->filter->isFile('vfs://root/a/path'));
|
||||
$this->assertFalse($this->filter->isFile('xdebug://debug-eval'));
|
||||
@@ -167,7 +167,7 @@ class FilterTest extends TestCase
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
*/
|
||||
public function testWhitelistedFileIsNotFiltered()
|
||||
public function testWhitelistedFileIsNotFiltered(): void
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertFalse($this->filter->isFiltered($this->files[0]));
|
||||
@@ -176,7 +176,7 @@ class FilterTest extends TestCase
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
*/
|
||||
public function testNotWhitelistedFileIsFiltered()
|
||||
public function testNotWhitelistedFileIsFiltered(): void
|
||||
{
|
||||
$this->filter->addFileToWhitelist($this->files[0]);
|
||||
$this->assertTrue($this->filter->isFiltered($this->files[1]));
|
||||
@@ -186,7 +186,7 @@ class FilterTest extends TestCase
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
|
||||
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
|
||||
*/
|
||||
public function testNonFilesAreFiltered()
|
||||
public function testNonFilesAreFiltered(): void
|
||||
{
|
||||
$this->assertTrue($this->filter->isFiltered('vfs://root/a/path'));
|
||||
$this->assertTrue($this->filter->isFiltered('xdebug://debug-eval'));
|
||||
@@ -195,4 +195,19 @@ class FilterTest extends TestCase
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
||||
+16
-17
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -16,14 +15,14 @@ class HTMLTest extends TestCase
|
||||
{
|
||||
private static $TEST_REPORT_PATH_SOURCE;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML';
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'HTML';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
@@ -35,13 +34,13 @@ class HTMLTest extends TestCase
|
||||
foreach ($tmpFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$pathname = $fileInfo->getPathname();
|
||||
$fileInfo->isDir() ? rmdir($pathname) : unlink($pathname);
|
||||
$fileInfo->isDir() ? \rmdir($pathname) : \unlink($pathname);
|
||||
}
|
||||
}
|
||||
|
||||
public function testForBankAccountTest()
|
||||
public function testForBankAccountTest(): void
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
|
||||
@@ -49,9 +48,9 @@ class HTMLTest extends TestCase
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
public function testForFileWithIgnoredLines(): void
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
|
||||
@@ -59,10 +58,10 @@ class HTMLTest extends TestCase
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
public function testForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$expectedFilesPath =
|
||||
self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
|
||||
$report = new Facade;
|
||||
$report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
|
||||
@@ -74,14 +73,14 @@ class HTMLTest extends TestCase
|
||||
* @param string $expectedFilesPath
|
||||
* @param string $actualFilesPath
|
||||
*/
|
||||
private function assertFilesEquals($expectedFilesPath, $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),
|
||||
\iterator_count($expectedFilesIterator),
|
||||
\iterator_count($actualFilesIterator),
|
||||
'Generated files and expected files not match'
|
||||
);
|
||||
|
||||
@@ -89,13 +88,13 @@ class HTMLTest extends TestCase
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$filename = $fileInfo->getFilename();
|
||||
|
||||
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
|
||||
$actualFile = $actualFilesPath . \DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
$this->assertFileExists($actualFile);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
$fileInfo->getPathname(),
|
||||
str_replace(PHP_EOL, "\n", file_get_contents($actualFile)),
|
||||
\str_replace(\PHP_EOL, "\n", \file_get_contents($actualFile)),
|
||||
"${filename} not match"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -17,33 +16,33 @@ use SebastianBergmann\CodeCoverage\TestCase;
|
||||
*/
|
||||
class TextTest extends TestCase
|
||||
{
|
||||
public function testTextForBankAccountTest()
|
||||
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()))
|
||||
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
|
||||
);
|
||||
}
|
||||
|
||||
public function testTextForFileWithIgnoredLines()
|
||||
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()))
|
||||
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
|
||||
);
|
||||
}
|
||||
|
||||
public function testTextForClassWithAnonymousFunction()
|
||||
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()))
|
||||
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -17,7 +16,7 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class UtilTest extends TestCase
|
||||
{
|
||||
public function testPercent()
|
||||
public function testPercent(): void
|
||||
{
|
||||
$this->assertEquals(100, Util::percent(100, 0));
|
||||
$this->assertEquals(100, Util::percent(100, 100));
|
||||
|
||||
+16
-17
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* 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;
|
||||
@@ -16,14 +15,14 @@ class XmlTest extends TestCase
|
||||
{
|
||||
private static $TEST_REPORT_PATH_SOURCE;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML';
|
||||
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'XML';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
@@ -31,13 +30,13 @@ class XmlTest extends TestCase
|
||||
|
||||
foreach ($tmpFilesIterator as $path => $fileInfo) {
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
unlink($fileInfo->getPathname());
|
||||
\unlink($fileInfo->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
public function testForBankAccountTest()
|
||||
public function testForBankAccountTest(): void
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
|
||||
@@ -45,9 +44,9 @@ class XmlTest extends TestCase
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForFileWithIgnoredLines()
|
||||
public function testForFileWithIgnoredLines(): void
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
|
||||
@@ -55,9 +54,9 @@ class XmlTest extends TestCase
|
||||
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
|
||||
}
|
||||
|
||||
public function testForClassWithAnonymousFunction()
|
||||
public function testForClassWithAnonymousFunction(): void
|
||||
{
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
|
||||
|
||||
$xml = new Facade('1.0.0');
|
||||
$xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
|
||||
@@ -69,14 +68,14 @@ class XmlTest extends TestCase
|
||||
* @param string $expectedFilesPath
|
||||
* @param string $actualFilesPath
|
||||
*/
|
||||
private function assertFilesEquals($expectedFilesPath, $actualFilesPath)
|
||||
private function assertFilesEquals($expectedFilesPath, $actualFilesPath): void
|
||||
{
|
||||
$expectedFilesIterator = new \FilesystemIterator($expectedFilesPath);
|
||||
$actualFilesIterator = new \FilesystemIterator($actualFilesPath);
|
||||
|
||||
$this->assertEquals(
|
||||
iterator_count($expectedFilesIterator),
|
||||
iterator_count($actualFilesIterator),
|
||||
\iterator_count($expectedFilesIterator),
|
||||
\iterator_count($actualFilesIterator),
|
||||
'Generated files and expected files not match'
|
||||
);
|
||||
|
||||
@@ -84,13 +83,13 @@ class XmlTest extends TestCase
|
||||
/* @var \SplFileInfo $fileInfo */
|
||||
$filename = $fileInfo->getFilename();
|
||||
|
||||
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
|
||||
$actualFile = $actualFilesPath . \DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
$this->assertFileExists($actualFile);
|
||||
|
||||
$this->assertStringMatchesFormatFile(
|
||||
$fileInfo->getPathname(),
|
||||
file_get_contents($actualFile),
|
||||
\file_get_contents($actualFile),
|
||||
"${filename} not match"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user