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()); }
public function testMappingBranchToModel() { $this->timeService->lockNow(); // mock d'une page animal en bdd $pageAnimalBranch = new PageAnimalBranch(); $pageAnimalBranch->setId(1); $this->pageAnimalBranchRepository->method('find')->with(1)->willReturn($pageAnimalBranch); $photo = new Photo(); $photo->setNom('zzccd'); $commit = new PageAnimalCommit(null, 'rudy', $this->timeService->now(), 'Un beau chien', PageAnimal::DISPONIBLE, PageAnimal::FEMELLE, [$photo]); $pageAnimalBranch->setCommit($commit); // Requete de la page animal $pageAnimal = $this->pageAnimalService->find(1); // On vérifie que la page est retournée avec les bonnes données $this->assertEquals('rudy', $pageAnimal->getNom()); $this->assertEquals($this->timeService->now(), $pageAnimal->getDateNaissance()); $this->assertEquals('Un beau chien', $pageAnimal->getDescription()); $this->assertEquals(PageAnimal::DISPONIBLE, $pageAnimal->getStatut()); $this->assertEquals(PageAnimal::FEMELLE, $pageAnimal->getSexe()); $this->assertEquals('zzccd', $pageAnimal->getPhotos()[0]->getNom()); }