You are here

class ExceptionTest in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.2 api-sdk-php/tests/unit/ExceptionTest.php \Smartling\Tests\ExceptionTest
  2. 8.2 vendor/smartling/api-sdk-php/tests/unit/ExceptionTest.php \Smartling\Tests\ExceptionTest
  3. 8.3 vendor/smartling/api-sdk-php/tests/unit/ExceptionTest.php \Smartling\Tests\ExceptionTest

Test class for Smartling\Exceptions\SmartlingApiException.

Hierarchy

  • class \Smartling\Tests\ExceptionTest extends \Smartling\Tests\PHPUnit_Framework_TestCase

Expanded class hierarchy of ExceptionTest

File

vendor/smartling/api-sdk-php/tests/unit/ExceptionTest.php, line 9

Namespace

Smartling\Tests
View source
class ExceptionTest extends \PHPUnit_Framework_TestCase {

  /**
   * Check exception's constructor with string error passed in.
   */
  public function testConstructorStringMessage() {
    $exceptionMessage = 'Exception message';
    $e = new SmartlingApiException($exceptionMessage);
    $this
      ->assertTrue(is_string($e
      ->getMessage()));
    $this
      ->assertNotEmpty($e
      ->getMessage());
    $this
      ->assertSame($exceptionMessage, $e
      ->getMessage());
  }

  /**
   * Check exception's constructor with array of errors passed in.
   */
  public function testConstructorArrayMessage() {
    $exceptionArray = [
      'errors' => [
        [
          'key' => 'error_key',
          'message' => 'Error message.',
          'details' => [
            'errorId' => 'error_id',
          ],
        ],
      ],
    ];
    $e = new SmartlingApiException($exceptionArray);
    $this
      ->assertTrue(is_string($e
      ->getMessage()));
    $this
      ->assertNotEmpty($e
      ->getMessage());
    $this
      ->assertSame(print_r($exceptionArray, TRUE), $e
      ->getMessage());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExceptionTest::testConstructorArrayMessage public function Check exception's constructor with array of errors passed in.
ExceptionTest::testConstructorStringMessage public function Check exception's constructor with string error passed in.