mapperMock = $this->getMockBuilder(Mapper::class) ->disableOriginalConstructor() ->getMock(); $this->readerXmlMock = $this->getMockBuilder(ReaderInterface::class) ->disableOriginalConstructor() ->getMock(); $this->readerDbMock = $this->getMockBuilder(ReaderInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->reader = $this->objectManagerHelper->getObject( Reader::class, [ 'mapper' => $this->mapperMock, 'readers' => [ $this->readerXmlMock, $this->readerDbMock, ], ] ); } /** * @return void */ public function testRead() { $scope = 'store'; $xmlReaderResult = [ 'config' => ['node1' => ['node2' => 'node4']] ]; $dbReaderResult = [ 'config' => ['node1' => ['node2' => 'node3']] ]; $mapperResult = ['node2' => ['node3', 'node4']]; $this->readerXmlMock ->expects($this->once()) ->method('read') ->with($scope) ->willReturn($xmlReaderResult); $this->readerDbMock ->expects($this->once()) ->method('read') ->with($scope) ->willReturn($dbReaderResult); $this->mapperMock ->expects($this->once()) ->method('execute') ->with(array_merge_recursive($xmlReaderResult, $dbReaderResult)) ->willReturn($mapperResult); $this->assertSame($mapperResult, $this->reader->read($scope)); } }