Add attribute
public addAttribute ( string $name, string $value ) : Newscoop\Entity\User | ||
$name | string | |
$value | string | |
return | Newscoop\Entity\User |
public function testDeleteActive() { $this->user->setActive(true); $this->em->persist($this->user); $this->em->flush(); $this->user->addAttribute('tic', 'toc'); $this->em->persist($this->user); $this->em->flush(); $this->assertTrue($this->user->isActive()); $this->auth->expects($this->once())->method('getIdentity')->will($this->returnValue(3)); sleep(2); // for testing difference in create/update time $this->service->delete($this->user); $this->assertFalse($this->user->isActive()); $this->assertFalse($this->user->isPublic()); $this->assertFalse($this->user->isAdmin()); $this->assertEmpty($this->user->getEmail()); $this->assertEmpty($this->user->getFirstName()); $this->assertEmpty($this->user->getLastName()); $this->assertEmpty($this->user->getAttribute('tic')); $this->assertEmpty($this->user->getAttributes()); $this->assertGreaterThan($this->user->getCreated()->getTimestamp(), $this->user->getUpdated()->getTimestamp()); }
public function addAttribute($name, $value) { $this->__load(); return parent::addAttribute($name, $value); }
/** * Remove user attributes * * @param Newscoop\Entity\User $user * @return void */ private function removeAttributes(User $user) { $attributes = $this->getEntityManager()->getRepository('Newscoop\\Entity\\UserAttribute')->findBy(array('user' => $user->getId())); foreach ($attributes as $attribute) { $user->addAttribute($attribute->getName(), null); $this->getEntityManager()->remove($attribute); } }