tests/TestCase.php
/**
     * Assert that the response contains the given JSON fragment.
     *
     * @param array $data
     *
     * @return $this
     */
Assert that the response contains the given JSON fragment.
@param array $data

@return $this
Assert that the response contains the given JSON fragment . @param array $data @return $this
public function assertJsonFragment(array $data)
    {
        $actual = json_encode(Arr::sortRecursive(
            (array) $this->decodeResponseJson()
        ));
        foreach (Arr::sortRecursive($data) as $key => $value) {
            $expected = substr(json_encode([$key => $value]), 1, -1);
            PHPUnit::assertTrue(
                Str::contains($actual, $expected),
                'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL.
                "[{$expected}]".PHP_EOL.PHP_EOL.
                'within'.PHP_EOL.PHP_EOL.
                "[{$actual}]."
            );
        }
        return $this;
    }
public function assertJsonFragment ( array $ data ) { $ actual = json_encode ( Arr :: sortRecursive ( ( array ) $ this -> decodeResponseJson ( ) ) ) ; foreach ( Arr :: sortRecursive ( $ data ) as $ key => $ value ) { $ expected = substr ( json_encode ( [ $ key => $ value ] ) , 1 , - 1 ) ; PHPUnit :: assertTrue ( Str :: contains ( $ actual , $ expected ) , 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . " [ { $ expected } ] " . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . " [ { $ actual } ]. " ) ; } return $ this ; }
Assert that the response contains the given JSON fragment.
Assert that the response contains the given JSON fragment .