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); }
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'])); }
public function testArray() { $this->types['user'] = '******'; $jsonType = new JsonType($this->data); $this->assertTrue($jsonType->matches($this->types)); }