Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DriverPoolTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Framework\Filesystem\DriverPool;
10 
11 class DriverPoolTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testGetDriver()
14  {
15  $object = new DriverPool();
17  $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver($code));
18  }
19  $default = $object->getDriver('');
20  $this->assertInstanceOf(\Magento\Framework\Filesystem\Driver\File::class, $default);
21  $this->assertSame($default, $object->getDriver(''));
22  }
23 
24  public function testCustomDriver()
25  {
26  $customOne = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class);
27  $customTwo = get_class($this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class));
28  $object = new DriverPool(['customOne' => $customOne, 'customTwo' => $customTwo]);
29  $this->assertSame($customOne, $object->getDriver('customOne'));
30  $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver('customOne'));
31  $this->assertEquals($customTwo, get_class($object->getDriver('customTwo')));
32  $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver('customTwo'));
33  }
34 
39  public function testCustomDriverException()
40  {
41  new DriverPool(['custom' => new \StdClass()]);
42  }
43 }
$code
Definition: info.phtml:12