getAppInstance(); /** @var Container $container */ $container = $app->getContainer(); $user = new User(1, 'bill.gates', 'Bill', 'Gates'); $userRepositoryProphecy = $this->prophesize(UserRepository::class); $userRepositoryProphecy ->findAll() ->willReturn([$user]) ->shouldBeCalledOnce(); $container->set(UserRepository::class, $userRepositoryProphecy->reveal()); $request = $this->createRequest('GET', '/users'); $response = $app->handle($request); $payload = (string) $response->getBody(); $expectedPayload = new ActionPayload(200, [$user]); $serializedPayload = json_encode($expectedPayload, JSON_PRETTY_PRINT); $this->assertEquals($serializedPayload, $payload); } }