self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); MenuFactory::createMany(10); $this->createClientWithCredentials()->request('GET', '/menus'); $this->assertResponseStatusCodeSame(Response::HTTP_OK); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/Menu', '@id' => '/menus', '@type' => 'hydra:Collection', 'hydra:totalItems' => 10, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testCreateMenu(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); $this->createClientWithCredentials()->request('POST', '/menus',['json' => [ 'name' => self::MENU_CREATE, 'resolution' => "1920x1080", ]]); $this->assertResponseStatusCodeSame(201); $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); $this->assertJsonContains([ '@context' => '/contexts/MenuOutput', '@type' => 'Menu', 'name' => self::MENU_CREATE, ]); } /** * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ public function testUpdateMenu(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); MenuFactory::createOne(['name' => self::MENU_UPDATE, 'resolution' => "1920x1080"]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_UPDATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::MENU_UPDATE, 'resolution' => '1080x768' ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::MENU_UPDATE, 'resolution' => '1080x768' ]); } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function testDeleteMenu(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); MenuFactory::createOne(['name' => self::MENU_DELETE, 'resolution' => "1920x1080"]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri); $this->assertResponseStatusCodeSame(204); $this->assertNull( static::getContainer()->get('doctrine')->getRepository(Menu::class)->findOneBy(['name' => self::MENU_DELETE]) ); } }