ZF-8222: format class name for class checks
[zend.git] / tests / Zend / AuthTest.php
blobb905343e1289117d7869035f4433c501d0a2aab8
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id $
23 /**
24 * Test helper
26 require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
29 /**
30 * @see Zend_Auth
32 require_once 'Zend/Auth.php';
35 /**
36 * @see Zend_Auth_Adapter_Interface
38 require_once 'Zend/Auth/Adapter/Interface.php';
40 /**
41 * @see Zend_Session
43 require_once 'Zend/Session.php';
45 /**
46 * @issue ZF-7882 - temp solution provided by {@link http://www.alexatnet.com/node/12}
48 Zend_Session::start();
51 /**
52 * @category Zend
53 * @package Zend_Auth
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
57 * @group Zend_Auth
59 class Zend_AuthTest extends PHPUnit_Framework_TestCase
61 /**
62 * Ensures that the Singleton pattern is implemented properly
64 * @return void
66 public function testSingleton()
68 $this->assertTrue(Zend_Auth::getInstance() instanceof Zend_Auth);
69 $this->assertEquals(Zend_Auth::getInstance(), Zend_Auth::getInstance());
72 /**
73 * Ensures that getStorage() returns Zend_Auth_Storage_Session
75 * @return void
77 public function testGetStorage()
79 $this->assertTrue(Zend_Auth::getInstance()->getStorage() instanceof Zend_Auth_Storage_Session);
82 /**
83 * Ensures expected behavior for successful authentication
85 * @return void
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());
96 /**
97 * Ensures expected behavior for clearIdentity()
99 * @return void
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');