Skip to content

Commit

Permalink
Correction les tests marchent (pas mais c'est bon)
Browse files Browse the repository at this point in the history
  • Loading branch information
Altaks committed Dec 13, 2023
1 parent f7e2198 commit 7d34efc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 85 deletions.
36 changes: 0 additions & 36 deletions webapp/sfapp/migrations/Version20231213102251.php

This file was deleted.

33 changes: 0 additions & 33 deletions webapp/sfapp/migrations/Version20231213102423.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231213094525 extends AbstractMigration
final class Version20231213152130 extends AbstractMigration
{
public function getDescription(): string
{
Expand All @@ -21,25 +21,19 @@ public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE batiment (id INT AUTO_INCREMENT NOT NULL, nom VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE releve (id INT AUTO_INCREMENT NOT NULL, systeme_acquisition_id INT DEFAULT NULL, salle_id INT NOT NULL, temperature DOUBLE PRECISION DEFAULT NULL, humidite INT DEFAULT NULL, qualite_air INT DEFAULT NULL, horodatage DATETIME NOT NULL, INDEX IDX_DDABFF833572D180 (systeme_acquisition_id), INDEX IDX_DDABFF83DC304035 (salle_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE salle (id INT AUTO_INCREMENT NOT NULL, batiment_id INT NOT NULL, systeme_acquisition_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, etage INT NOT NULL, orientation VARCHAR(2) NOT NULL, nombre_fenetre INT NOT NULL, nombre_porte INT NOT NULL, contient_pc TINYINT(1) NOT NULL, INDEX IDX_4E977E5CD6F6891B (batiment_id), UNIQUE INDEX UNIQ_4E977E5C3572D180 (systeme_acquisition_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE systeme_acquisition (id INT AUTO_INCREMENT NOT NULL, adresse_mac VARCHAR(17) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE systeme_acquisition (id INT AUTO_INCREMENT NOT NULL, adresse_mac VARCHAR(17) NOT NULL, tag INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE utilisateur (id INT AUTO_INCREMENT NOT NULL, identifiant VARCHAR(255) NOT NULL, mot_de_passe VARCHAR(255) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE releve ADD CONSTRAINT FK_DDABFF833572D180 FOREIGN KEY (systeme_acquisition_id) REFERENCES systeme_acquisition (id)');
$this->addSql('ALTER TABLE releve ADD CONSTRAINT FK_DDABFF83DC304035 FOREIGN KEY (salle_id) REFERENCES salle (id)');
$this->addSql('ALTER TABLE salle ADD CONSTRAINT FK_4E977E5CD6F6891B FOREIGN KEY (batiment_id) REFERENCES batiment (id)');
$this->addSql('ALTER TABLE salle ADD CONSTRAINT FK_4E977E5C3572D180 FOREIGN KEY (systeme_acquisition_id) REFERENCES systeme_acquisition (id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE releve DROP FOREIGN KEY FK_DDABFF833572D180');
$this->addSql('ALTER TABLE releve DROP FOREIGN KEY FK_DDABFF83DC304035');
$this->addSql('ALTER TABLE salle DROP FOREIGN KEY FK_4E977E5CD6F6891B');
$this->addSql('ALTER TABLE salle DROP FOREIGN KEY FK_4E977E5C3572D180');
$this->addSql('DROP TABLE batiment');
$this->addSql('DROP TABLE releve');
$this->addSql('DROP TABLE salle');
$this->addSql('DROP TABLE systeme_acquisition');
$this->addSql('DROP TABLE utilisateur');
Expand Down
2 changes: 1 addition & 1 deletion webapp/sfapp/src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function load(ObjectManager $manager): void
->setContientpc(true)
->setBatiment($batiment);

$manager->persist($salle1);
$manager->persist($salle4);

$sa1 = new SystemeAcquisition();
$sa1->setAdresseMac("00:00:00:00:00:01")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Repository\BatimentRepository;
use App\Repository\SalleRepository;
use App\Repository\SystemeAcquisitionRepository;
use App\Repository\UtilisateurRepository;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use function PHPUnit\Framework\assertEquals;
Expand All @@ -25,10 +26,10 @@ public function test_controleur_infracontroller_route_infra_charge_de_mission_sa
$batimentD = $batimentRepository->findOneBy(['nom' => 'Batiment D']);

$salleRepository = static::getContainer()->get(SalleRepository::class);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => '304']);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => 'D304']);


$crawler = $client->request('GET', '/infra/charge-de-mission/salles/'+ $salleD304->getId() +'/ajouter-sa');
$crawler = $client->request('GET', '/infra/charge-de-mission/salles/' . $salleD304->getId() . '/ajouter-sa');
$this->assertResponseIsSuccessful();

$this->assertSelectorTextContains('h1', 'Ajouter un système d\'acquisition à la salle D304');
Expand All @@ -47,9 +48,9 @@ public function test_controleur_infracontroller_route_infra_charge_de_mission_sa
$batimentD = $batimentRepository->findOneBy(['nom' => 'Batiment D']);

$salleRepository = static::getContainer()->get(SalleRepository::class);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => '304']);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => 'D304']);

$crawler = $client->request('GET', '/infra/charge-de-mission/salles/'+ $salleD304->getId() +'/ajouter-sa');
$crawler = $client->request('GET', '/infra/charge-de-mission/salles/' . $salleD304->getId() . '/ajouter-sa');

$this->assertResponseStatusCodeSame(302, $client->getResponse()->getStatusCode());
$this->assertMatchesRegularExpression('/\/connexion$/', $client->getResponse()->headers->get('location'));
Expand All @@ -71,9 +72,9 @@ public function test_controleur_infracontroller_route_infra_charge_de_mission_sa
$batimentD = $batimentRepository->findOneBy(['nom' => 'Batiment D']);

$salleRepository = static::getContainer()->get(SalleRepository::class);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => '304']);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => 'D304']);

$crawler = $client->request('GET', '/infra/charge-de-mission/salles/'+ $salleD304->getId() +'/ajouter-sa');
$crawler = $client->request('GET', '/infra/charge-de-mission/salles/' . $salleD304->getId() . '/ajouter-sa');

$this->assertResponseStatusCodeSame(403, $client->getResponse()->getStatusCode());
}
Expand All @@ -93,7 +94,7 @@ public function test_controleur_infracontroller_route_infra_charge_de_mission_sa
$batimentD = $batimentRepository->findOneBy(['nom' => 'Batiment D']);

$salleRepository = static::getContainer()->get(SalleRepository::class);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => '304']);
$salleD304 = $salleRepository->findOneBy(['batiment' => $batimentD->getId(), 'nom' => 'D304']);

$saRepository = static::getContainer()->get(SystemeAcquisitionRepository::class);
$saSansSalle = $saRepository->findOneBy(['adresseMac' => "00:00:00:00:00:04"]);
Expand Down

0 comments on commit 7d34efc

Please sign in to comment.