当前位置: 首页>>代码示例>>PHP>>正文


PHP Directory\Read类代码示例

本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Read的典型用法代码示例。如果您正苦于以下问题:PHP Read类的具体用法?PHP Read怎么用?PHP Read使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Read类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetPackageNameInvalidJson

 /**
  * @expectedException \Zend_Json_Exception
  */
 public function testGetPackageNameInvalidJson()
 {
     $this->componentRegistrar->expects($this->once())->method('getPath')->willReturn('path/to/A');
     $this->dirRead->expects($this->once())->method('isExist')->willReturn(true);
     $this->dirRead->expects($this->once())->method('readFile')->willReturn('{"name": }');
     $this->themePackageInfo->getPackageName('themeA');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:ThemePackageInfoTest.php

示例2: testReadValidConfig

 /**
  * @covers \Magento\Framework\App\Config\Initial\Reader::read
  */
 public function testReadValidConfig()
 {
     $testXmlFilesList = array(file_get_contents($this->_filePath . 'initial_config1.xml'), file_get_contents($this->_filePath . 'initial_config2.xml'));
     $expectedConfig = array('data' => array(), 'metadata' => array());
     $this->_fileResolverMock->expects($this->at(0))->method('get')->with('config.xml', 'global')->will($this->returnValue($testXmlFilesList));
     $this->_converterMock->expects($this->once())->method('convert')->with($this->anything())->will($this->returnValue($expectedConfig));
     $this->rootDirectory->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->rootDirectory->expects($this->any())->method('readFile')->will($this->returnValue('<config></config>'));
     $this->assertEquals($expectedConfig, $this->_model->read());
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: testReadFile

 public function testReadFile()
 {
     $path = 'filepath';
     $flag = 'flag';
     $context = 'context';
     $contents = 'contents';
     $this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path)->will($this->returnValue($path));
     $this->driver->expects($this->once())->method('fileGetContents')->with($path, $flag, $context)->will($this->returnValue($contents));
     $this->assertEquals($contents, $this->read->readFile($path, $flag, $context));
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例4: testGetStorageData

 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(\Magento\Framework\App\Filesystem::MEDIA_DIR))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap(array(array('/', true), array('folder_one', true), array('file_three.txt', false), array('folder_one/.svn', false), array('folder_one/file_one.txt', false), array('folder_one/folder_two', true), array('folder_one/folder_two/.htaccess', false), array('folder_one/folder_two/file_two.txt', false))));
     $paths = array('folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt');
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = array('files' => array('file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'), 'directories' => array(array('name' => 'folder_one', 'path' => '/'), array('name' => 'folder_two', 'path' => 'folder_one')));
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例5: testGetStorageData

 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(DirectoryList::MEDIA))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap([['/', true], ['folder_one', true], ['file_three.txt', false], ['folder_one/.svn', false], ['folder_one/file_one.txt', false], ['folder_one/folder_two', true], ['folder_one/folder_two/.htaccess', false], ['folder_one/folder_two/file_two.txt', false]]));
     $paths = ['folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt'];
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = ['files' => ['file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'], 'directories' => [['name' => 'folder_one', 'path' => '/'], ['name' => 'folder_two', 'path' => 'folder_one']]];
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:FileTest.php

示例6: __construct

 /**
  * Open file and detect column names
  *
  * There must be column names in the first line
  *
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Read $directory
  * @param string $delimiter
  * @param string $enclosure
  * @throws \LogicException
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Read $directory, $delimiter = ',', $enclosure = '"')
 {
     register_shutdown_function([$this, 'destruct']);
     try {
         $this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
     } catch (\Magento\Framework\Exception\FileSystemException $e) {
         throw new \LogicException("Unable to open file: '{$file}'");
     }
     if ($delimiter) {
         $this->_delimiter = $delimiter;
     }
     $this->_enclosure = $enclosure;
     parent::__construct($this->_getNextRow());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:Csv.php

示例7: setUp

 protected function setUp()
 {
     $this->_resolver = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Resolver', [], [], '', false);
     $this->_validator = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Validator', [], [], '', false);
     $this->rootDirMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
     $this->rootDirMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->_filesystem = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false);
     $this->_filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT, DriverPool::FILE)->will($this->returnValue($this->rootDirMock));
     $this->_templateEngine = $this->getMock('Magento\\Framework\\View\\TemplateEnginePool', ['render', 'get'], [], '', false);
     $this->_templateEngine->expects($this->any())->method('get')->will($this->returnValue($this->_templateEngine));
     $appState = $this->getMock('Magento\\Framework\\App\\State', ['getAreaCode'], [], '', false);
     $appState->expects($this->any())->method('getAreaCode')->will($this->returnValue('frontend'));
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_block = $helper->getObject('Magento\\Framework\\View\\Element\\Template', ['filesystem' => $this->_filesystem, 'enginePool' => $this->_templateEngine, 'resolver' => $this->_resolver, 'validator' => $this->_validator, 'appState' => $appState, 'data' => ['template' => 'template.phtml', 'module_name' => 'Fixture_Module']]);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:TemplateTest.php

示例8: testGetRequiredExceptionMissingPackages

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Missing key 'packages' in 'composer.lock' file
  */
 public function testGetRequiredExceptionMissingPackages()
 {
     $this->directoryReadMock->expects($this->once())->method('isExist')->will($this->returnValue(true));
     $this->directoryReadMock->expects($this->once())->method('readFile')->with('composer.lock')->will($this->returnValue('{"platform-dev":{"ext-e":"*", "f":"*"}}'));
     $phpInfo = new PhpInformation($this->filesystemMock);
     $phpInfo->getRequired();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:PhpInformationTest.php

示例9: testGetImagesJson

 public function testGetImagesJson()
 {
     $url = [['file_1.jpg', 'url_to_the_image/image_1.jpg'], ['file_2.jpg', 'url_to_the_image/image_2.jpg']];
     $mediaPath = [['file_1.jpg', 'catalog/product/image_1.jpg'], ['file_2.jpg', 'catalog/product/image_2.jpg']];
     $sizeMap = [['catalog/product/image_1.jpg', ['size' => 399659]], ['catalog/product/image_2.jpg', ['size' => 879394]]];
     $imagesResult = [['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image', 'position' => '0', 'url' => 'url_to_the_image/image_2.jpg', 'size' => 879394], ['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image', 'position' => '1', 'url' => 'url_to_the_image/image_1.jpg', 'size' => 399659]];
     $images = ['images' => [['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image', 'position' => '1'], ['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image', 'position' => '0']]];
     $this->content->setElement($this->galleryMock);
     $this->galleryMock->expects($this->once())->method('getImages')->willReturn($images);
     $this->fileSystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($this->readMock);
     $this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url);
     $this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturnMap($mediaPath);
     $this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap);
     $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
     $this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:ContentTest.php

示例10: launch

 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  * @throws \LogicException
  */
 public function launch()
 {
     if (!$this->_mediaDirectory) {
         $config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', ['cacheFile' => $this->_configCacheFile]);
         $config->save();
         $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
         $allowedResources = $config->getAllowedResources();
         $this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
         $isAllowed = $this->_isAllowed;
         if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
             throw new \LogicException('The specified path is not allowed.');
         }
     }
     if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
         throw new \LogicException('The specified path is not within media directory.');
     }
     $sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
     $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
     if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
         $this->_response->setFilePath($this->_request->getFilePath());
     } else {
         $this->_response->setHttpResponseCode(404);
     }
     return $this->_response;
 }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例11: testCheckUpdater

 public function testCheckUpdater()
 {
     $json = [ReadinessCheck::KEY_READINESS_CHECKS => [CronScriptReadinessCheck::UPDATER_KEY_FILE_PERMISSIONS_VERIFIED => true], ReadinessCheck::KEY_CURRENT_TIMESTAMP => 200, ReadinessCheck::KEY_LAST_TIMESTAMP => 140];
     $this->read->expects($this->once())->method('readFile')->willReturn(json_encode($json));
     $expected = ['success' => true];
     $this->assertEquals($expected, $this->cronScriptReadinessCheck->checkUpdater());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:CronScriptReadinessCheckTest.php

示例12: getCustomViewConfigPath

 /**
  * Get path to custom view configuration file
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string|null
  */
 public function getCustomViewConfigPath(\Magento\Framework\View\Design\ThemeInterface $theme)
 {
     $path = null;
     if ($theme->getId()) {
         $path = $this->mediaDirectoryRead->getAbsolutePath(self::DIR_NAME . '/' . $theme->getId() . '/' . $this->filename);
     }
     return $path;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Path.php

示例13: testProcessRequestReturnsNotFoundIfFileIsNotSynchronized

 public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized()
 {
     $this->sync->expects($this->once())->method('synchronize')->with(self::RELATIVE_FILE_PATH);
     $this->directoryMock->expects($this->once())->method('getAbsolutePath')->with()->will($this->returnValue(self::MEDIA_DIRECTORY));
     $this->directoryMock->expects($this->once())->method('isReadable')->with(self::RELATIVE_FILE_PATH)->will($this->returnValue(false));
     $this->responseMock->expects($this->once())->method('setHttpResponseCode')->with(404);
     $this->assertSame($this->responseMock, $this->model->launch());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:MediaTest.php

示例14: minifyFile

 /**
  * Get path to minified file for specified original file
  *
  * @param string $originalFile path to original file relative to pub/view_cache
  * @param string $targetFile path relative to pub/view_cache
  * @return void
  */
 public function minifyFile($originalFile, $targetFile)
 {
     if ($this->_isUpdateNeeded($targetFile)) {
         $content = $this->rootDirectory->readFile($originalFile);
         $content = $this->adapter->minify($content);
         $this->pubViewCacheDir->writeFile($targetFile, $content);
     }
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:15,代码来源:Lite.php

示例15: testSetTemplateContext

 public function testSetTemplateContext()
 {
     $template = 'themedir/template.phtml';
     $this->rootDirMock->expects($this->once())->method('isFile')->with($template)->will($this->returnValue(true));
     $context = new \Magento\Framework\Object();
     $this->_templateEngine->expects($this->once())->method('render')->with($context);
     $this->_block->setTemplateContext($context);
     $this->_block->fetchView($template);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:TemplateTest.php


注:本文中的Magento\Framework\Filesystem\Directory\Read类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。