diff --git a/tests/Unit/RuleTest.php b/tests/Unit/RuleTest.php index b5d823c..77928f1 100644 --- a/tests/Unit/RuleTest.php +++ b/tests/Unit/RuleTest.php @@ -9,12 +9,12 @@ use Closure; use DateTime; use Illuminate\Auth\AuthManager; -use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Contracts\Validation\InvokableRule; use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Auth\User; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Illuminate\Validation\Rules\Dimensions; @@ -478,7 +478,11 @@ public static function ruleDataProvider(): array 'data' => 'value-a', 'rules' => function () { $mockUser = new User; - $this->mockGateAllows(true, 'modify', [User::class, $mockUser, 'value-a']); + + Gate::expects('allows') + ->once() + ->with('modify', [User::class, $mockUser, 'value-a']) + ->andReturn(true); return RuleSet::create()->can('modify', User::class, $mockUser); }, @@ -488,7 +492,11 @@ public static function ruleDataProvider(): array 'data' => 'value-b', 'rules' => function () { $mockUser = new User; - $this->mockGateAllows(false, 'modify', [User::class, $mockUser, 'value-b']); + + Gate::expects('allows') + ->once() + ->with('modify', [User::class, $mockUser, 'value-b']) + ->andReturn(false); return RuleSet::create()->can('modify', User::class, $mockUser); }, @@ -3114,18 +3122,4 @@ public function getClientOriginalExtension(): string } }; } - - private function mockGateAllows(bool $return, ...$arguments): void - { - $gate = $this->mock(Gate::class); - - $gate - ->expects('allows') - ->once() - ->with(...$arguments) - ->andReturn($return) - ->getMock(); - - $this->app->instance(Gate::class, $gate); - } }