Newscoop\Services\ListUserService::findEditors PHP Méthode

findEditors() public méthode

List editors
public findEditors ( integer $limit = NULL, integer $offset = NULL ) : array
$limit integer
$offset integer
Résultat array
    public function findEditors($limit = NULL, $offset = NULL)
    {
        return $this->getRepository()->findEditors($this->config['role'], $limit, $offset);
    }

Usage Example

 public function testGetEditors()
 {
     $blogRole = new Group();
     $blogRole->setName('blogger');
     $author1 = new Author('tic1', 'toc');
     $author2 = new Author('tic2', 'toc');
     $this->em->persist($blogRole);
     $this->em->persist($author1);
     $this->em->persist($author2);
     $this->em->flush();
     $user = new User();
     $user->setUsername('user')->setEmail('*****@*****.**')->setActive(true);
     $admin = new User();
     $admin->setUsername('admin')->setEmail('*****@*****.**')->setActive(true)->setAdmin(true);
     $editor = new User();
     $editor->setUsername('editor')->setEmail('*****@*****.**')->setActive(true)->setAdmin(true)->setAuthor($author1);
     $blogger = new User();
     $blogger->setUsername('blogger')->setEmail('*****@*****.**')->setActive(true)->setAdmin(true)->setAuthor($author2)->addUserType($blogRole);
     $this->em->persist($user);
     $this->em->persist($admin);
     $this->em->persist($editor);
     $this->em->persist($blogger);
     $this->em->flush();
     $service = new ListUserService(array('blog' => array('role' => $blogRole->getId())), $this->em);
     $editors = $service->findEditors();
     $this->assertEquals(1, count($editors));
     $this->assertEquals($editor->getId(), $editors[0]->getId());
     $this->assertEquals(1, $service->getEditorsCount());
 }