self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/software'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/Software', '@id' => '/software', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateSoftware(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); $this->createClientWithCredentials()->request('POST', '/software',['json' => [ 'name' => self::SW_CREATE, 'type' => SoftwareTypes::FILE ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/SoftwareOutput', '@type' => 'Software', 'name' => self::SW_CREATE, 'type' => SoftwareTypes::FILE ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateSoftware(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareFactory::createOne(['name' => self::SW_CREATE]); $iri = $this->findIriBy(Software::class, ['name' => self::SW_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::SW_UPDATE, ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::SW_UPDATE, ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteSoftware(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareFactory::createOne(['name' => self::SW_DELETE]); $iri = $this->findIriBy(Software::class, ['name' => self::SW_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(Software::class)->findOneBy(['name' => self::SW_DELETE]) ); } }