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