Exemplo n.º 1
0
 /**
  * @expectedException \AppBundle\Service\ValidationException
  * @expectedExceptionCode \AppBundle\Service\ValidationException::EMPTY_DATE_NAISSANCE
  */
 public function testCommit_dateNaissance_empty()
 {
     // 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);
     // Commit la page avec un nom vide
     $pageAnimal = $this->pageAnimalService->find($pageAnimalBranch->getId());
     $pageAnimal->setDateNaissance(null);
     $this->pageAnimalService->commit($user, $pageAnimal);
 }
Exemplo n.º 2
0
 public function testModifiedAt()
 {
     $user = $this->createUser();
     $this->timeService->lockNow();
     $this->userManager->updateUser($user);
     // A la création de l'entité, createdAt et modifiedAt ont la même valeur, 'now'
     $this->assertEquals($this->timeService->now(), $user->getModifiedAt());
     //modification du user
     $user->setPlainPassword('modified');
     //enregistrement du user une seconde plus tard
     $this->timeService->lockNow($this->timeService->now()->add(new DateInterval('PT1S')));
     // Simule un sleep(1)
     $this->userManager->updateUser($user);
     $this->assertEquals($this->timeService->now(), $user->getModifiedAt());
     $this->assertGreaterThan($user->getCreatedAt(), $user->getModifiedAt());
 }