fileSystemMock = $this->getMockBuilder(Filesystem::class) ->disableOriginalConstructor() ->getMock(); $this->flyweightFactoryMock = $this->getMockBuilder(FlyweightFactory::class) ->disableOriginalConstructor() ->getMock(); $this->model = new Codes( $this->flyweightFactoryMock, $this->fileSystemMock ); } public function testGetList() { $code = 'code'; $area = 'area'; $fullPath = 'some/full/path'; $themeMock = $this->getMockBuilder(ThemeInterface::class) ->getMockForAbstractClass(); $themeMock->expects($this->once()) ->method('getFullPath') ->willReturn($fullPath); $this->flyweightFactoryMock->expects($this->once()) ->method('create') ->with($code, $area) ->willReturn($themeMock); $reader = $this->getMockBuilder(ReadInterface::class) ->getMockForAbstractClass(); $reader->expects($this->once()) ->method('read') ->with($fullPath) ->willReturn([ $fullPath . '/de_DE', $fullPath . '/en_US', $fullPath . '/fr_FR' ]); $this->fileSystemMock->expects($this->once()) ->method('getDirectoryRead') ->with(DirectoryList::STATIC_VIEW) ->willReturn($reader); $this->assertEquals( [ 'de_DE', 'en_US', 'fr_FR' ], $this->model->getList($code, $area) ); } }