Skip to content

Commit a1f9a61

Browse files
committed
JSON Serialize Stop Recursion: Fix tests
1 parent d0b598e commit a1f9a61

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/TDBMAbstractServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ private static function initSchema(Connection $connection): void
459459
->column('id')->integer()->primaryKey()->autoIncrement()
460460
->column('fk_1')->integer()
461461
->column('fk_2')->integer()
462-
->then()->addForeignKeyConstraint($targetTable, ['fk_1', 'fk_2'], ['id_1', 'id_2']);
462+
->then()->getDbalTable()->addForeignKeyConstraint($targetTable->getDbalTable(), ['fk_1', 'fk_2'], ['id_1', 'id_2']);
463463

464464

465465
$sqlStmts = $toSchema->getMigrateFromSql($fromSchema, $connection->getDatabasePlatform());

tests/TDBMDaoGeneratorTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,9 +1941,9 @@ public function testJsonRecursive(): void
19411941
self::assertEquals('index.html', $json['alias']['alias']['basename']);
19421942
// ... each alias even serializes its parents, ...
19431943
self::assertTrue(isset($json['alias']['alias']['parent']['parent']));
1944-
// ... however, parents aliases chains are not serialized, as parents are serialized with $stopRecursion=true
1945-
self::assertTrue(!isset($json['alias']['alias']['parent']['parent']['alias']));
1946-
self::assertNotNull($index->getAlias()->getAlias()->getParent()->getParent()->getAlias());
1944+
// ... however, parents aliases chains have just their foreign key (id), as parents are serialized with $stopRecursion=true
1945+
self::assertEquals(3, $json['alias']['alias']['parent']['parent']['alias']['id']);
1946+
self::assertCount(1 , $json['alias']['alias']['parent']['parent']['alias']);
19471947
}
19481948

19491949
/**
@@ -1981,8 +1981,9 @@ public function testJsonCollection(): void
19811981
// Collection name properly handled ('discography' instead of default 'albums')
19821982
self::assertTrue(isset($json['discography']));
19831983
self::assertEquals($animals->getTitle(), $json['discography'][0]['title']);
1984-
// Make sure top object is not its own grandfather
1985-
self::assertTrue(!isset($json['discography'][0]['artist']));
1984+
// Make sure top object have just its primary key
1985+
self::assertEquals(1, $json['discography'][0]['artist']['id']);
1986+
self::assertCount(1, $json['discography'][0]['artist']);
19861987
$json = $animals->jsonSerialize();
19871988
// Nevertheless, artist should be serialized in album as top object...
19881989
self::assertTrue(isset($json['artist']));

0 commit comments

Comments
 (0)