CredentialsValidatorTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Test\Unit\Model;
  7. /**
  8. * Unit test for \Magento\Integration\Model\CredentialsValidator
  9. */
  10. class CredentialsValidatorTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Integration\Model\CredentialsValidator
  14. */
  15. protected $credentialsValidator;
  16. protected function setUp()
  17. {
  18. $this->credentialsValidator = new \Magento\Integration\Model\CredentialsValidator();
  19. }
  20. /**
  21. * @expectedException \Magento\Framework\Exception\InputException
  22. * @expectedExceptionMessage "username" is required. Enter and try again.
  23. */
  24. public function testValidateNoUsername()
  25. {
  26. $username = '';
  27. $password = 'my_password';
  28. $this->credentialsValidator->validate($username, $password);
  29. }
  30. /**
  31. * @expectedException \Magento\Framework\Exception\InputException
  32. * @expectedExceptionMessage "password" is required. Enter and try again.
  33. */
  34. public function testValidateNoPassword()
  35. {
  36. $username = 'my_username';
  37. $password = '';
  38. $this->credentialsValidator->validate($username, $password);
  39. }
  40. public function testValidateValidCredentials()
  41. {
  42. $username = 'my_username';
  43. $password = 'my_password';
  44. $result = $this->credentialsValidator->validate($username, $password);
  45. $this->assertNull($result);
  46. }
  47. }