예제 #1
0
 /**
  * @param Note          $note
  * @param EntityManager $entityManager
  * @param bool          $update
  */
 protected function setUpdatedProperties(Note $note, EntityManager $entityManager, $update = false)
 {
     $newUpdatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
     $newUpdatedBy = $this->getUser($entityManager);
     $unitOfWork = $entityManager->getUnitOfWork();
     if ($update && $newUpdatedBy != $note->getUpdatedBy()) {
         $unitOfWork->propertyChanged($note, 'updatedAt', $note->getUpdatedAt(), $newUpdatedAt);
         $unitOfWork->propertyChanged($note, 'updatedBy', $note->getUpdatedBy(), $newUpdatedBy);
     }
     $note->setUpdatedAt($newUpdatedAt);
     $note->setUpdatedBy($newUpdatedBy);
 }
예제 #2
0
 public function testGettersSetters()
 {
     $note = new Note();
     $this->assertNull($note->getMessage());
     $this->assertNull($note->getId());
     $now = new \DateTime();
     $note->setCreatedAt($now)->setUpdatedAt($now)->setMessage('test');
     $this->assertEquals($now, $note->getCreatedAt());
     $this->assertEquals($now, $note->getUpdatedAt());
     $this->assertEquals('test', $note->getMessage());
     $user = new User();
     $note->setUpdatedBy($user)->setOwner($user);
     $this->assertSame($user, $note->getUpdatedBy());
     $this->assertEquals($user, $note->getOwner());
     $organization = new Organization();
     $this->assertNull($note->getOrganization());
     $note->setOrganization($organization);
     $this->assertSame($organization, $note->getOrganization());
 }