@@ -897,7 +897,7 @@ public static function isCacheableDataProvider(): array
897897 */
898898 public function testGenerateElementsWithoutCache (): void
899899 {
900- $ this ->readerContextFactoryMock ->expects ($ this ->once ( ))
900+ $ this ->readerContextFactoryMock ->expects ($ this ->atMost ( 2 ))
901901 ->method ('create ' )
902902 ->willReturn ($ this ->readerContextMock );
903903 $ layoutCacheId = 'layout_cache_id ' ;
@@ -952,6 +952,11 @@ public function testGenerateElementsWithoutCache(): void
952952 $ this ->layoutScheduledSructure ->expects ($ this ->any ())
953953 ->method ('__toArray ' )
954954 ->willReturn ($ layoutScheduledStructureData );
955+
956+ // Ensure __toArray returns valid data for defensive copying
957+ $ this ->pageConfigStructure ->expects ($ this ->any ())
958+ ->method ('__toArray ' )
959+ ->willReturn ($ pageConfigStructureData );
955960 $ data = [
956961 'pageConfigStructure ' => $ pageConfigStructureData ,
957962 'scheduledStructure ' => $ layoutScheduledStructureData ,
@@ -999,7 +1004,7 @@ public function testGenerateElementsWithCache(): void
9991004 $ xml = simplexml_load_string ('<layout/> ' , Element::class);
10001005 $ this ->model ->setXml ($ xml );
10011006
1002- $ this ->readerContextFactoryMock ->expects ($ this ->once ( ))
1007+ $ this ->readerContextFactoryMock ->expects ($ this ->atMost ( 2 ))
10031008 ->method ('create ' )
10041009 ->willReturn ($ this ->readerContextMock );
10051010 $ themeMock = $ this ->getMockForAbstractClass (ThemeInterface::class);
@@ -1035,6 +1040,14 @@ public function testGenerateElementsWithCache(): void
10351040 $ this ->layoutScheduledSructure ->expects ($ this ->once ())
10361041 ->method ('populateWithArray ' )
10371042 ->with ($ layoutScheduledStructureData );
1043+
1044+ // Ensure __toArray returns valid data for defensive copying
1045+ $ this ->layoutScheduledSructure ->expects ($ this ->any ())
1046+ ->method ('__toArray ' )
1047+ ->willReturn ($ layoutScheduledStructureData );
1048+ $ this ->pageConfigStructure ->expects ($ this ->any ())
1049+ ->method ('__toArray ' )
1050+ ->willReturn ($ pageConfigStructureData );
10381051 $ data = [
10391052 'pageConfigStructure ' => $ pageConfigStructureData ,
10401053 'scheduledStructure ' => $ layoutScheduledStructureData ,
0 commit comments