@@ -477,6 +477,57 @@ public function testNestedMetadataArrayOfDiverseObjects()
477
477
$ this ->assertEquals ($ expectedResult , $ result );
478
478
}
479
479
480
+
481
+ public function testExtendedWithRequiredEntity ()
482
+ {
483
+ $ entityDataObjectBuilder = new EntityDataObjectBuilder ();
484
+ $ extEntityDataObject = $ entityDataObjectBuilder
485
+ ->withName ("extEntity " )
486
+ ->withType ("entity " )
487
+ ->withLinkedEntities (["baseSubentity " => "subentity " ,"extSubentity " => "subentity " ])
488
+ ->build ();
489
+
490
+ $ mockDOHInstance = AspectMock::double (DataObjectHandler::class, ["getObject " => function ($ name ) {
491
+ $ entityDataObjectBuilder = new EntityDataObjectBuilder ();
492
+
493
+ if ($ name == "baseSubentity " ) {
494
+ return $ entityDataObjectBuilder
495
+ ->withName ("baseSubentity " )
496
+ ->withType ("subentity " )
497
+ ->withDataFields (["subtest " => "BaseSubtest " ])
498
+ ->build ();
499
+ }
500
+
501
+ if ($ name == "extSubentity " ) {
502
+ return $ entityDataObjectBuilder
503
+ ->withName ("extSubentity " )
504
+ ->withType ("subentity " )
505
+ ->withDataFields (["subtest " => "ExtSubtest " ])
506
+ ->build ();
507
+ }
508
+ }])->make ();
509
+ AspectMock::double (DataObjectHandler::class, ['getInstance ' => $ mockDOHInstance ]);
510
+
511
+ $ subentityOpElementBuilder = new OperationElementBuilder ();
512
+ $ subentityOpElement = $ subentityOpElementBuilder
513
+ ->withKey ("sub " )
514
+ ->withType ("subentity " )
515
+ ->withElementType ("object " )
516
+ ->withFields (["subtest " => "string " ])
517
+ ->build ();
518
+
519
+ $ operationResolver = new OperationDataArrayResolver ();
520
+ $ result = $ operationResolver ->resolveOperationDataArray ($ extEntityDataObject ,[$ subentityOpElement ], "create " , false );
521
+
522
+ $ expected = [
523
+ "sub " => [
524
+ "subtest " => "ExtSubtest "
525
+ ]
526
+ ];
527
+
528
+ $ this ->assertEquals ($ expected , $ result );
529
+
530
+ }
480
531
/**
481
532
* After class functionality
482
533
* @return void
0 commit comments