self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandTaskFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/command-tasks'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/CommandTask', '@id' => '/command-tasks', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateCommandTask(): 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]); $date = new \DateTimeImmutable(); $this->createClientWithCredentials()->request('POST', '/command-tasks',['json' => [ 'dateTime' => $date->format('Y-m-d H:i:s'), 'notes' => self::CMD_TASK_CREATE, 'commands' => [ $commandIri ] ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/CommandTaskOutput', '@type' => 'CommandTask', 'notes' => self::CMD_TASK_CREATE, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateCommandTask(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandTaskFactory::createOne(['notes' => self::CMD_TASK_CREATE]); $iri = $this->findIriBy(CommandTask::class, ['notes' => self::CMD_TASK_CREATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'notes' => self::CMD_TASK_UPDATE, ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'notes' => self::CMD_TASK_UPDATE ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteCommandTask(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); CommandTaskFactory::createOne(['notes' => self::CMD_TASK_DELETE]); $iri = $this->findIriBy(CommandTask::class, ['notes' => self::CMD_TASK_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(CommandTask::class)->findOneBy(['notes' => self::CMD_TASK_DELETE]) ); } }