Skip to content

Commit 62e357f

Browse files
committed
squash tests
1 parent 5502f07 commit 62e357f

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

tests/Rule/Data/DisallowDivisionByLiteralZeroRule/missing-error.php renamed to tests/Rule/Data/DisallowDivisionByLiteralZeroRule/error-message.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace DisallowDivisionByLiteralZeroRule;
44

5-
function testMissingError(): void
5+
function testErrorMessage(): void
66
{
77
$a = 10;
8+
$invalidDivision = $a / 0; // error: This error should not be reported
89
$validDivision = $a / 2; // error: Division by literal zero is not allowed
910
}

tests/Rule/Data/DisallowDivisionByLiteralZeroRule/extra-error.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/RuleTestCaseTest.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,27 @@ public function testAutofix(): void
5353
self::assertFileEquals($expectedFile, $tmpFile);
5454
}
5555

56-
public function testErrorMessageWithExtraError(): void
56+
public function testErrorMessageFormat(): void
5757
{
58-
$testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/extra-error.php';
58+
$testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/error-message.php';
5959

6060
try {
6161
$this->analyzeFiles([$testFile]);
62-
self::fail('Expected assertion to fail due to extra error');
62+
self::fail('Expected assertion to fail');
6363
} catch (AssertionFailedError $e) { // @phpstan-ignore catch.internalClass
64-
self::assertStringContainsString('New errors reported:', $e->getMessage());
65-
self::assertStringContainsString('Division by literal zero is not allowed', $e->getMessage());
66-
}
67-
}
64+
$expectedMessage = <<<MSG
65+
Errors in file {$testFile} do not match:
6866
69-
public function testErrorMessageWithMissingError(): void
70-
{
71-
$testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/missing-error.php';
67+
New errors reported:
68+
08: Division by literal zero is not allowed
7269
73-
try {
74-
$this->analyzeFiles([$testFile]);
75-
self::fail('Expected assertion to fail due to missing error');
76-
} catch (AssertionFailedError $e) { // @phpstan-ignore catch.internalClass
77-
self::assertStringContainsString('Errors not reported:', $e->getMessage());
78-
self::assertStringContainsString('Division by literal zero is not allowed', $e->getMessage());
70+
Errors not reported:
71+
08: This error should not be reported
72+
09: Division by literal zero is not allowed
73+
74+
75+
MSG;
76+
self::assertStringContainsString($expectedMessage, $e->getMessage());
7977
}
8078
}
8179

0 commit comments

Comments
 (0)