IntegrationTestCountUsersByLoginName.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\User_LDAP\Tests\Integration\Lib;
  24. use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
  25. require_once __DIR__ . '/../Bootstrap.php';
  26. class IntegrationTestCountUsersByLoginName extends AbstractIntegrationTest {
  27. /**
  28. * prepares the LDAP environment and sets up a test configuration for
  29. * the LDAP backend.
  30. */
  31. public function init() {
  32. require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
  33. parent::init();
  34. }
  35. /**
  36. * tests countUsersByLoginName where it is expected that the login name does
  37. * not match any LDAP user
  38. *
  39. * @return bool
  40. */
  41. protected function case1() {
  42. $result = $this->access->countUsersByLoginName('nothere');
  43. return $result === 0;
  44. }
  45. /**
  46. * tests countUsersByLoginName where it is expected that the login name does
  47. * match one LDAP user
  48. *
  49. * @return bool
  50. */
  51. protected function case2() {
  52. $result = $this->access->countUsersByLoginName('alice');
  53. return $result === 1;
  54. }
  55. }
  56. /** @var string $host */
  57. /** @var int $port */
  58. /** @var string $adn */
  59. /** @var string $apwd */
  60. /** @var string $bdn */
  61. $test = new IntegrationTestCountUsersByLoginName($host, $port, $adn, $apwd, $bdn);
  62. $test->init();
  63. $test->run();