diff --git a/tests/Feature/Admin/ProfileTest.php b/tests/Feature/Admin/ProfileTest.php new file mode 100644 index 0000000..8dec11f --- /dev/null +++ b/tests/Feature/Admin/ProfileTest.php @@ -0,0 +1,70 @@ +routes = [ + 'me' => '/api/admin/profile', + ]; + + $this->admin = Admin::factory()->create(); + + Sanctum::actingAs($this->admin, [], 'admin'); + } + + /** + * An admin can get his profile. + * + * @return void + */ + public function testAnAdminCanGetHisProfile() + { + $response = $this + ->json('GET', $this->routes['me']) + ->assertStatus(Response::HTTP_OK) + ->assertJsonStructure([ + 'id', + 'name', + 'email', + 'avatar_url', + 'created_at', + ]) + ->assertJson([ + 'id' => $this->admin->id, + 'email' => $this->admin->email, + 'name' => $this->admin->name, + 'avatar_url' => null, + ]); + + $this->assertInstanceOf(AdminResource::class, $response->getOriginalContent()); + } +}