Exemplo n.º 1
0
 public function testDirectoriesCustomization()
 {
     $config = [DirectoryList::APP => [DirectoryList::PATH => 'foo', DirectoryList::URL_PATH => 'bar']];
     $object = new DirectoryList('/root/dir', $config);
     $this->assertFileExists($object->getPath(DirectoryList::SYS_TMP));
     $this->assertEquals('/root/dir/foo', $object->getPath(DirectoryList::APP));
     $this->assertEquals('bar', $object->getUrlPath(DirectoryList::APP));
     $this->setExpectedException('\\Magento\\Framework\\Filesystem\\FilesystemException', "Unknown directory type: 'unknown'");
     $object->getPath('unknown');
 }
Exemplo n.º 2
0
 /**
  * Get a driver instance according the given scheme.
  *
  * @param null|string $protocolCode
  * @param string $driverClass
  * @return DriverInterface
  * @throws FilesystemException
  */
 public function get($protocolCode = null, $driverClass = null)
 {
     if (!$driverClass) {
         $driverClass = $protocolCode ? $this->directoryList->getProtocolConfig($protocolCode)['driver'] : '\\Magento\\Framework\\Filesystem\\Driver\\File';
     }
     if (!isset($this->drivers[$driverClass])) {
         $this->drivers[$driverClass] = new $driverClass();
         if (!$this->drivers[$driverClass] instanceof DriverInterface) {
             throw new FilesystemException("Invalid filesystem driver class: " . $driverClass);
         }
     }
     return $this->drivers[$driverClass];
 }
Exemplo n.º 3
0
 public function testPrependRoot()
 {
     $object = new DirectoryList('/root/dir', [DirectoryList::SYS_TMP => [DirectoryList::PATH => 'tmp']]);
     $this->assertEquals('/root/dir/tmp', $object->getPath(DirectoryList::SYS_TMP));
 }