Skip to content

Commit

Permalink
Make the definedIn test actually test what it should test (#200)
Browse files Browse the repository at this point in the history
Static calls like `Royale::withCheese()` would require `return new StaticCalls` instead of `return new MethodCalls` in the test class' `getRule()` method otherwise they're irrelevant.

Follow-up to #198
  • Loading branch information
spaze committed May 28, 2023
2 parents 12a42e7 + 5d6389d commit cae3e66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 10 additions & 0 deletions tests/libs/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ class Bar

public const NAME = 'Bar';


public function foo(): void
{
}


public function bar(): void
{
}

}
7 changes: 4 additions & 3 deletions tests/src/disallowed-allow/methodCallsDefinedIn.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types = 1);

use Fiction\Pulp\Royale;
use Waldo\Foo\Bar;
use Waldo\Quux\Blade;

// allowed by path
Expand All @@ -10,8 +10,9 @@
$blade->server();

// allowed by path
Royale::withCheese();
Royale::leBigMac();
$bar = new Bar();
$bar->foo();
$bar->bar();

// allowed because it's a built-in function
time();
7 changes: 4 additions & 3 deletions tests/src/disallowed/methodCallsDefinedIn.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types = 1);

use Fiction\Pulp\Royale;
use Waldo\Foo\Bar;
use Waldo\Quux\Blade;

// disallowed based on definedIn
Expand All @@ -10,8 +10,9 @@
$blade->server();

// allowed because these are defined elsewhere
Royale::withCheese();
Royale::leBigMac();
$bar = new Bar();
$bar->foo();
$bar->bar();

// allowed because it's a built-in function
time();

0 comments on commit cae3e66

Please sign in to comment.