mockDirectoryList = $this->getMockBuilder(\Magento\Framework\App\Filesystem\DirectoryList::class) ->disableOriginalConstructor() ->getMock(); $this->mockDirectoryList->expects($this->any()) ->method('getPath') ->willReturnArgument(0); } public function testPopulateMappings() { $mockAutoloader = $this->getMockBuilder(\Magento\Framework\Autoload\AutoloaderInterface::class) ->disableOriginalConstructor() ->getMock(); $mockAutoloader->expects($this->once()) ->method('addPsr4') ->with( 'Magento\\', [DirectoryList::GENERATED_CODE . '/Magento/'], true ); $mockAutoloader->expects($this->once()) ->method('addPsr0') ->with('', [DirectoryList::GENERATED_CODE]); Populator::populateMappings($mockAutoloader, $this->mockDirectoryList); } }