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:----EmpTbCJdWOfmKjosTz+jG5F3EgQjo6bEbaNVfbQEZufBz8dHhiBktljdLPUkw+ETtU3gdEmn/a1qXn4vVxN1hty/vxo58Xl7j8uz565wXMxuKIvxcftexFV4TgPHNh9houqgLI9zLm1AGBfOaEp4ORO4A631qGgPwxPPWkTQIgZfeJpn1SEnj+f4ptISkgKYpNnt6W3Vy8czz3tloZ6dsmAb4gBO9H6hBAqoA+/3AJAZpEdHUfol3D+uJiucVQMVtU+8HmH5Gwqa0h/r1ROY3YcKDJ5rMc6uUqkuUGykk3yReuOOZZ9lgJ5rh2bzO8FUedwRyfFK5RJ3dmyHCcMT5/hHQJtH9Qh/WKA+6cNgGq+A8lcjmbkjuxy5t8vu03xoKiZGy1c6IYWK1TvZh2OO09DqlpIf+8nHj6AkoCG4W7ZH767CPcpeyyLQ9KXEqXVpzUC9wvuPErDDfZTjxovXL2ycTQiibxmwoBi1BMlRKlWnNjJoHySR440Wt1hfHfWg4kLc2LeAgwOqyn1TR16QrfYORIOlyWLfsUyEz0NZ1CI7XRDaw7gcUhH9y4rvaUjQxVBiQksRpZhwlKK9JHeGbbLzLAEFxfU6kSBrLNQ9kbvBw+rvrjV/h+6FFUWAuTtjEwDqUCyznijbGuJwBUSox7v4M0qqToABNcz5uole52A=----ATTACHMENT:----NzcwMzc3NTcwOTI5Mjc5MCA4NTU0ODA1OTI5NzEyNDg2IDE3ODQzMDUzNjUwMzQ3NTc=