public function testCommit_dateNaissance_nom()
 {
     $pageAnimal = $this->testUtils->createUser()->toEleveur()->addAnimal()->getPageEleveur()->getAnimaux()[0];
     $pageAnimal->setDateNaissance(null);
     // Modification du nom et de la description de la page
     $this->client->request('POST', '/animal/' . $pageAnimal->getId(), array(), array(), array(), $this->serializer->serialize($pageAnimal, 'json'));
     $this->assertEquals(Response::HTTP_NOT_ACCEPTABLE, $this->client->getResponse()->getStatusCode());
 }
 public function testConfirmation()
 {
     $user = $this->testUtils->createUser()->getUser();
     $crawler = $this->client->request('GET', '/contact');
     $form = $crawler->filter('form')->form();
     $form['form[message]'] = 'test';
     $this->client->submit($form);
     $this->assertEquals(Response::HTTP_FOUND, $this->client->getResponse()->getStatusCode());
     $confirmationCrawler = $this->client->followRedirect();
     $this->assertContains('Nous vous répondrons à l\'adresse ' . $user->getEmail(), $confirmationCrawler->filter('#confirmation')->text());
 }
 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());
 }
 public function testHomeEleveur()
 {
     $pageEleveur = $this->testUtils->createUser()->toEleveur()->getPageEleveur();
     $crawler = $this->client->request('GET', '/');
     $this->assertEquals(1, $crawler->filter('a[href="' . '/elevage/' . $pageEleveur->getSlug() . '"]')->count());
 }