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 | |
| class LoanTest extends TestCase{ | |
| public function test_can_log_a_loan() | |
| { | |
| $user = factory(User::class)->create(); | |
| $wallet = factory(Wallet::class)->create([ | |
| 'user_id' => $user->id | |
| ]); |
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 | |
| class LoanTest extends TestCase | |
| { | |
| use DatabaseMigrations; | |
| public function test_can_log_a_loan() | |
| { | |
| $user = factory(User::class)->create(); | |
| $wallet = factory(Wallet::class)->create([ |
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 | |
| /** | |
| * @depends test_user_have_a_copy_of_the_default_categories | |
| */ | |
| public function test_users_can_get_their_categories_list() | |
| { | |
| factory(Category::class, 5)->create(); | |
| $this->passportAs($user = factory(User::class)->create()) |
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 | |
| // Option 1, write a simple comment | |
| public function test_users_can_get_their_categories_list() | |
| { | |
| factory(Category::class, 5)->create(); | |
| // once the user created, we will have a copy of the default categories | |
| $user = factory(User::class)->create(); | |
| // ... |
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 | |
| // add this method to your TestCase | |
| public function passportAs($user, $scopes = [], $guard = 'api') | |
| { | |
| Passport::actingAs($user, $scopes, $guard); | |
| return $this; | |
| } |
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 | |
| // add this macro to your service provider | |
| TestResponse::macro('assertJsonPaths', function ($path, $expected) { | |
| foreach ($this->json($path) as $real) { | |
| PHPUnit::assertEquals($expected, $real); | |
| } | |
| return $this; | |
| }); |
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 | |
| public function test_users_can_get_their_categories_list() | |
| { | |
| // ... | |
| $response = $this->get('api/categories') | |
| ->assertSuccessful() | |
| ->dump() | |
| ->assertJsonCount(5) |
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 | |
| public function test_users_can_get_their_categories_list() | |
| { | |
| factory(Category::class, 5)->create(); | |
| $user = factory(User::class)->create(); | |
| Passport::actingAs($user); | |
| $response = $this->get('api/categories'); | |
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 | |
| public function test_users_can_get_their_categories_list() | |
| { | |
| factory(Category::class, 5)->create(); | |
| $user = factory(User::class)->create(); | |
| Passport::actingAs($user); | |
| $response = $this->get('api/categories'); | |
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 | |
| class response { | |
| public $response = []; | |
| function __construct(){ | |
| $this->addNormalResponse(); | |
| return $this->response; | |
| } |