OfflineTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-2009 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-2009 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. $this->_adapter->setLdap(new Zend_Ldap());
  64. $this->assertType('Zend_Ldap', $this->_adapter->getLdap());
  65. }
  66. public function testUsernameIsNullIfNotSet()
  67. {
  68. $this->assertNull($this->_adapter->getUsername());
  69. }
  70. public function testPasswordIsNullIfNotSet()
  71. {
  72. $this->assertNull($this->_adapter->getPassword());
  73. }
  74. public function testSetAndGetUsername()
  75. {
  76. $usernameExpected = 'someUsername';
  77. $usernameActual = $this->_adapter->setUsername($usernameExpected)
  78. ->getUsername();
  79. $this->assertSame($usernameExpected, $usernameActual);
  80. }
  81. public function testSetAndGetPassword()
  82. {
  83. $passwordExpected = 'somePassword';
  84. $passwordActual = $this->_adapter->setPassword($passwordExpected)
  85. ->getPassword();
  86. $this->assertSame($passwordExpected, $passwordActual);
  87. }
  88. public function testSetIdentityProxiesToSetUsername()
  89. {
  90. $usernameExpected = 'someUsername';
  91. $usernameActual = $this->_adapter->setIdentity($usernameExpected)
  92. ->getUsername();
  93. $this->assertSame($usernameExpected, $usernameActual);
  94. }
  95. public function testSetCredentialProxiesToSetPassword()
  96. {
  97. $passwordExpected = 'somePassword';
  98. $passwordActual = $this->_adapter->setCredential($passwordExpected)
  99. ->getPassword();
  100. $this->assertSame($passwordExpected, $passwordActual);
  101. }
  102. }