ExceptionTest.php in TMGMT Translator Smartling 8.2
File
api-sdk-php/tests/unit/ExceptionTest.php
View source
<?php
namespace Smartling\Tests;
use Smartling\Exceptions\SmartlingApiException;
class ExceptionTest extends \PHPUnit_Framework_TestCase {
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());
}
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());
}
}