From c7ed9bdae626d6edea6fea05307791adf9b9bb30 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Tue, 25 Jun 2024 11:15:13 +0400 Subject: [PATCH] Fix inheritance tests; revert changes in metadata reader providers --- src/TableInheritance.php | 6 +++++- tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php | 5 ++--- tests/Annotated/Functional/Driver/Common/BaseTestCase.php | 6 +++--- .../Driver/Common/Inheritance/JoinedTableTestCase.php | 2 +- .../Functional/Driver/Common/InheritanceTestCase.php | 7 ++++++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/TableInheritance.php b/src/TableInheritance.php index 176a36f2..3152c15f 100644 --- a/src/TableInheritance.php +++ b/src/TableInheritance.php @@ -66,7 +66,11 @@ public function run(Registry $registry): Registry // All child should be presented in a schema as separated entity // Every child will be handled according its table inheritance type - \assert($child->getRole() !== null && $entity !== null && isset($parent)); + // todo should $parent be not null? + // \assert(isset($parent)); + + \assert($child->getRole() !== null && $entity !== null); + if (!$registry->hasEntity($child->getRole())) { $registry->register($child); diff --git a/tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php b/tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php index c4d6356b..0adf88db 100644 --- a/tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php +++ b/tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php @@ -10,12 +10,11 @@ /** * This proxy class doesn't have an {@see Entity} annotation (attribute) declaration, * and it shouldn't be presented in Schema. - * Note: this behavior might be improved. There will be added support for - * annotated base class columns without Entity annotation declaration. + * But all the classes that extend this class should contain all the fields from this class. */ class ExecutiveProxy extends Employee { - /** @Column(type="string") */ + /** @Column(type="string", name="proxy") */ #[Column(type: 'string', name: 'proxy')] public ?string $proxyFieldWithAnnotation = null; diff --git a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php b/tests/Annotated/Functional/Driver/Common/BaseTestCase.php index 54f3a2c6..05fbcda0 100644 --- a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/BaseTestCase.php @@ -115,14 +115,14 @@ public function getDriver(): Driver public static function singularReadersProvider(): \Traversable { - yield ['reader' => new AnnotationReader()]; - yield ['reader' => new AttributeReader()]; + yield ['Annotation reader' => new AnnotationReader()]; + yield ['Attribute reader' => new AttributeReader()]; } public static function allReadersProvider(): \Traversable { yield from static::singularReadersProvider(); - yield ['reader' => new SelectiveReader([new AttributeReader(), new AnnotationReader()])]; + yield ['Selective reader' => new SelectiveReader([new AttributeReader(), new AnnotationReader()])]; } protected function getDatabase(): Database diff --git a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php b/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php index 52ec0e69..64d32f53 100644 --- a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php @@ -125,7 +125,7 @@ public function testTableInheritance(ReaderInterface $reader): void $this->assertSame('secret', $loadedExecutive->hidden); $this->assertSame(15000, $loadedExecutive->bonus); $this->assertSame('executive', $loadedExecutive->getType()); - $this->assertNull($loadedExecutive->proxyFieldWithAnnotation); + $this->assertSame('value', $loadedExecutive->proxyFieldWithAnnotation); } #[DataProvider('allReadersProvider')] diff --git a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php index 515fd52b..24457413 100644 --- a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php @@ -109,7 +109,12 @@ public function testTableInheritance(ReaderInterface $reader): void $this->assertSame('foo_id', $schema['executive'][SchemaInterface::PARENT_KEY]); $this->assertSame('executives', $schema['executive'][SchemaInterface::TABLE]); $this->assertSame( - ['bonus' => 'bonus', 'foo_id' => 'id', 'hidden' => 'hidden'], + [ + 'bonus' => 'bonus', + 'proxyFieldWithAnnotation' => 'proxy', + 'foo_id' => 'id', + 'hidden' => 'hidden', + ], $schema['executive'][SchemaInterface::COLUMNS] );