1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public function testDeconnection() {
$kernel = static::createKernel();
$kernel->boot();
$em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
$etatConnecte = $em->getRepository('pflAppBundle:EtatTaxi')->find(1);
$etatDeconnecte = $em->getRepository('pflAppBundle:EtatTaxi')->find(2);
//Création d'un taxi pour le test
$taxi = new Taxi();
$taxi->setImei('777777777777777');
$taxi->setEtat($etatConnecte);
$em->persist($taxi);
//Création d'une course et attribution du taxi à la course
$course = new Course('777777777777777', 49.506306553386054, 0.149688720703125, 49.52413862702165, 0.223846435546875);
$course->setTaxi($taxi);
$em->persist($course);
$taxi->setCourse($course);
$em->persist($taxi);
$em->flush();
$client = static::createClient();
$crawler = $client->request('POST', '/taxi/deconnection/777777777777777');
//On met à jour la variable $taxi en récupérant l'objet modifié
$taxi = $em->getRepository('pflAppBundle:Taxi')->findOneByImei('777777777777777');
$this->assertEquals('pfl\AppBundle\Controller\TaxiController::deconnectionAction', $client->getRequest()->attributes->get('_controller'));
$this->assertTrue($crawler->filter('html:contains("&etat=AuRevoir")')->count() > 0);
$this->assertTrue($taxi->getCourse() == null);
$this->assertEquals($taxi->getEtat()->getId(), 2);
$em->remove($taxi);
$em->flush();
} |
Partager