@@ -1024,25 +1024,22 @@ public function testIdenticalTwoWayKeyRelationship(): void
10241024 id: 'child1 '
10251025 );
10261026
1027- try {
1028- $ database ->createRelationship (
1029- collection: 'parent ' ,
1030- relatedCollection: 'child ' ,
1031- type: Database::RELATION_ONE_TO_MANY ,
1032- id: 'children ' ,
1033- );
1034- $ this ->fail ('Failed to throw Exception ' );
1035- } catch (Exception $ e ) {
1036- $ this ->assertEquals ('Related attribute already exists ' , $ e ->getMessage ());
1037- }
1038-
1039- $ database ->createRelationship (
1027+ $ result = $ database ->createRelationship (
10401028 collection: 'parent ' ,
10411029 relatedCollection: 'child ' ,
10421030 type: Database::RELATION_ONE_TO_MANY ,
10431031 id: 'children ' ,
1032+ );
1033+ $ this ->assertTrue ($ result );
1034+
1035+ $ result = $ database ->createRelationship (
1036+ collection: 'parent ' ,
1037+ relatedCollection: 'child ' ,
1038+ type: Database::RELATION_ONE_TO_MANY ,
1039+ id: 'childrenById ' ,
10441040 twoWayKey: 'parent_id '
10451041 );
1042+ $ this ->assertTrue ($ result );
10461043
10471044 $ collection = $ database ->getCollection ('parent ' );
10481045 $ attributes = $ collection ->getAttribute ('attributes ' , []);
@@ -1052,6 +1049,10 @@ public function testIdenticalTwoWayKeyRelationship(): void
10521049 }
10531050
10541051 if ($ attribute ['key ' ] === 'children ' ) {
1052+ $ this ->assertEquals ('parent ' , $ attribute ['options ' ]['twoWayKey ' ]);
1053+ }
1054+
1055+ if ($ attribute ['key ' ] === 'childrenById ' ) {
10551056 $ this ->assertEquals ('parent_id ' , $ attribute ['options ' ]['twoWayKey ' ]);
10561057 }
10571058 }
0 commit comments