2
0

OfflineTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Auth
  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$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  26. /**
  27. * @see Zend_Auth_Adapter_Ldap
  28. */
  29. require_once 'Zend/Auth/Adapter/Ldap.php';
  30. /**
  31. * @see Zend_Ldap
  32. */
  33. require_once 'Zend/Ldap.php';
  34. /**
  35. * @category Zend
  36. * @package Zend_Auth
  37. * @subpackage UnitTests
  38. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. * @group Zend_Auth
  41. */
  42. class Zend_Auth_Adapter_Ldap_OfflineTest extends PHPUnit_Framework_TestCase
  43. {
  44. /**
  45. * Authentication adapter instance
  46. *
  47. * @var Zend_Auth_Adapter_Ldap
  48. */
  49. protected $_adapter = null;
  50. /**
  51. * Setup operations run prior to each test method:
  52. *
  53. * * Creates an instance of Zend_Auth_Adapter_Ldap
  54. *
  55. * @return void
  56. */
  57. public function setUp()
  58. {
  59. $this->_adapter = new Zend_Auth_Adapter_Ldap();
  60. }
  61. public function testGetSetLdap()
  62. {
  63. if (!extension_loaded('ldap')) {
  64. $this->markTestSkipped('LDAP is not enabled');
  65. }
  66. $this->_adapter->setLdap(new Zend_Ldap());
  67. $this->assertType('Zend_Ldap', $this->_adapter->getLdap());
  68. }
  69. public function testUsernameIsNullIfNotSet()
  70. {
  71. $this->assertNull($this->_adapter->getUsername());
  72. }
  73. public function testPasswordIsNullIfNotSet()
  74. {
  75. $this->assertNull($this->_adapter->getPassword());
  76. }
  77. public function testSetAndGetUsername()
  78. {
  79. $usernameExpected = 'someUsername';
  80. $usernameActual = $this->_adapter->setUsername($usernameExpected)
  81. ->getUsername();
  82. $this->assertSame($usernameExpected, $usernameActual);
  83. }
  84. public function testSetAndGetPassword()
  85. {
  86. $passwordExpected = 'somePassword';
  87. $passwordActual = $this->_adapter->setPassword($passwordExpected)
  88. ->getPassword();
  89. $this->assertSame($passwordExpected, $passwordActual);
  90. }
  91. public function testSetIdentityProxiesToSetUsername()
  92. {
  93. $usernameExpected = 'someUsername';
  94. $usernameActual = $this->_adapter->setIdentity($usernameExpected)
  95. ->getUsername();
  96. $this->assertSame($usernameExpected, $usernameActual);
  97. }
  98. public function testSetCredentialProxiesToSetPassword()
  99. {
  100. $passwordExpected = 'somePassword';
  101. $passwordActual = $this->_adapter->setCredential($passwordExpected)
  102. ->getPassword();
  103. $this->assertSame($passwordExpected, $passwordActual);
  104. }
  105. }