refs #1288. Updated Menu entity and API
testing/ogcore-api/pipeline/head This commit looks good Details

pull/18/head
Manuel Aranda Rosales 2024-12-16 10:59:34 +01:00
parent 19c94561cd
commit 38bf6e23ad
6 changed files with 33 additions and 31 deletions

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241216080914 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View File

@ -16,11 +16,6 @@ final class MenuInput
#[ApiProperty(description: 'The name of the menu', example: "Menu 1")] #[ApiProperty(description: 'The name of the menu', example: "Menu 1")]
public ?string $name = null; 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'])] #[Groups(['menu:write'])]
#[ApiProperty(description: 'Comments of the menu', example: "Menu 1 comments")] #[ApiProperty(description: 'Comments of the menu', example: "Menu 1 comments")]
public ?string $comments = null; public ?string $comments = null;
@ -45,7 +40,6 @@ final class MenuInput
} }
$this->name = $menu->getName(); $this->name = $menu->getName();
$this->title = $menu->getTitle();
$this->comments = $menu->getComments(); $this->comments = $menu->getComments();
$this->resolution = $menu->getResolution(); $this->resolution = $menu->getResolution();
$this->publicUrl = $menu->getPublicUrl(); $this->publicUrl = $menu->getPublicUrl();
@ -59,7 +53,6 @@ final class MenuInput
} }
$menu->setName($this->name); $menu->setName($this->name);
$menu->setTitle($this->title);
$menu->setComments($this->comments); $menu->setComments($this->comments);
$menu->setResolution($this->resolution); $menu->setResolution($this->resolution);
$menu->setPublicUrl($this->publicUrl); $menu->setPublicUrl($this->publicUrl);

View File

@ -13,9 +13,6 @@ final class MenuOutput extends AbstractOutput
#[Groups(['menu:read', 'organizational-unit:read'])] #[Groups(['menu:read', 'organizational-unit:read'])]
public string $name; public string $name;
#[Groups(['menu:read'])]
public ?string $title = null;
#[Groups(['menu:read'])] #[Groups(['menu:read'])]
public string $resolution; public string $resolution;
@ -39,7 +36,6 @@ public function __construct(Menu $menu)
parent::__construct($menu); parent::__construct($menu);
$this->name = $menu->getName(); $this->name = $menu->getName();
$this->title = $menu->getTitle();
$this->resolution = $menu->getResolution(); $this->resolution = $menu->getResolution();
$this->comments = $menu->getComments(); $this->comments = $menu->getComments();
$this->publicUrl = $menu->getPublicUrl(); $this->publicUrl = $menu->getPublicUrl();

View File

@ -12,9 +12,6 @@ class Menu extends AbstractEntity
{ {
use NameableTrait; use NameableTrait;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $resolution = null; private ?string $resolution = null;
@ -39,18 +36,6 @@ class Menu extends AbstractEntity
$this->clients = new ArrayCollection(); $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 public function getResolution(): ?string
{ {
return $this->resolution; return $this->resolution;

View File

@ -33,7 +33,6 @@ final class MenuFactory extends ModelFactory
'createdAt' => self::faker()->dateTime(), 'createdAt' => self::faker()->dateTime(),
'name' => self::faker()->text(255), 'name' => self::faker()->text(255),
'resolution' => self::faker()->text(255), 'resolution' => self::faker()->text(255),
'title' => self::faker()->text(255),
'updatedAt' => self::faker()->dateTime(), 'updatedAt' => self::faker()->dateTime(),
]; ];
} }

View File

@ -65,7 +65,6 @@ class MenuTest extends AbstractTest
$this->createClientWithCredentials()->request('POST', '/menus',['json' => [ $this->createClientWithCredentials()->request('POST', '/menus',['json' => [
'name' => self::MENU_CREATE, 'name' => self::MENU_CREATE,
'title' => self::MENU_CREATE,
'resolution' => "1920x1080", 'resolution' => "1920x1080",
]]); ]]);
@ -75,7 +74,6 @@ class MenuTest extends AbstractTest
'@context' => '/contexts/MenuOutput', '@context' => '/contexts/MenuOutput',
'@type' => 'Menu', '@type' => 'Menu',
'name' => self::MENU_CREATE, '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]]); 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]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_UPDATE]);
$this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ $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]]); 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]); $iri = $this->findIriBy(Menu::class, ['name' => self::MENU_DELETE]);
$this->createClientWithCredentials()->request('DELETE', $iri); $this->createClientWithCredentials()->request('DELETE', $iri);