UserProfileFactoryTest.php 1.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

namespace UnicaenAppTest\View\Helper;

use UnicaenAppTest\View\Helper\BaseServiceFactoryTest;

/**
 * Description of UserProfileFactoryTest
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
class UserProfileFactoryTest extends BaseServiceFactoryTest
{
    protected $factoryClass = 'UnicaenAuth\View\Helper\UserProfileFactory';
    protected $serviceClass = 'UnicaenAuth\View\Helper\UserProfile';
    
    public function testCanCreateService()
    {
        $authService      = $this->getMock('Zend\Authentication\AuthenticationService', array());
        $authorize        = $this->getMock('BjyAuthorize\Service\Authorize', array('getIdentityProvider'), array(), '', false);
        $identityProvider = $this->getMockForAbstractClass('BjyAuthorize\Provider\Identity\ProviderInterface', array());

        $authorize->expects($this->once())
                ->method('getIdentityProvider')
                ->will($this->returnValue($identityProvider));
        
        $this->serviceManager->expects($this->exactly(2))
                ->method('get')
                ->will($this->returnValueMap(array(
                    array('zfcuser_auth_service', $authService),
                    array('BjyAuthorize\Service\Authorize', $authorize))));
       
        $service = $this->factory->createService($this->pluginManager);
        
        $this->assertInstanceOf($this->serviceClass, $service);
        $this->assertSame($identityProvider, $service->getIdentityProvider());
    }
}