Skip to content

Commit

Permalink
Fix inheritance tests; revert changes in metadata reader providers
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jun 25, 2024
1 parent 309bf55 commit c7ed9bd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/TableInheritance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions tests/Annotated/Functional/Driver/Common/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);

Expand Down

0 comments on commit c7ed9bd

Please sign in to comment.