tao-test/app/vendor/respect/validation/tests/unit/Rules/JsonTest.php

54 lines
1.2 KiB
PHP

<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
*/
namespace Respect\Validation\Rules;
/**
* @group rule
* @covers Respect\Validation\Rules\Json
* @covers Respect\Validation\Exceptions\JsonException
*/
class JsonTest extends RuleTestCase
{
public function providerForValidInput()
{
$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'],
];
}
public function providerForInvalidInput()
{
$json = new Json();
return [
[$json, false],
[$json, new \stdClass()],
[$json, []],
[$json, ''],
[$json, 'a'],
[$json, 'xx'],
[$json, '{foo: bar}'],
[$json, '{foo: "baz"}'],
];
}
}