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

getEditorsCount() public méthode

Get editors count
public getEditorsCount ( ) : integer
Résultat integer
    public function getEditorsCount()
    {
        return $this->getRepository()->getEditorsCount($this->config['role']);
    }

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());
 }