has(Contact::factory()) ->has(PersonalData::factory()) ->has(Settings::factory()) ->has(State::factory()) ->create(); /** @var Authenticator|MockObject $auth */ $auth = $this->createMock(Authenticator::class); $this->setExpects($auth, 'user', null, $user); $controller = new UsersController(new Response(), $auth); $response = $controller->self(); $this->validateApiResponse('/users/self', 'get', $response); $this->assertEquals(['application/json'], $response->getHeader('content-type')); $this->assertJson($response->getContent()); $data = json_decode($response->getContent(), true); $this->assertArrayHasKey('data', $data); $this->assertArrayHasKey('id', $data['data']); $this->assertEquals($user->id, $data['data']['id']); $this->assertArrayHasKey('dates', $data['data']); } }