Exemplo n.º 1
0
 public function testCommit_fastforward()
 {
     // Simulation d'une page animal en base de données
     $user = new User();
     $pageAnimalBranch = new PageAnimalBranch();
     $pageAnimalBranch->setOwner($user);
     $commit = new PageAnimalCommit(null, 'rodolf', $this->timeService->now(), null, PageAnimal::DISPONIBLE, PageAnimal::MALE, null);
     $commit->setId(1);
     $pageAnimalBranch->setCommit($commit);
     $this->pageAnimalBranchRepository->method('find')->willReturn($pageAnimalBranch);
     $this->pageAnimalCommitRepository->method('find')->with($commit->getId())->willReturn($commit);
     $this->timeService->lockNow($this->timeService->now()->add(new \DateInterval("P1D")));
     // Simulation d'un commit coté client sur la page animal
     $pageAnimal = new PageAnimal();
     $pageAnimal->setHead($commit->getId());
     $pageAnimal->setNom('rudolf');
     $pageAnimal->setDateNaissance($this->timeService->now());
     $pageAnimal->setDescription('Inscrit au LOF');
     $pageAnimal->setStatut(PageAnimal::RESERVE);
     $pageAnimal->setSexe(PageAnimal::FEMELLE);
     $photo = new Photo();
     $photo->setNom('bllbl');
     $pageAnimal->setPhotos([$photo]);
     $this->pageAnimalService->commit($user, $pageAnimal);
     // On vérifier que le commit a bien été créé avec les nouvelles données
     $this->assertEquals($commit->getId(), $pageAnimalBranch->getCommit()->getParent()->getId());
     $this->assertEquals('rudolf', $pageAnimalBranch->getCommit()->getNom());
     $this->assertEquals($this->timeService->now(), $pageAnimalBranch->getCommit()->getDateNaissance());
     $this->assertEquals('Inscrit au LOF', $pageAnimalBranch->getCommit()->getDescription());
     $this->assertEquals(PageAnimal::RESERVE, $pageAnimalBranch->getCommit()->getStatut());
     $this->assertEquals(PageAnimal::FEMELLE, $pageAnimalBranch->getCommit()->getSexe());
     /** @var Photo[] $photos */
     $photos = $pageAnimalBranch->getCommit()->getPhotos();
     $this->assertEquals('bllbl', $photos[0]->getNom());
 }
Exemplo n.º 2
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;
 }