Skip to content

Commit

Permalink
Add tests for $var::CONSTANT where $var is a string or an object
Browse files Browse the repository at this point in the history
  • Loading branch information
spaze committed Feb 4, 2021
1 parent 5b88c57 commit c0195f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/ClassConstantUsagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ protected function getRule(): Rule
'src/*-allow/*.*',
],
],
[
'constant' => 'Waldo\Quux\Blade::DECKARD',
'message' => 'maybe a replicant',
'allowIn' => [
'src/disallowed-allowed/*.php',
'src/*-allow/*.*',
],
],
]
);
}
Expand Down Expand Up @@ -78,6 +86,14 @@ public function testRule(): void
'Using Waldo\Quux\Blade::RUNNER is forbidden, not a replicant',
14,
],
[
'Using Waldo\Quux\Blade::DECKARD is forbidden, maybe a replicant',
18,
],
[
'Using Waldo\Quux\Blade::DECKARD is forbidden, maybe a replicant',
21,
],
]);
$this->analyse([__DIR__ . '/src/disallowed-allow/constantUsages.php'], []);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/src/disallowed/constantUsages.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
$blade = "\\Waldo\\{$quux}\\Blade";
$blade::DECKARD;

$orion = new Blade();
$orion::DECKARD;

// not a disallowed constant usage
Base::ALL;

Expand Down

0 comments on commit c0195f0

Please sign in to comment.