assertJsonStringEqualsJsonString()
assertJsonStringEqualsJsonString(mixed $expectedJson, mixed $actualJson[, string $message = ''])
Reports an error identified by $message if the value of $actualJson does not match the value of $expectedJson.
Example A.35: Usage of assertJsonStringEqualsJsonString()
<?php
use PHPUnit\Framework\TestCase;
class JsonStringEqualsJsonStringTest extends TestCase
{
public function testFailure()
{
$this->assertJsonStringEqualsJsonString(
json_encode(['Mascot' => 'Tux']),
json_encode(['Mascot' => 'ux'])
);
}
}
?>
phpunit JsonStringEqualsJsonStringTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 5.00Mb There was 1 failure: 1) JsonStringEqualsJsonStringTest::testFailure Failed asserting that two objects are equal. --- Expected +++ Actual @@ @@ stdClass Object ( - 'Mascot' => 'Tux' + 'Mascot' => 'ux' ) /home/sb/JsonStringEqualsJsonStringTest.php:5 FAILURES! Tests: 1, Assertions: 3, Failures: 1.
Please login to continue.