self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); ImageFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/images'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/Image', '@id' => '/images', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateImage(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); ClientFactory::createOne(['name' => self::CLIENT]); $clientIri = $this->findIriBy(Client::class, ['name' => self::CLIENT]); SoftwareProfileFactory::createOne(['description' => self::SOFTWARE_PROFILE]); $swPIri = $this->findIriBy(SoftwareProfile::class, ['description' => self::SOFTWARE_PROFILE]); OrganizationalUnitFactory::createOne(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]); $ouIri = $this->findIriBy(OrganizationalUnit::class, ['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]); $this->createClientWithCredentials()->request('POST', '/images',['json' => [ 'name' => self::IMAGE_CREATE, 'size' => 123, 'path' => '/path/to/image', 'client' => $clientIri, 'softwareProfile' => $swPIri, 'organizationalUnit' => $ouIri, ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/ImageOutput', '@type' => 'Image', 'name' => self::IMAGE_CREATE, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateImage(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); ImageFactory::createOne(['name' => self::IMAGE_CREATE]); $iri = $this->findIriBy(Image::class, ['name' => self::IMAGE_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::IMAGE_UPDATE, 'size' => 123 ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::IMAGE_UPDATE, 'size' => 123 ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteImage(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); ImageFactory::createOne(['name' => self::IMAGE_DELETE]); $iri = $this->findIriBy(Image::class, ['name' => self::IMAGE_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(Client::class)->findOneBy(['name' => self::IMAGE_DELETE]) ); } }