Skip to content

Commit e0ea704

Browse files
Cleanup
1 parent b22cb52 commit e0ea704

File tree

7 files changed

+52
-55
lines changed

7 files changed

+52
-55
lines changed

tests/TestCase.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,18 @@
99
*/
1010
namespace SebastianBergmann\CodeCoverage;
1111

12-
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
13-
use SebastianBergmann\CodeCoverage\Test\Target\Target;
14-
use SebastianBergmann\CodeCoverage\Test\Target\TargetCollection;
15-
use function array_merge;
16-
use function range;
1712
use function rmdir;
1813
use function unlink;
1914
use BankAccount;
2015
use RecursiveDirectoryIterator;
2116
use RecursiveIteratorIterator;
17+
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
2218
use SebastianBergmann\CodeCoverage\Driver\Driver;
19+
use SebastianBergmann\CodeCoverage\Test\Target\Target;
20+
use SebastianBergmann\CodeCoverage\Test\Target\TargetCollection;
2321

2422
abstract class TestCase extends \PHPUnit\Framework\TestCase
2523
{
26-
protected static $TEST_TMP_PATH;
27-
28-
public static function setUpBeforeClass(): void
29-
{
30-
self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp';
31-
}
32-
3324
protected function getLineCoverageXdebugDataForBankAccount()
3425
{
3526
return [

tests/tests/Report/Html/EndToEndTest.php

+15-26
Original file line numberDiff line numberDiff line change
@@ -20,73 +20,62 @@
2020

2121
final class EndToEndTest extends TestCase
2222
{
23-
private static $TEST_REPORT_PATH_SOURCE;
24-
25-
public static function setUpBeforeClass(): void
26-
{
27-
parent::setUpBeforeClass();
28-
29-
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML';
30-
}
31-
3223
protected function tearDown(): void
3324
{
34-
parent::tearDown();
35-
3625
$this->removeTemporaryFiles();
3726
}
3827

3928
public function testLineCoverageForBankAccountTest(): void
4029
{
41-
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
30+
$expectedFilesPath = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
4231

4332
$report = new Facade;
44-
$report->process($this->getLineCoverageForBankAccount(), self::$TEST_TMP_PATH);
33+
$report->process($this->getLineCoverageForBankAccount(), TEST_FILES_PATH . 'tmp');
4534

46-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
35+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
4736
}
4837

4938
public function testPathCoverageForBankAccountTest(): void
5039
{
5140
$this->markTestIncomplete('This test fails after https://github.com/sebastianbergmann/php-code-coverage/pull/1037 and I have not figured out how to update it.');
5241

5342
/** @phpstan-ignore deadCode.unreachable */
54-
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'PathCoverageForBankAccount';
43+
$expectedFilesPath = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'PathCoverageForBankAccount';
5544

5645
$report = new Facade;
57-
$report->process($this->getPathCoverageForBankAccount(), self::$TEST_TMP_PATH);
46+
$report->process($this->getPathCoverageForBankAccount(), TEST_FILES_PATH . 'tmp');
5847

59-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
48+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
6049
}
6150

6251
public function testPathCoverageForSourceWithoutNamespace(): void
6352
{
64-
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'PathCoverageForSourceWithoutNamespace';
53+
$expectedFilesPath = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'PathCoverageForSourceWithoutNamespace';
6554

6655
$report = new Facade;
67-
$report->process($this->getPathCoverageForSourceWithoutNamespace(), self::$TEST_TMP_PATH);
56+
$report->process($this->getPathCoverageForSourceWithoutNamespace(), TEST_FILES_PATH . 'tmp');
6857

69-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
58+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
7059
}
7160

7261
public function testForFileWithIgnoredLines(): void
7362
{
74-
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
63+
$expectedFilesPath = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
7564

7665
$report = new Facade;
77-
$report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
66+
$report->process($this->getCoverageForFileWithIgnoredLines(), TEST_FILES_PATH . 'tmp');
7867

79-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
68+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
8069
}
8170

8271
public function testForClassWithAnonymousFunction(): void
8372
{
84-
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
73+
$expectedFilesPath = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
8574

8675
$report = new Facade;
87-
$report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
76+
$report->process($this->getCoverageForClassWithAnonymousFunction(), TEST_FILES_PATH . 'tmp');
8877

89-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
78+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
9079
}
9180

9281
private function assertFilesEquals(string $expectedFilesPath, string $actualFilesPath): void

tests/tests/Report/PhpTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function testPHPSerialisationProducesValidCode(): void
2626
$coverage = $this->getLineCoverageForBankAccount();
2727

2828
/* @noinspection UnusedFunctionResultInspection */
29-
(new PHP)->process($coverage, self::$TEST_TMP_PATH . '/serialized.php');
29+
(new PHP)->process($coverage, TEST_FILES_PATH . 'tmp/serialized.php');
3030

31-
$unserialized = require self::$TEST_TMP_PATH . '/serialized.php';
31+
$unserialized = require TEST_FILES_PATH . 'tmp/serialized.php';
3232

3333
$this->assertEquals($coverage, $unserialized);
3434
}
@@ -38,9 +38,9 @@ public function testPHPSerialisationProducesValidCodeWhenOutputIncludesSingleQuo
3838
$coverage = $this->getLineCoverageForFileWithEval();
3939

4040
/* @noinspection UnusedFunctionResultInspection */
41-
(new PHP)->process($coverage, self::$TEST_TMP_PATH . '/serialized.php');
41+
(new PHP)->process($coverage, TEST_FILES_PATH . 'tmp/serialized.php');
4242

43-
$unserialized = require self::$TEST_TMP_PATH . '/serialized.php';
43+
$unserialized = require TEST_FILES_PATH . 'tmp/serialized.php';
4444

4545
$this->assertEquals($coverage, $unserialized);
4646
}
@@ -53,12 +53,11 @@ public function testCacheDataNeverGetSaved(): void
5353
$coverage->getReport();
5454

5555
$refProperty = new ReflectionProperty($coverage, 'cachedReport');
56-
$refProperty->setAccessible(true);
5756

5857
$this->assertNotNull($refProperty->getValue($coverage));
5958

6059
/* @noinspection UnusedFunctionResultInspection */
61-
(new PHP)->process($coverage, self::$TEST_TMP_PATH . '/serialized.php');
60+
(new PHP)->process($coverage, TEST_FILES_PATH . 'tmp/serialized.php');
6261

6362
$this->assertNull($refProperty->getValue($coverage));
6463
}

tests/tests/Report/XmlTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function tearDown(): void
3131
{
3232
parent::tearDown();
3333

34-
foreach (new FilesystemIterator(self::$TEST_TMP_PATH) as $path => $fileInfo) {
34+
foreach (new FilesystemIterator(TEST_FILES_PATH . 'tmp') as $path => $fileInfo) {
3535
/* @var \SplFileInfo $fileInfo */
3636
unlink($fileInfo->getPathname());
3737
}
@@ -42,29 +42,29 @@ public function testForBankAccountTest(): void
4242
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
4343

4444
$xml = new Facade('1.0.0');
45-
$xml->process($this->getLineCoverageForBankAccount(), self::$TEST_TMP_PATH);
45+
$xml->process($this->getLineCoverageForBankAccount(), TEST_FILES_PATH . 'tmp');
4646

47-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
47+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
4848
}
4949

5050
public function testForFileWithIgnoredLines(): void
5151
{
5252
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
5353

5454
$xml = new Facade('1.0.0');
55-
$xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
55+
$xml->process($this->getCoverageForFileWithIgnoredLines(), TEST_FILES_PATH . 'tmp');
5656

57-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
57+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
5858
}
5959

6060
public function testForClassWithAnonymousFunction(): void
6161
{
6262
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
6363

6464
$xml = new Facade('1.0.0');
65-
$xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
65+
$xml->process($this->getCoverageForClassWithAnonymousFunction(), TEST_FILES_PATH . 'tmp');
6666

67-
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
67+
$this->assertFilesEquals($expectedFilesPath, TEST_FILES_PATH . 'tmp');
6868
}
6969

7070
private function assertFilesEquals(string $expectedFilesPath, string $actualFilesPath): void

tests/tests/StaticAnalysis/Value/ClassTest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ public function testMayUseTraits(): void
7979

8080
public function testMayHaveMethods(): void
8181
{
82-
$methods = [new Method('method', 0, 0, 'method(): void', Visibility::Public, 1)];
82+
$methods = [
83+
'method' => new Method(
84+
'method',
85+
0,
86+
0,
87+
'method(): void',
88+
Visibility::Public,
89+
1,
90+
),
91+
];
8392

8493
$this->assertSame($methods, $this->class(methods: $methods)->methods());
8594
}

tests/tests/StaticAnalysis/Value/InterfaceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testMayHaveParentInterfaces(): void
4646
{
4747
$interfaces = ['example\AnInterface'];
4848

49-
$this->assertSame($interfaces, $this->interface(parentInterfaces: $interfaces)->parentInterfaces());
49+
$this->assertSame($interfaces, $this->interface($interfaces)->parentInterfaces());
5050
}
5151

5252
/**

tests/tests/StaticAnalysis/Value/TraitTest.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ public function testHasEndLine(): void
4444

4545
public function testMayHaveMethods(): void
4646
{
47-
$methods = [new Method('method', 0, 0, 'method(): void', Visibility::Public, 1)];
47+
$methods = [
48+
'method' => new Method(
49+
'method',
50+
0,
51+
0,
52+
'method(): void',
53+
Visibility::Public,
54+
1,
55+
),
56+
];
4857

49-
$this->assertSame($methods, $this->trait(methods: $methods)->methods());
58+
$this->assertSame($methods, $this->trait($methods)->methods());
5059
}
5160

5261
/**

0 commit comments

Comments
 (0)