Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReadFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\Filesystem\File\ReadFactory;
9 
13 class ReadFactoryTest extends \PHPUnit\Framework\TestCase
14 {
15  public function testCreate()
16  {
17  $driverPool = $this->createPartialMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']);
18  $driverPool->expects($this->never())->method('getDriver');
19  $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class);
20  $driver->expects($this->any())->method('isExists')->willReturn(true);
21  $factory = new ReadFactory($driverPool);
22  $result = $factory->create('path', $driver);
23  $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $result);
24  }
25 
26  public function testCreateWithDriverCode()
27  {
28  $driverPool = $this->createPartialMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']);
29  $driverMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class);
30  $driverMock->expects($this->any())->method('isExists')->willReturn(true);
31  $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock);
32  $factory = new ReadFactory($driverPool);
33  $result = $factory->create('path', 'driverCode');
34  $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $result);
35  }
36 }