self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); OperativeSystemFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/operative-systems'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/OperativeSystem', '@id' => '/operative-systems', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateOperativeSystem(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); $this->createClientWithCredentials()->request('POST', '/operative-systems',['json' => [ 'name' => self::OS_CREATE, ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/OperativeSystemOutput', '@type' => 'OperativeSystem', 'name' => self::OS_CREATE ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateOperativeSystem(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); OperativeSystemFactory::createOne(['name' => self::OS_CREATE]); $iri = $this->findIriBy(OperativeSystem::class, ['name' => self::OS_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::OS_UPDATE, ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::OS_UPDATE, ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteOperativeSystem(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); OperativeSystemFactory::createOne(['name' => self::OS_DELETE]); $iri = $this->findIriBy(OperativeSystem::class, ['name' => self::OS_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(OperativeSystem::class)->findOneBy(['name' => self::OS_DELETE]) ); } }