self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandGroupFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/command-groups'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/CommandGroup', '@id' => '/command-groups', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateCommandGroup(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandFactory::createOne(['name' => self::CMD_CREATE]); $commandIri = $this->findIriBy(Command::class, ['name' => self::CMD_CREATE]); $this->createClientWithCredentials()->request('POST', '/command-groups',['json' => [ 'name' => self::CMD_GROUP_CREATE, 'commands' => [ $commandIri ] ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/CommandGroupOutput', '@type' => 'CommandGroup', 'name' => self::CMD_GROUP_CREATE, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateCommandGroup(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandGroupFactory::createOne(['name' => self::CMD_GROUP_CREATE]); $iri = $this->findIriBy(CommandGroup::class, ['name' => self::CMD_GROUP_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::CMD_GROUP_UPDATE, ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::CMD_GROUP_UPDATE ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteCommandGroup(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandGroupFactory::createOne(['name' => self::CMD_GROUP_DELETE]); $iri = $this->findIriBy(CommandGroup::class, ['name' => self::CMD_GROUP_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(CommandGroup::class)->findOneBy(['name' => self::CMD_GROUP_DELETE]) ); } }