From 38bf6e23ad2fdefc025026824bc08dd31133c1df Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Mon, 16 Dec 2024 10:59:34 +0100 Subject: [PATCH] refs #1288. Updated Menu entity and API --- migrations/Version20241216080914.php | 31 ++++++++++++++++++++++++++++ src/Dto/Input/MenuInput.php | 7 ------- src/Dto/Output/MenuOutput.php | 4 ---- src/Entity/Menu.php | 15 -------------- src/Factory/MenuFactory.php | 1 - tests/Functional/MenuTest.php | 6 ++---- 6 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 migrations/Version20241216080914.php diff --git a/migrations/Version20241216080914.php b/migrations/Version20241216080914.php new file mode 100644 index 0000000..328c8fb --- /dev/null +++ b/migrations/Version20241216080914.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE menu DROP title'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE menu ADD title VARCHAR(255) NOT NULL'); + } +} diff --git a/src/Dto/Input/MenuInput.php b/src/Dto/Input/MenuInput.php index d09d78e..762d868 100644 --- a/src/Dto/Input/MenuInput.php +++ b/src/Dto/Input/MenuInput.php @@ -16,11 +16,6 @@ final class MenuInput #[ApiProperty(description: 'The name of the menu', example: "Menu 1")] public ?string $name = null; - #[Assert\NotNull()] - #[Groups(['menu:write'])] - #[ApiProperty(description: 'The title of the menu', example: "Menu 1 title")] - public ?string $title = null; - #[Groups(['menu:write'])] #[ApiProperty(description: 'Comments of the menu', example: "Menu 1 comments")] public ?string $comments = null; @@ -45,7 +40,6 @@ final class MenuInput } $this->name = $menu->getName(); - $this->title = $menu->getTitle(); $this->comments = $menu->getComments(); $this->resolution = $menu->getResolution(); $this->publicUrl = $menu->getPublicUrl(); @@ -59,7 +53,6 @@ final class MenuInput } $menu->setName($this->name); - $menu->setTitle($this->title); $menu->setComments($this->comments); $menu->setResolution($this->resolution); $menu->setPublicUrl($this->publicUrl); diff --git a/src/Dto/Output/MenuOutput.php b/src/Dto/Output/MenuOutput.php index 309fb45..03b52f5 100644 --- a/src/Dto/Output/MenuOutput.php +++ b/src/Dto/Output/MenuOutput.php @@ -13,9 +13,6 @@ final class MenuOutput extends AbstractOutput #[Groups(['menu:read', 'organizational-unit:read'])] public string $name; - #[Groups(['menu:read'])] - public ?string $title = null; - #[Groups(['menu:read'])] public string $resolution; @@ -39,7 +36,6 @@ public function __construct(Menu $menu) parent::__construct($menu); $this->name = $menu->getName(); - $this->title = $menu->getTitle(); $this->resolution = $menu->getResolution(); $this->comments = $menu->getComments(); $this->publicUrl = $menu->getPublicUrl(); diff --git a/src/Entity/Menu.php b/src/Entity/Menu.php index 53c123a..7798e14 100644 --- a/src/Entity/Menu.php +++ b/src/Entity/Menu.php @@ -12,9 +12,6 @@ class Menu extends AbstractEntity { use NameableTrait; - #[ORM\Column(length: 255)] - private ?string $title = null; - #[ORM\Column(length: 255)] private ?string $resolution = null; @@ -39,18 +36,6 @@ class Menu extends AbstractEntity $this->clients = new ArrayCollection(); } - public function getTitle(): ?string - { - return $this->title; - } - - public function setTitle(string $title): static - { - $this->title = $title; - - return $this; - } - public function getResolution(): ?string { return $this->resolution; diff --git a/src/Factory/MenuFactory.php b/src/Factory/MenuFactory.php index 37f8125..6b38f41 100644 --- a/src/Factory/MenuFactory.php +++ b/src/Factory/MenuFactory.php @@ -33,7 +33,6 @@ final class MenuFactory extends ModelFactory 'createdAt' => self::faker()->dateTime(), 'name' => self::faker()->text(255), 'resolution' => self::faker()->text(255), - 'title' => self::faker()->text(255), 'updatedAt' => self::faker()->dateTime(), ]; } diff --git a/tests/Functional/MenuTest.php b/tests/Functional/MenuTest.php index 4276047..ffdd305 100644 --- a/tests/Functional/MenuTest.php +++ b/tests/Functional/MenuTest.php @@ -65,7 +65,6 @@ class MenuTest extends AbstractTest $this->createClientWithCredentials()->request('POST', '/menus',['json' => [ 'name' => self::MENU_CREATE, - 'title' => self::MENU_CREATE, 'resolution' => "1920x1080", ]]); @@ -75,7 +74,6 @@ class MenuTest extends AbstractTest '@context' => '/contexts/MenuOutput', '@type' => 'Menu', 'name' => self::MENU_CREATE, - 'title' => self::MENU_CREATE, ]); } @@ -90,7 +88,7 @@ class MenuTest extends AbstractTest { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); - MenuFactory::createOne(['name' => self::MENU_UPDATE, 'title' => self::MENU_UPDATE, 'resolution' => "1920x1080"]); + MenuFactory::createOne(['name' => self::MENU_UPDATE, 'resolution' => "1920x1080"]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_UPDATE]); $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ @@ -117,7 +115,7 @@ class MenuTest extends AbstractTest { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); - MenuFactory::createOne(['name' => self::MENU_DELETE, 'title' => self::MENU_DELETE, 'resolution' => "1920x1080"]); + MenuFactory::createOne(['name' => self::MENU_DELETE, 'resolution' => "1920x1080"]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_DELETE]); $this->createClientWithCredentials()->request('DELETE', $iri);