refs #452. Migrate clients and hardware profile ended
parent
2893c0921e
commit
a5d37d5092
|
@ -0,0 +1,33 @@
|
||||||
|
<?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 Version20240612105731 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 client CHANGE name name VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE network_settings CHANGE mcast_speed mcast_speed INT DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE network_settings CHANGE mcast_speed mcast_speed INT NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE client CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?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 Version20240612111552 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 client CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE hardware CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE user_group CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE hardware CHANGE name name VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE user_group CHANGE name name VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE client CHANGE name name VARCHAR(255) NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Dto\Input;
|
namespace App\Dto\Input;
|
||||||
|
|
||||||
|
use App\Dto\Output\OrganizationalUnitOutput;
|
||||||
use App\Entity\NetworkSettings;
|
use App\Entity\NetworkSettings;
|
||||||
use App\Entity\OrganizationalUnit;
|
use App\Entity\OrganizationalUnit;
|
||||||
use App\Model\OrganizationalUnitTypes;
|
use App\Model\OrganizationalUnitTypes;
|
||||||
|
@ -87,9 +88,7 @@ final class OrganizationalUnitClassroomInput extends OrganizationalUnitInput
|
||||||
?EntityManagerInterface $entityManager = null
|
?EntityManagerInterface $entityManager = null
|
||||||
): OrganizationalUnit
|
): OrganizationalUnit
|
||||||
{
|
{
|
||||||
if (!$organizationalUnit) {
|
$organizationalUnit = parent::createOrUpdateEntity($organizationalUnit);
|
||||||
$organizationalUnit = new OrganizationalUnit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$organizationalUnit->setType(OrganizationalUnitTypes::CLASSROOM);
|
$organizationalUnit->setType(OrganizationalUnitTypes::CLASSROOM);
|
||||||
$organizationalUnit->setLocation($this->location);
|
$organizationalUnit->setLocation($this->location);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class NetworkSettings extends AbstractEntity
|
||||||
#[ORM\Column(length: 255, nullable: true)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
private ?string $mcastIp = null;
|
private ?string $mcastIp = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
private ?int $mcastSpeed = null;
|
private ?int $mcastSpeed = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255, nullable: true)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
@ -161,7 +161,7 @@ class NetworkSettings extends AbstractEntity
|
||||||
return $this->mcastSpeed;
|
return $this->mcastSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMcastSpeed(int $mcastSpeed): static
|
public function setMcastSpeed(?int $mcastSpeed): static
|
||||||
{
|
{
|
||||||
$this->mcastSpeed = $mcastSpeed;
|
$this->mcastSpeed = $mcastSpeed;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Functional;
|
||||||
|
|
||||||
|
use App\Factory\OrganizationalUnitFactory;
|
||||||
|
use App\Factory\UserFactory;
|
||||||
|
use App\Model\OrganizationalUnitTypes;
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
|
|
||||||
|
class OrganizationalUnitTest extends AbstractTest
|
||||||
|
{
|
||||||
|
CONST string USER_ADMIN = 'ogadmin';
|
||||||
|
|
||||||
|
CONST string ORGANIZATIONAL_UNIT_CREATE = 'test-organizational-unit-create';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testGetCollectionOrganizationalUnit(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
OrganizationalUnitFactory::createMany(2, ['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]);
|
||||||
|
OrganizationalUnitFactory::createMany(2, ['type' => OrganizationalUnitTypes::CLASSROOMS_GROUP]);
|
||||||
|
OrganizationalUnitFactory::createMany(2, ['type' => OrganizationalUnitTypes::CLASSROOM]);
|
||||||
|
OrganizationalUnitFactory::createMany(2, ['type' => OrganizationalUnitTypes::CLIENTS_GROUP]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('GET', '/organizational-units');
|
||||||
|
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/OrganizationalUnit',
|
||||||
|
'@id' => '/organizational-units',
|
||||||
|
'@type' => 'hydra:Collection',
|
||||||
|
'hydra:totalItems' => 8,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateOrganizationalUnitRoot(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/organizational-units/root',['json' => [
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||||
|
'@type' => 'OrganizationalUnit',
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateOrganizationalUnitClassroomGroup(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/organizational-units/classroom-group',['json' => [
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||||
|
'@type' => 'OrganizationalUnit',
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
'type' => OrganizationalUnitTypes::CLASSROOMS_GROUP,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateOrganizationalUnitClassroom(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/organizational-units/classroom',['json' => [
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||||
|
'@type' => 'OrganizationalUnit',
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
'type' => OrganizationalUnitTypes::CLASSROOM,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateOrganizationalUnitClientGroup(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/organizational-units/client-group',['json' => [
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||||
|
'@type' => 'OrganizationalUnit',
|
||||||
|
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||||
|
'type' => OrganizationalUnitTypes::CLIENTS_GROUP,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue