isPublic() public method

Test if user is public
public isPublic ( ) : boolean
return boolean
Example #1
0
 public function testSave()
 {
     $user = new User();
     $group = new Group();
     $group->setName('test');
     $this->em->persist($group);
     $this->assertFalse($user->isAdmin());
     $this->assertFalse($user->isPublic());
     $this->repository->save($user, array('username' => 'foo_bar', 'password' => 'secret', 'email' => '*****@*****.**', 'first_name' => 'Foo', 'last_name' => 'Bar', 'status' => User::STATUS_INACTIVE, 'is_public' => TRUE, 'is_admin' => TRUE, 'attributes' => array('phone' => 123), 'user_type' => array(1)));
     $this->em->flush();
     $this->em->clear();
     $users = $this->repository->findAll();
     $this->assertEquals(1, sizeof($users));
     $user = array_shift($users);
     $this->assertEquals(1, $user->getId());
     $this->assertEquals('foo_bar', $user->getUsername());
     $this->assertTrue($user->checkPassword('secret'));
     $this->assertEquals('*****@*****.**', $user->getEmail());
     $this->assertEquals('Foo', $user->getFirstName());
     $this->assertEquals('Bar', $user->getLastName());
     $this->assertEquals(User::STATUS_INACTIVE, $user->getStatus());
     $this->assertFalse($user->isActive());
     $this->assertLessThan(5, time() - $user->getCreated()->getTimestamp());
     $this->assertEquals(123, $user->getAttribute('phone'));
     $this->assertTrue($user->isAdmin());
     $this->assertTrue($user->isPublic());
     $this->assertEquals(1, sizeof($user->getUserTypes()));
     // test attribute change
     $user->addAttribute('phone', 1234);
     $this->em->persist($user);
     $this->em->flush();
     $this->assertEquals(1234, $user->getAttribute('phone'));
 }
Example #2
0
 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());
 }
Example #3
0
 /**
  * Set form defaults
  *
  * @param Newscoop\Entity\User $user
  * @return Admin_Form_User
  */
 public function setDefaultsFromEntity(User $user)
 {
     $types = array();
     foreach ($user->getUserTypes() as $type) {
         $types[] = $type->getId();
     }
     try {
         $user->getAuthorId();
     } catch (\Doctrine\ORM\EntityNotFoundException $e) {
         // deleted author
         $user->setAuthor(null);
     }
     return $this->setDefaults(array('first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'email' => $user->getEmail(), 'username' => $user->getUsername(), 'status' => $user->isActive(), 'is_admin' => $user->isAdmin(), 'is_public' => $user->isPublic(), 'user_type' => $types, 'author' => $user->getAuthorId()));
 }
Example #4
0
 /**
  * Set form defaults
  *
  * @param  Newscoop\Entity\User $user
  * @return Admin_Form_User
  */
 public function setDefaultsFromEntity(User $user)
 {
     $defaults = array('first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'username' => $user->getUsername(), 'attributes' => array());
     $profile = $this->getSubForm('attributes');
     foreach ($profile as $field) {
         $defaults['attributes'][$field->getName()] = (string) $user->getAttribute($field->getName());
     }
     $types = array();
     foreach ($user->getUserTypes() as $type) {
         $types[] = $type->getId();
     }
     try {
         $user->getAuthorId();
     } catch (\Doctrine\ORM\EntityNotFoundException $e) {
         // deleted author
         $user->setAuthor(null);
     }
     $settings = array('first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'email' => $user->getEmail(), 'username' => $user->getUsername(), 'status' => $user->isActive(), 'is_admin' => $user->isAdmin(), 'is_public' => $user->isPublic(), 'is_verified' => $user->getAttribute('is_verified'), 'is_featured' => $user->getAttribute('is_featured'), 'user_type' => $types, 'author' => $user->getAuthorId());
     return $this->setDefaults(array_merge($settings, $defaults));
 }
 public function isPublic()
 {
     $this->__load();
     return parent::isPublic();
 }