entityManager = static::getContainer()->get(EntityManagerInterface::class); } public function testGetCollection(): void { static::createClient()->request('GET', '/v4/projects'); $this->assertResponseIsSuccessful(); $this->assertJsonContains(['@id' => '/v4/projects']); $this->assertJsonContains(['@type' => 'hydra:Collection']); $this->assertJsonContains(['hydra:totalItems' => 0]); $this->assertJsonContains(['hydra:member' => []]); $owner = new User(); $owner->setUsername('test_user'); $owner->setEmail('testuser@example.com'); $owner->setPassword('projectapitestuserpassword'); $project = new Project(); $project->setTitle('Test Project'); $project->setOwner($owner); $project->setStatus(ProjectStatus::Editing); $this->entityManager->persist($owner); $this->entityManager->persist($project); $this->entityManager->flush(); static::createClient()->request('GET', '/v4/projects'); $this->assertResponseIsSuccessful(); $this->assertJsonContains(['hydra:totalItems' => 1]); $this->assertJsonContains(['hydra:member' => [ [ 'title' => 'Test Project', 'accounting' => [], 'status' => ProjectStatus::Editing->value ] ]]); } public function testPostUnauthorized() { $client = static::createClient(); $client->request( 'POST', '/v4/projects', [ 'json' => [ 'title' => 'ProjectApiTest Project', ] ] ); $this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED); } }