dirListMock = $this->getMockBuilder(DirectoryList::class) ->disableOriginalConstructor() ->getMock(); $this->driverPoolMock = $this->getMockBuilder(DriverPool::class) ->disableOriginalConstructor() ->getMock(); $this->configFilePool = $this->getMockBuilder(ConfigFilePool::class) ->disableOriginalConstructor() ->getMock(); $this->driverMock = $this->getMockBuilder(DriverInterface::class) ->getMockForAbstractClass(); $this->model = new FileReader( $this->dirListMock, $this->driverPoolMock, $this->configFilePool ); } public function testLoad() { $fileKey = 'configKeyOne'; $this->dirListMock->expects($this->exactly(2)) ->method('getPath') ->with(DirectoryList::CONFIG) ->willReturn(__DIR__ . '/_files'); $this->driverPoolMock->expects($this->exactly(2)) ->method('getDriver') ->with(DriverPool::FILE) ->willReturn($this->driverMock); $this->configFilePool->expects($this->exactly(2)) ->method('getPath') ->willReturnMap([['configKeyOne', 'config.php']]); $this->driverMock->expects($this->exactly(2)) ->method('isExists') ->willReturnOnConsecutiveCalls(true, false); $this->configFilePool ->expects($this->any()) ->method('getPath') ->willReturnMap([['configKeyOne', 'config.php']]); $this->assertSame(['fooKey' => 'foo', 'barKey' => 'bar'], $this->model->load($fileKey)); $this->assertSame([], $this->model->load($fileKey)); } }