Skip to content

Commit 41c9edf

Browse files
authored
[TASK] Add tests for DeclarationBlock constructor (#1350)
The class extends `RuleSet`, but the constructor behaviour needs to be tested for each class.
1 parent c5bce4c commit 41c9edf

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Unit/RuleSet/DeclarationBlockTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,44 @@ public function implementsPositionable(): void
5353
self::assertInstanceOf(Positionable::class, $this->subject);
5454
}
5555

56+
/**
57+
* @test
58+
*/
59+
public function getLineNumberByDefaultReturnsNull(): void
60+
{
61+
$result = $this->subject->getLineNumber();
62+
63+
self::assertNull($result);
64+
}
65+
66+
/**
67+
* @return array<non-empty-string, array{0: int<1, max>|null}>
68+
*/
69+
public function provideLineNumber(): array
70+
{
71+
return [
72+
'null' => [null],
73+
'line 1' => [1],
74+
'line 42' => [42],
75+
];
76+
}
77+
78+
/**
79+
* @test
80+
*
81+
* @param int<1, max>|null $lineNumber
82+
*
83+
* @dataProvider provideLineNumber
84+
*/
85+
public function getLineNumberReturnsLineNumberPassedToConstructor(?int $lineNumber): void
86+
{
87+
$subject = new DeclarationBlock($lineNumber);
88+
89+
$result = $subject->getLineNumber();
90+
91+
self::assertSame($lineNumber, $result);
92+
}
93+
5694
/**
5795
* @return array<non-empty-string, array{0: non-empty-string}>
5896
*/

0 commit comments

Comments
 (0)