|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\JsonPath\Test; |
| 13 | + |
| 14 | +use Symfony\Component\JsonPath\JsonCrawler; |
| 15 | +use Symfony\Component\JsonPath\JsonPath; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author Alexandre Daubois <[email protected]> |
| 19 | + * |
| 20 | + * @psalm-requires-extend \PHPUnit\Framework\Assert |
| 21 | + * |
| 22 | + * @experimental |
| 23 | + */ |
| 24 | +trait JsonPathAssertionsTrait |
| 25 | +{ |
| 26 | + public static function assertJsonPathEquals(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void |
| 27 | + { |
| 28 | + self::assertThat($expectedValue, new JsonPathEquals($jsonPath, $json), $message); |
| 29 | + } |
| 30 | + |
| 31 | + public static function assertJsonPathNotEquals(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void |
| 32 | + { |
| 33 | + self::assertThat($expectedValue, new JsonPathNotEquals($jsonPath, $json), $message); |
| 34 | + } |
| 35 | + |
| 36 | + public static function assertJsonPathCount(int $expectedCount, JsonPath|string $jsonPath, string $json, string $message = ''): void |
| 37 | + { |
| 38 | + self::assertThat($expectedCount, new JsonPathCount($jsonPath, $json), $message); |
| 39 | + } |
| 40 | + |
| 41 | + public static function assertJsonPathSame(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void |
| 42 | + { |
| 43 | + self::assertThat($expectedValue, new JsonPathSame($jsonPath, $json), $message); |
| 44 | + } |
| 45 | + |
| 46 | + public static function assertJsonPathNotSame(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void |
| 47 | + { |
| 48 | + self::assertThat($expectedValue, new JsonPathNotSame($jsonPath, $json), $message); |
| 49 | + } |
| 50 | + |
| 51 | + public static function assertJsonPathContains(mixed $expectedValue, JsonPath|string $jsonPath, string $json, bool $strict = true, string $message = ''): void |
| 52 | + { |
| 53 | + self::assertThat($expectedValue, new JsonPathContains($jsonPath, $json, $strict), $message); |
| 54 | + } |
| 55 | + |
| 56 | + public static function assertJsonPathNotContains(mixed $expectedValue, JsonPath|string $jsonPath, string $json, bool $strict = true, string $message = ''): void |
| 57 | + { |
| 58 | + self::assertThat($expectedValue, new JsonPathNotContains($jsonPath, $json, $strict), $message); |
| 59 | + } |
| 60 | +} |
0 commit comments