Created
May 2, 2018 09:18
-
-
Save devmsh/4aa24a42209220f9b2c24789be973f5f to your computer and use it in GitHub Desktop.
quicker Laravel Passport test using fake token generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| abstract class TestCase extends BaseTestCase{ | |
| public function mockPassportToken(): void | |
| { | |
| $factory = \Mockery::mock(PersonalAccessTokenFactory::class); | |
| $factory->shouldReceive('make')->with(\Mockery::any(), \Mockery::any(), \Mockery::any())->andReturn(new PersonalAccessTokenResult("123", "123")); | |
| app()->instance(PersonalAccessTokenFactory::class, $factory); | |
| } | |
| } | |
| // after adding this method, you can call mockPassprtToken nested to using passport::install for the test that use passport |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment