OauthInputExceptionTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Oauth\Test\Unit;
  7. use \Magento\Framework\Oauth\OauthInputException;
  8. use Magento\Framework\Phrase;
  9. class OauthInputExceptionTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @return void
  13. */
  14. public function testGetAggregatedErrorMessage()
  15. {
  16. $exception = new OauthInputException();
  17. foreach (['field1', 'field2'] as $param) {
  18. $exception->addError(
  19. new Phrase('"%fieldName" is required. Enter and try again.', ['fieldName' => $param])
  20. );
  21. }
  22. $exception->addError(new Phrase('Message with period.'));
  23. $this->assertEquals(
  24. '"field1" is required. Enter and try again, "field2" is required. Enter and try again, Message with period',
  25. $exception->getAggregatedErrorMessage()
  26. );
  27. }
  28. /**
  29. * @return void
  30. */
  31. public function testGetAggregatedErrorMessageNoError()
  32. {
  33. $exception = new OauthInputException();
  34. $this->assertEquals('', $exception->getAggregatedErrorMessage());
  35. }
  36. }