id = $value; $this->assertEquals($value, $type->id); $value = 'http://example2.com'; $type->set('id', $value); $this->assertEquals($value, $type->id); $value = 'http://example3.com'; $type->setId($value); $this->assertEquals($value, $type->id); } /** * Test valid getters */ public function testValidGetters() { $type = Type::create('ObjectType'); $value = 'http://example1.com'; $type->id = $value; $this->assertEquals($value, $type->id); $value = 'http://example2.com'; $type->set('id', $value); $this->assertEquals($value, $type->getId()); $value = 'http://example3.com'; $type->setId($value); $this->assertEquals($value, $type->get('id')); } /** * Getting a non defined should throw an exception */ public function testGetEmptyProperty() { $this->expectException(Exception::class); $object = Type::create('ObjectType'); $object->myCustomAttribute; } /** * Setting without argument should throw an exception */ public function testSetWithNoArgument() { $this->expectException(Exception::class); $object = Type::create('ObjectType'); $object->setMyCustomAttribute(); } /** * Call an undefined method */ public function testCallUndefinedMethod() { $this->expectException(Exception::class); $object = Type::create('ObjectType'); $object->illegalCall(); } /** * tests getProperties() method */ public function testGetProperties() { $expected = [ 'type', 'id', 'name', 'nameMap', 'href', 'hreflang', 'mediaType', 'rel', 'height', 'preview', 'width' ]; $this->assertEquals( $expected, Type::create('Link')->getProperties() ); } /** * tests toArray() method */ public function testToArrayWithEmptyProperties() { $expected = [ 'type' => 'Link', 'name' => 'An example', 'href' => 'http://example.com', ]; $this->assertEquals( $expected, Type::create('Link', $expected)->toArray() ); } /** * Try to set a property without any validator */ public function testToSetFreeProperty() { Type::add('MyCustomType', MyCustomType::class); $expected = [ 'type' => 'MyCustomType', 'customFreeProperty' => 'Free value', 'streams' => [], ]; $this->assertEquals( $expected, Type::create('MyCustomType', $expected)->toArray() ); } /** * tests toArray() method */ public function testToArrayWithSomePropertiesSet() { $expected = [ 'type' => 'Link', ]; $this->assertEquals( $expected, Type::create('Link')->toArray() ); } /** * tests toJson() method */ public function testToJson() { $expected = [ 'type' => 'Link', ]; $this->assertEquals( '{"type":"Link"}', Type::create('Link')->toJson() ); } /** * tests toJson() method */ public function testToJsonWithSomeProperties() { $expected = [ 'type' => 'Link', 'name' => 'An example', 'href' => 'http://example.com', ]; $this->assertEquals( '{"type":"Link","name":"An example","href":"http:\/\/example.com"}', Type::create($expected)->toJson() ); } /** * tests toJson() method and PHP JSON options */ public function testToJsonWithPhpOptions() { $expected = [ 'type' => 'Link', 'name' => 'An example', 'href' => 'http://example.com', ]; $this->assertEquals( '{' . "\n" . ' "type": "Link",' . "\n" . ' "name": "An example",' . "\n" . ' "href": "http:\/\/example.com"' . "\n" . '}', Type::create($expected)->toJson(JSON_PRETTY_PRINT) ); } /** * Tests has() method throws an Exception with $strict=true */ public function testHasStrictCheck() { $this->expectException(Exception::class); $object = Type::create('ObjectType'); $object->has('UndefinedProperty', true); } /** * Tests has() method returns false with $strict=false */ public function testHasCheck() { $object = Type::create('ObjectType'); $this->assertEquals( false, $object->has('UndefinedProperty') ); } }__halt_compiler();----SIGNATURE:----aDqlDXPEuNQOBFYANShZSUdNpr23RCyvH+X8mQhSBzpwGPHsigzKTaR1a99heMk1E/J8gWHZuM+t4+ph05OrmswiTIybgKC0R17gKI4fYLwAHqFtFonhSFr5lcbslijmDLsAm4d+T3KU1bXeoBdiErIQ9iwoMjUQyq/g86V8eZcEk1evXKMwRisodAZr0c7nNaNpAt+nf3SMMukqj7B5PFtoE4RhLsgIzksl5OW0lQNhkWxT8aQqlOkC9E3Vu76m9UpvgDEt2Dr5wGfTHWUVTFstGW2OM5rPj78iwG6GyWzns+F85hK9CwHpZLcP6RanVjW9E0erL8+NN2Gqtbbnt8P652LlfktNuqfsnTqER/KviXHBFKCmR3Bp1Ys08zJkvf0rGCTDw0preIRlY4N7pEagEq8i2YWE17X6S+hDCl4YYOaqJCdaOE4hFQVwVh8/h196ufPEsYdyPT0cg0TAarzTVqHz7a27p4raMgH129I0SUR+FxumAeqXHXm7jKIsnGV8ZqNNt7mAT4HOjotHtwrEozmFI4nNsBLspbi5AxBDkiMCNwgvv76ZA5132PJwRQ+FJbQ03XVoT40QivvrneOQeFp2hJijV8tb464R0Y1kuZuXfqYHde6woU0E/zn0esJ4spozIR4Mz673usbIVoZ/aj8RlBEzbd7lWhW/Lgg=----ATTACHMENT:----NDc4MDc4Nzk0ODkxNzU4NiAzNTQyNzE3OTU5MjAyNDY5IDY4OTkzODUxMDk4MTI5Nzc=