-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathJsonTest.php
More file actions
34 lines (28 loc) · 984 Bytes
/
JsonTest.php
File metadata and controls
34 lines (28 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Rakit\Validation\Tests\Rules;
use Rakit\Validation\Rules\Json;
use PHPUnit\Framework\TestCase;
class JsonTest extends TestCase
{
public function setUp()
{
$this->rule = new Json;
}
public function testValids()
{
$this->assertTrue($this->rule->check('{}'));
$this->assertTrue($this->rule->check('[]'));
$this->assertTrue($this->rule->check('false'));
$this->assertTrue($this->rule->check('null'));
$this->assertTrue($this->rule->check('{"username": "John Doe"}'));
$this->assertTrue($this->rule->check('{"number": 12345678}'));
}
public function testInvalids()
{
$this->assertFalse($this->rule->check(''));
$this->assertFalse($this->rule->check(123));
$this->assertFalse($this->rule->check(false));
$this->assertFalse($this->rule->check('{"username": John Doe}'));
$this->assertFalse($this->rule->check('{number: 12345678}'));
}
}