* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class SchemaAbstractTest extends TestCase { /** @var \Doctrine\Common\Annotations\Reader */ protected $reader; /** @var \PSX\Schema\SchemaManager */ protected $schemaManager; protected function setUp(): void { $this->reader = new AnnotationReader(); $this->schemaManager = new SchemaManager($this->reader); } /** * Tests whether we get a copy of a schema and not a reference */ public function testGetSchema() { $schemaC = $this->schemaManager->getSchema(SchemaCommon::class); $schemaA = $this->schemaManager->getSchema(SchemaA::class); $schemaB = $this->schemaManager->getSchema(SchemaB::class); $this->assertInstanceOf(ReferenceType::class, $schemaC->getType()); $type = $schemaC->getDefinitions()->getType($schemaC->getType()->getRef()); $this->assertInstanceOf(StructType::class, $type); $this->assertNull($type->getProperty('lat')->getTitle()); $this->assertNull($type->getProperty('long')->getTitle()); $this->assertInstanceOf(ReferenceType::class, $schemaA->getType()); $type = $schemaA->getDefinitions()->getType($schemaA->getType()->getRef()); $this->assertInstanceOf(StructType::class, $type); $this->assertEquals('foo', $type->getProperty('lat')->getTitle()); $this->assertEquals(null, $type->getProperty('long')->getTitle()); $this->assertInstanceOf(ReferenceType::class, $schemaB->getType()); $type = $schemaB->getDefinitions()->getType($schemaB->getType()->getRef()); $this->assertInstanceOf(StructType::class, $type); $this->assertEquals(null, $type->getProperty('lat')->getTitle()); $this->assertEquals('bar', $type->getProperty('long')->getTitle()); } public function testSerialize() { $schema = $this->schemaManager->getSchema(SchemaCommon::class); $data = serialize($schema); /** @var SchemaInterface $schema */ $schema = unserialize($data); $this->assertInstanceOf(Schema::class, $schema); $this->assertInstanceOf(StructType::class, $schema->getDefinitions()->getType('Entry')); $this->assertInstanceOf(StructType::class, $schema->getDefinitions()->getType('Author')); $this->assertInstanceOf(StructType::class, $schema->getDefinitions()->getType('Location')); $this->assertInstanceOf(ReferenceType::class, $schema->getType()); } } __halt_compiler();----SIGNATURE:----XsprlnpK5ACmp/jZxfCYIQX2yxecFjUG2swvGfIt+qEBOxlHukmjiIrODF4Z7/6HOYUuCHmIp2lLf0ydVTyyM3ydLd2NclULcQL22sjGPNps0wBjaojFHQx6pEOpodKDlBGYYL1jZdk9bnHcGIW8d63TemIu4b9pUxj8PelOsdYWnBnaTyMj3jAzGfdhjKMyrH38dlNaY2wUtE1ws7rxbEyqo6q0NUjZRr14KJm9PafVF5ldUpmt5jhPXxs1A1o9xQg/eGiHRMcSpIjni/WIDFWB/2bmU+yjBQbCZPPq+YIPSQ2k3z4gPypQZlrfh8tBJ43LBdce9TWNT72DamPCgoqmwl8N/uHWooHQER3aFK0x2MipShEsBB+PG7u6OTsNUzheZYnv3E6lR+r6vI0x/y+Y+lBPtAlPvkaBO/HTdYhaOF8GXTDSL/2u7oFVD7H7D3qOTD1Z3/ngncjjXsMzeA0kUAzct0x+EYOipe6gkrMdqFBIjHzjz+0P2EM+RUwUVPu/Cx2xbbyQ9C5+LYnqPyIbNq+nzOXq6NC9NDvM/KKC6kqaO+mRocvz+dpICVpvmpskMfDjSFymMgLfnIICRYtfKieIzzRPEFSxlGD6zzd2DCV1bQuMqrylK2gAwevKRkKRJhqwAAB13Wv939R5+TXp5s7Y9upwjrWa5hyz/ng=----ATTACHMENT:----OTEzMzYwMTA2MTg1NDA4OCA5NTU0ODQ3NjcyNTkwOTMwIDU1NjgyMDY4MjQ1OTQ5ODk=