Ejemplo n.º 1
0
 public static function fromBranch(PageAnimalBranch $branch)
 {
     $pageAnimal = new PageAnimal();
     $pageAnimal->setId($branch->getId());
     $pageAnimal->setHead($branch->getCommit()->getId());
     $pageAnimal->setOwner($branch->getOwner());
     $pageAnimal->setNom($branch->getCommit()->getNom());
     $pageAnimal->setDateNaissance($branch->getCommit()->getDateNaissance());
     $pageAnimal->setDescription($branch->getCommit()->getDescription());
     $pageAnimal->setStatut($branch->getCommit()->getStatut());
     $pageAnimal->setSexe($branch->getCommit()->getSexe());
     $pageAnimal->setPhotos($branch->getCommit()->getPhotos());
     return $pageAnimal;
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \AppBundle\Service\HistoryException
  * @expectedExceptionCode \AppBundle\Service\HistoryException::NON_FAST_FORWARD
  */
 public function testCommit_non_fastforward()
 {
     // Simulation d'une branche en bdd sur le commit 1
     $user = new User();
     $user->setId(1);
     $pageAnimalBranch = new PageAnimalBranch();
     $pageAnimalBranch->setOwner($user);
     $commit = new PageAnimalCommit(null, 'Joey', null, null, PageAnimal::DISPONIBLE, PageAnimal::MALE, null);
     $commit->setId(1);
     $pageAnimalBranch->setCommit($commit);
     $this->pageAnimalBranchRepository->method('find')->with(10)->willReturn($pageAnimalBranch);
     // Simulation commit à partir d'un head sur le commit 2
     $pageAnimal = new PageAnimal();
     $pageAnimal->setHead(2);
     $pageAnimal->setId(10);
     $this->pageAnimalCommitRepository->method('find')->with(2)->willReturn(new PageAnimalCommit(null, 'Joey', null, null, PageAnimal::DISPONIBLE, PageAnimal::MALE, null));
     $this->pageAnimalService->commit($user, $pageAnimal);
 }
Ejemplo n.º 3
0
 public function testCommit_BrancheInconnue()
 {
     $this->testUtils->createUser();
     $fakePageEleveur = new PageAnimal();
     $fakePageEleveur->setId(-1);
     $fakePageEleveur->setHead(-1);
     $this->client->request('POST', '/animal/1', array(), array(), array(), $this->serializer->serialize($fakePageEleveur, 'json'));
     $this->assertEquals(Response::HTTP_NOT_FOUND, $this->client->getResponse()->getStatusCode());
 }