public function testAddGetRemove()
 {
     $pays = $this->repository->getPays();
     $region = new Region($pays, 82, 'Rhône-Alpes');
     $departement = new Departement($region, 38, 'Isère');
     $commune = new Commune($departement, 'ZE', 'Grenoble');
     $arrondissementCommunal = new ArrondissementCommunal($commune, 'ZE', 'Test');
     $circonscriptionLeg = new CirconscriptionLegislative($departement, 2);
     $circonscriptionEur = new CirconscriptionEuropeenne($pays, 1, 'Sud-Ouest');
     $this->repository->add($arrondissementCommunal);
     $this->repository->add($circonscriptionLeg);
     $this->repository->add($circonscriptionEur);
     $this->repository->save();
     // L'id peut avoir changer donc on teste juste le nom.
     $this->assertEquals($region->getNom(), $this->repository->getRegion(82)->getNom());
     $this->assertEquals($departement->getNom(), $this->repository->getDepartement(38)->getNom());
     $this->assertEquals($commune->getNom(), $this->repository->getCommune(38, 'ZE')->getNom());
     $this->assertEquals($arrondissementCommunal->getNom(), $this->repository->getArrondissementCommunal($commune, 'ZE')->getNom());
     $this->assertEquals($circonscriptionLeg->getCode(), $this->repository->getCirconscriptionLegislative(38, 2)->getCode());
     $this->assertEquals($circonscriptionEur->getNom(), $this->repository->getCirconscriptionEuropeenne('Sud-Ouest')->getNom());
     $this->assertEquals($circonscriptionEur->getNom(), $this->repository->getCirconscriptionEuropeenne(1)->getNom());
     $this->assertEquals('France', $this->repository->getPays()->getNom());
     // On teste remove
     $this->repository->remove($this->repository->getRegion(82));
     $this->repository->save();
     // Si on utilise assertNull, en cas d'échec du test, phpUnit fait un
     // var_dump ce qui pose problème lorsqu'il y a des associations
     // d'entités cycliques.
     $this->assertTrue(null === $this->repository->getRegion(82));
     $this->assertTrue(null === $this->repository->getDepartement(38));
     $this->assertTrue(null === $this->repository->getCommune(38, 'ZE'));
     $this->assertTrue(null === $this->repository->getArrondissementCommunal($commune, 'ZE'));
 }
 public function testHasDepartementAndCodeAndNom()
 {
     $pays = new Pays('France');
     $region = new Region($pays, 82, 'Rhône-Alpes');
     $departement = new Departement($region, 38, 'Isère');
     $commune = new Commune($departement, 185, 'Grenoble');
     $this->assertEquals('Grenoble', $commune->getNom());
     $this->assertEquals(185, $commune->getCode());
     $this->assertEquals($departement, $commune->getDepartement());
     $this->assertContains($commune, $departement->getCommunes());
 }