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:----kjCMwVC6ibrWBeHQyoOxvjnRSdzaA8GGiqps8AkjpMfU23lliQYm1ks9GPqLzXGcjVt7miZ0v0z9ftxYpeYl53nYgnwdrXbOk/iADV9C063FpNV49V7dmFH8OGnqJltkKSfOvrW431/pAsfoqf/IlUnHwWXRYCCdi8f/Yi6EpfHgG2E0CEgLcc0pXWCGxn3LRWiwaitQ6LfVynIzyBdxuZTbjSz0gWmFl7bmiFMWQC2M4HiYZkyxbWbl5GeyyIDCxEbFS4stWZE+alglmBGd3ycecrDuMG5iVCMumsY1CK6xOzWUqcGjKV/qezICX1x+ynSuF5hbi6B9MUdqYVyriMFgwTxQXSxbfXM71vSgLKYvohxaE2nEzE703RTsMyqLKgKobvzeDj1JBvZRvs8KelgjV7RAousOLPHskb5KWVP8KY1Mg0y+3BdcAYZqupMDmHt3b4bT+r7Mk5+i0dm9L0wo9LlGBF+mAdU8znRMSxN6ljwOHEGPgDKOjtKH1NNVplsmTGquwLD07BGr8uCG104FUTJcz2jt86AIjeOwHqMcAu+Y/2QlUMfHfRxQil0Hna0G3K8XHr/9giS5Xhlrqpqij//AcZO5LTEH5EOBDCdJwFm3OZaezPvpfym1Gnb1sMmm70Yw1cay4868ac2j2zdvMUyX78I6MkPCkbN7UVc=----ATTACHMENT:----NDYxMDk0NDMwMjIxMDYzNyA3NjY3NTc5MjMyMTEwNjMxIDIwMDE5MDgzNTU5MDUzMTM=