7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Config
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
26 require_once dirname(dirname(__FILE__
)) . DIRECTORY_SEPARATOR
. 'TestHelper.php';
32 require_once 'Zend/Auth.php';
36 * @see Zend_Auth_Adapter_Interface
38 require_once 'Zend/Auth/Adapter/Interface.php';
43 require_once 'Zend/Session.php';
46 * @issue ZF-7882 - temp solution provided by {@link http://www.alexatnet.com/node/12}
48 Zend_Session
::start();
54 * @subpackage UnitTests
55 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
56 * @license http://framework.zend.com/license/new-bsd New BSD License
59 class Zend_AuthTest
extends PHPUnit_Framework_TestCase
62 * Ensures that the Singleton pattern is implemented properly
66 public function testSingleton()
68 $this->assertTrue(Zend_Auth
::getInstance() instanceof Zend_Auth
);
69 $this->assertEquals(Zend_Auth
::getInstance(), Zend_Auth
::getInstance());
73 * Ensures that getStorage() returns Zend_Auth_Storage_Session
77 public function testGetStorage()
79 $this->assertTrue(Zend_Auth
::getInstance()->getStorage() instanceof Zend_Auth_Storage_Session
);
83 * Ensures expected behavior for successful authentication
87 public function testAuthenticate()
89 $auth = Zend_Auth
::getInstance();
90 $result = $auth->authenticate(new Zend_AuthTest_Success_Adapter());
91 $this->assertTrue($result instanceof Zend_Auth_Result
);
92 $this->assertTrue($auth->hasIdentity());
93 $this->assertEquals('someIdentity', $auth->getIdentity());
97 * Ensures expected behavior for clearIdentity()
101 public function testClearIdentity()
103 $auth = Zend_Auth
::getInstance();
104 $auth->clearIdentity();
105 $this->assertFalse($auth->hasIdentity());
106 $this->assertEquals(null, $auth->getIdentity());
111 class Zend_AuthTest_Success_Adapter
implements Zend_Auth_Adapter_Interface
113 public function authenticate()
115 return new Zend_Auth_Result(true, 'someIdentity');