Skip to content

Commit b97f468

Browse files
committed
Adding failing test for junction tables pointing to a parent table in an inheritance relationship
1 parent fbcba88 commit b97f468

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/TDBMAbstractServiceTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ private static function initSchema(Connection $connection): void
439439
->column('parent_id')->references('artists')
440440
->column('child_id')->references('artists');
441441

442+
$db->junctionTable('person', 'boats');
443+
442444
$sqlStmts = $toSchema->getMigrateFromSql($fromSchema, $connection->getDatabasePlatform());
443445

444446
foreach ($sqlStmts as $sqlStmt) {
@@ -746,6 +748,18 @@ private static function initSchema(Connection $connection): void
746748
'track_id' => 5,
747749
'artist_id' => 2
748750
]);
751+
752+
self::insert($connection, 'boats', [
753+
'name' => 'RoseBud',
754+
'anchorage_country' => 1,
755+
'current_country' => 1,
756+
'length' => '13.5',
757+
]);
758+
759+
self::insert($connection, 'person_boats', [
760+
'person_id' => 1,
761+
'boat_id' => 1,
762+
]);
749763
}
750764

751765
protected static function insert(Connection $connection, string $tableName, array $data): void

tests/TDBMDaoGeneratorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,22 @@ public function testJointureSave10(): void
646646
$this->assertEquals(2, $roles[0]->getId());
647647
}
648648

649+
/**
650+
* Test jointure in a parent table in an inheritance relationship
651+
*
652+
* @depends testDaoGeneration
653+
*/
654+
public function testJointureInParentTable(): void
655+
{
656+
$userDao = new UserDao($this->tdbmService);
657+
$user = $userDao->getById(1);
658+
659+
$boats = $user->getBoats();
660+
661+
$this->assertCount(1, $boats);
662+
$this->assertEquals(1, $boats[0]->getId());
663+
}
664+
649665
/**
650666
* @depends testDaoGeneration
651667
*/

0 commit comments

Comments
 (0)