* SPDX-FileContributor: Danilo Benevides * SPDX-FileContributor: Emmerson Siqueira * SPDX-FileContributor: Henrique Moody * SPDX-FileContributor: Nick Lombard */ declare(strict_types=1); namespace Respect\Validation\Validators; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use Respect\Validation\Test\RuleTestCase; use stdClass; #[Group('validator')] #[CoversClass(Json::class)] final class JsonTest extends RuleTestCase { /** @return iterable */ public static function providerForValidInput(): iterable { $json = new Json(); return [ [$json, '2'], [$json, '"abc"'], [$json, '[1,2,3]'], [$json, '["foo", "bar", "number", 1]'], [$json, '{"foo": "bar", "number":1}'], [$json, '[]'], [$json, '{}'], [$json, 'false'], [$json, 'null'], ]; } /** @return iterable */ public static function providerForInvalidInput(): iterable { $json = new Json(); return [ [$json, false], [$json, new stdClass()], [$json, []], [$json, ''], [$json, 'a'], [$json, 'xx'], [$json, '{foo: bar}'], [$json, '{foo: "baz"}'], ]; } }