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:----s7eYi0FAq/tS+Esnm1vCMhmQsuNDMhnIIDCzHR2aYylCR9loHrg9+a/A2fVqDT3FHOY1gkuichu+/Bya7vZQT8WFM+N13fdcZLM2FTanVHblSB3cBNOeNBUg48/W4zpWB6V4Zw4i5Du1I2POBxRSpERdbTK254jepLHjW/IabwrbL9hzE1pG4Wr03EhI8oNZ69lypaPmAqb5m3kuGGSF+/6AOjIAizu98TcAuyFP8dhoxd0aTjgU3MnRTwPx2stmakZGyF9+51q6n4C3fAk9t8JOyXmakVjJJlBa4vu4uW0lsuwW6CCxCIC9Q862HqEFK0H0Dxp/Jr1JvIeJS9+ot8XPCYIJ3l9SaBZtXVpVpK/f86nsEwYuUb7c0tKKml3NfDXDcNeXrpcn7viAEphyr+zH212Atca6gfYDj4IRWmT5kkP+z0ngU5S9Xy4lzudeD6BLLIiI7TfopyVQkCoCylcpw/Y30lMUghbFT4n/QrjH6qdcED3417beD6dburCWMPUq/tu6Ieh0Qr44q1atLUlvb8p8zwhvaZa7WtzPEdnNUyrwEL6zzGHasLnig579nep4KlZKZtfy9QVv/gnQPrAN41R8sw0blABIMIsm85xOHGPqUm9zPEVcMGjTLzwOAPBlp8e9EvU+PKilm37sLyFDCU1uvL8kMFapqprdt4c=----ATTACHMENT:----Njg5NDI0NzI1MjY4NTA5NyA2MDUxNDkzNjg2ODg0MjE1IDI5NDEzNjEzMzY2MTYwOA==