Skip to content
Snippets Groups Projects
Select Git revision
  • 3763f1844ae54441d8958429256a3df4a71731c8
  • master default protected
  • update-min-openvox-version-07f8cb2
  • cleanup_fixtures
  • add-openvox
  • freebsd-14
  • remove-legacy-top-scope-syntax
  • rel430
  • tests
  • revert-363-augeas-module-cleanup
  • release-4.1.0
  • puppet8
  • relax-dependencies
  • rel400
  • mode
  • puppet7
  • release-3.1.0
  • freebsd13
  • freebsd11
  • stdlib
  • centos
  • v6.0.0
  • v5.1.0
  • v5.0.0
  • v4.5.0
  • v4.4.0
  • v4.3.0
  • v4.2.1
  • v4.2.0
  • v4.1.0
  • v4.0.0
  • v3.1.0
  • v3.0.0
  • v2.0.0
  • 1.12.0
  • 1.11.0
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.0
  • 1.6.0
41 results

params.pp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    UserAbstractTest.php 2.04 KiB
    <?php
    namespace UnicaenAuthTest\View\Helper;
    
    use PHPUnit_Framework_TestCase;
    use UnicaenAuth\View\Helper\UserAbstract;
    
    /**
     * Description of AppConnectionTest
     *
     * @property UserAbstract $helper Description
     * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
     */
    class UserAbstractTest extends PHPUnit_Framework_TestCase
    {
        protected $helper;
        protected $authService;
        
        /**
         * Sets up the fixture, for example, open a network connection.
         * This method is called before a test is executed.
         */
        protected function setUp()
        {
            $this->authService = $this->getMock('Zend\Authentication\AuthenticationService', array('hasIdentity', 'getIdentity'));
            
            $this->helper = $this->getMockForAbstractClass('UnicaenAuth\View\Helper\UserAbstract');
            $this->helper->setAuthService($this->authService);
        }
        
        public function testCanSetAuthService()
        {
            $this->assertSame($this->authService, $this->helper->getAuthService());
        }
        
        public function testGettingIdentityReturnsNullIfNoAuthServiceAvailable()
        {
            $this->helper->setAuthService(null);
            $this->assertNull($this->helper->getAuthService());
            $this->assertNull($this->helper->getIdentity());
        }
        
        public function testGettingIdentityReturnsNullIfAuthServiceHasNoIdentity()
        {
            $this->authService->expects($this->once())
                              ->method('hasIdentity')
                              ->will($this->returnValue(false));
            $this->assertNull($this->helper->getIdentity());
        }
        
        public function testGettingIdentityReturnsAuthServiceIdentity()
        {
            $this->authService->expects($this->once())
                              ->method('hasIdentity')
                              ->will($this->returnValue(true));
            $this->authService->expects($this->once())
                              ->method('getIdentity')
                              ->will($this->returnValue($identity = 'Auth Service Identity'));
            $this->assertEquals($identity, $this->helper->getIdentity());
        }
    }