示例#1
0
 public function testCollection()
 {
     $jsonType = new JsonType([['id' => 1], ['id' => 3], ['id' => 5]]);
     $this->assertTrue($jsonType->matches(['id' => 'integer']));
     $this->assertNotTrue($res = $jsonType->matches(['id' => 'integer:<3']));
     $this->assertContains('3` is of type `integer:<3', $res);
     $this->assertContains('5` is of type `integer:<3', $res);
 }
示例#2
0
 public function testNull()
 {
     $jsonType = new JsonType(json_decode('{
         "id": 123456,
         "birthdate": null,
         "firstname": "John",
         "lastname": "Doe"
     }', true));
     $this->assertTrue($jsonType->matches(['birthdate' => 'string|null']));
     $this->assertTrue($jsonType->matches(['birthdate' => 'null']));
 }
示例#3
0
 public function testArray()
 {
     $this->types['user'] = '******';
     $jsonType = new JsonType($this->data);
     $this->assertTrue($jsonType->matches($this->types));
 }