PHPUnit_Framework_Assert::assertJson PHP Method

assertJson() public static method

Asserts that a string is a valid JSON string.
public static assertJson ( string $actualJson, string $message = '' )
$actualJson string
$message string
    public static function assertJson($actualJson, $message = '')
    {
        if (!is_string($actualJson)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
        }
        static::assertThat($actualJson, static::isJson(), $message);
    }

Usage Example

Example #1
0
 private function assertEqualJsons($expected, $actual, $error_message = '')
 {
     PHPUnit::assertJson($expected, $error_message);
     PHPUnit::assertJson($actual, $error_message);
     $expected = json_decode($expected);
     $actual = json_decode($actual);
     PHPUnit::assertEquals($expected, $actual, $error_message);
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertJson
PHPUnit_Framework_Assert