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:----IJ5u/yv+uEZPHge4+4CaTVhw7f9ZQqGHZ7FXvtMNq4umlVtYRcnKu39XF6sQjxrAVR0BmF1hHnxoTH2ZJAm8V8c4JB4AyRqD3iK3bACvXtSdCcy5sUFPalzg+bse7PBtIM7pWtAHnBqyGGTX8i5wtiV2pZZxcva1Bp1kU+eEP+tFI29v9/PZR9sTqrQWr72lJhPFLcmazMLBeDu0UJJGPKtQ7J16e7jzyAkuc7kj5xPzIwxxATb/Uzo1kURGdpm04do7TymeOiFZcljB1YQ+B5BZneEeHDJ0s40ARm2diAXmThboPP+JOIaz77JMVYfJrYkT8ty6fhGgVVP25r1BPulfndHNJuXSNHIPzMBuohMft7URzm0QUkXSdQp0w/uJFzdB8ErdHHiIKRdqceINQ3L3vYaZaz28dpNsincxbDcJXaKlkOZ99yZcrDKpaPzUSdQiyWRfkBBWqJ+Zim5comSXQ6hFxnnIGclJYLptlgMR4qupNSYh+KeSPSlzw1OP9vPx59ElJS8F27nuKfYFBcAFnjO89/6KKX5tDIxZYNqMdBTqzS1sL+ySkEVMR2CpZ5n16fuebCM5Gf8Uv5Be4nBMCofYdUYDcS4tRCuw+Uqj6/7sRhiuvap7yw/bueuH6Zfi/3f7/cLNKRj1Du9bmUJRrFPiowYZTG1MuJUQzY4=----ATTACHMENT:----OTA1NTE0NzI5ODk0NDYwMCA1NzkwODM3NDEzNzk0MDAgOTMyNDc3NTA2NDI1MDAyNQ==