Skip to content

Commit 5d2a7de

Browse files
committed
test: Add tests for new option
1 parent 72a4480 commit 5d2a7de

File tree

9 files changed

+89
-0
lines changed

9 files changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Error to escape ''\#$#'
5+
count: 1
6+
path: ../app/config.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- another.identifier.neon
3+
- missing-identifier.neon
4+
- sample.identifier.neon
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Error 3$#'
5+
count: 1
6+
path: ../app/index.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Error simple$#'
5+
count: 2
6+
path: ../app/file.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types = 1);
2+
3+
$ignoreErrors = [];
4+
$ignoreErrors[] = [
5+
'message' => '#^Error to escape \'\\#$#',
6+
'count' => 1,
7+
'path' => __DIR__ . '/../app/config.php',
8+
];
9+
10+
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php declare(strict_types = 1);
2+
3+
return ['includes' => [
4+
__DIR__ . '/another.identifier.php',
5+
__DIR__ . '/missing-identifier.php',
6+
__DIR__ . '/sample.identifier.php',
7+
]];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types = 1);
2+
3+
$ignoreErrors = [];
4+
$ignoreErrors[] = [
5+
'message' => '#^Error 3$#',
6+
'count' => 1,
7+
'path' => __DIR__ . '/../app/index.php',
8+
];
9+
10+
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types = 1);
2+
3+
$ignoreErrors = [];
4+
$ignoreErrors[] = [
5+
'message' => '#^Error simple$#',
6+
'count' => 2,
7+
'path' => __DIR__ . '/../app/file.php',
8+
];
9+
10+
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

tests/SplitterTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,36 @@ public function testBinaryWithPhp(): void
4242
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-php/missing-identifier.php', $fakeRoot . '/baselines/missing-identifier.php');
4343
}
4444

45+
public function testBinaryWithNeonNoErrorCount(): void
46+
{
47+
$fakeRoot = $this->prepareSampleFolder();
48+
$squashed = $this->getSampleErrors();
49+
50+
file_put_contents($fakeRoot . '/baselines/loader.neon', Neon::encode($squashed));
51+
52+
$this->runCommand('php bin/split-phpstan-baseline ' . $fakeRoot . '/baselines/loader.neon --no-error-count', __DIR__ . '/..', 0);
53+
54+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-neon-no-error-count/loader.neon', $fakeRoot . '/baselines/loader.neon');
55+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-neon-no-error-count/sample.identifier.neon', $fakeRoot . '/baselines/sample.identifier.neon');
56+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-neon-no-error-count/another.identifier.neon', $fakeRoot . '/baselines/another.identifier.neon');
57+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-neon-no-error-count/missing-identifier.neon', $fakeRoot . '/baselines/missing-identifier.neon');
58+
}
59+
60+
public function testBinaryWithPhpNoErrorCount(): void
61+
{
62+
$fakeRoot = $this->prepareSampleFolder();
63+
$squashed = $this->getSampleErrors();
64+
65+
file_put_contents($fakeRoot . '/baselines/loader.php', '<?php return ' . var_export($squashed, true) . ';');
66+
67+
$this->runCommand('php bin/split-phpstan-baseline ' . $fakeRoot . '/baselines/loader.php --no-error-count', __DIR__ . '/..', 0);
68+
69+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-php-no-error-count/loader.php', $fakeRoot . '/baselines/loader.php');
70+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-php-no-error-count/sample.identifier.php', $fakeRoot . '/baselines/sample.identifier.php');
71+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-php-no-error-count/another.identifier.php', $fakeRoot . '/baselines/another.identifier.php');
72+
self::assertFileEquals(__DIR__ . '/Rule/data/baselines-php-no-error-count/missing-identifier.php', $fakeRoot . '/baselines/missing-identifier.php');
73+
}
74+
4575
public function testSplitter(): void
4676
{
4777
$folder = $this->prepareSampleFolder();

0 commit comments

Comments
 (0)