self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareProfileFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/software-profiles'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/SoftwareProfile', '@id' => '/software-profiles', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateSoftwareProfile(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); OrganizationalUnitFactory::createOne(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]); $ouIri = $this->findIriBy(OrganizationalUnit::class, ['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]); $this->createClientWithCredentials()->request('POST', '/software-profiles',['json' => [ 'description' => self::SW_PROFILE_CREATE, 'organizationalUnit' => $ouIri ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/SoftwareProfileOutput', '@type' => 'SoftwareProfile', 'description' => self::SW_PROFILE_CREATE ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateSoftwareProfile(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareProfileFactory::createOne(['description' => self::SW_PROFILE_CREATE]); $iri = $this->findIriBy(SoftwareProfile::class, ['description' => self::SW_PROFILE_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'description' => self::SW_PROFILE_UPDATE, ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'description' => self::SW_PROFILE_UPDATE, ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteSoftwareProfile(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); SoftwareProfileFactory::createOne(['description' => self::SW_PROFILE_DELETE]); $iri = $this->findIriBy(SoftwareProfile::class, ['description' => self::SW_PROFILE_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(SoftwareProfile::class)->findOneBy(['description' => self::SW_PROFILE_DELETE]) ); } }