public function testPageAnimalSupprime()
 {
     $pageEleveur = $this->testUtils->createUser()->toEleveur()->addAnimal()->getPageEleveur();
     $pageAnimal = $pageEleveur->getAnimaux()[0];
     $pageEleveur->setAnimaux([]);
     /** @var PageEleveurService $pageEleveurService */
     $pageEleveurService = $this->client->getContainer()->get('zigotoo.page_eleveur');
     $pageEleveurService->commit($this->testUtils->getUser(), $pageEleveur);
     $crawler = $this->client->request('GET', '/animal/' . $pageAnimal->getId());
     $this->assertTrue($this->client->getResponse()->isOk());
     $this->assertEquals(0, $crawler->filter('h1 a')->count());
 }
 public function testAnimalList()
 {
     /** @var TestTimeService $timeService */
     $timeService = $this->client->getContainer()->get('zigotoo.time');
     $timeService->lockNow();
     /*
      * On avance le temps pour que les createdAt des animaux diffèrent.
      * Si non le test est instable à cause du orderBy sur createdAt
      */
     $this->testUtils->createUser()->toEleveur()->addAnimal();
     $timeService->lockNow($timeService->now()->add(new \DateInterval('PT1M')));
     $this->testUtils->addAnimal();
     $timeService->lockNow($timeService->now()->add(new \DateInterval('PT1M')));
     $this->testUtils->addAnimal();
     $timeService->lockNow($timeService->now()->add(new \DateInterval('PT1M')));
     $this->testUtils->addAnimal();
     $pageEleveur = $this->testUtils->getPageEleveur();
     /*
      * A ce moment, les PA sont triés par createdAt puisque testUtils utilise
      * PageEleveurService->commit qui retourne une PE avec les PA triées
      */
     $animal0 = $pageEleveur->getAnimaux()[0];
     $animal1 = $pageEleveur->getAnimaux()[1];
     $animal2 = $pageEleveur->getAnimaux()[2];
     $animal3 = $pageEleveur->getAnimaux()[3];
     // On met un animal dans chaque statut
     $this->assertEquals(PageAnimal::DISPONIBLE, $animal0->getStatut());
     $animal1->setStatut(PageAnimal::OPTION);
     $animal2->setStatut(PageAnimal::RESERVE);
     $animal3->setStatut(PageAnimal::ADOPTE);
     /** @var PageAnimalService $pageAnimalService */
     $pageAnimalService = $this->client->getContainer()->get('zigotoo.page_animal');
     $pageAnimalService->commit($this->testUtils->getUser(), $animal1);
     $pageAnimalService->commit($this->testUtils->getUser(), $animal2);
     $pageAnimalService->commit($this->testUtils->getUser(), $animal3);
     $this->testUtils->logout();
     $this->testUtils->clearEntities();
     $crawler = $this->client->request('GET', '/elevage/' . $pageEleveur->getSlug());
     // En visiteur, on ne voit pas les animaux adoptés, on a donc que 3 animaux dans la page
     $this->assertEquals(3, $crawler->filter('.animaux .animal')->count());
     $this->assertContains($animal0->getId(), $crawler->filter('.animaux .animal:nth-child(1) a')->link()->getUri());
     $this->assertContains($animal1->getId(), $crawler->filter('.animaux .animal:nth-child(2) a')->link()->getUri());
     $this->assertContains($animal2->getId(), $crawler->filter('.animaux .animal:nth-child(3) a')->link()->getUri());
 }
예제 #3
0
 public function testUserConnecte()
 {
     $this->testUtils->createUser();
     $crawler = $this->client->request('GET', '/contact');
     $this->assertEquals($this->testUtils->getUser()->getEmail(), $crawler->filter('form')->form()->get('form[email]')->getValue());
 }