本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Read类的典型用法代码示例。如果您正苦于以下问题:PHP Read类的具体用法?PHP Read怎么用?PHP Read使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Read类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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']];
// @codingStandardsIgnoreStart
$encodedString = '[{"value_id":"1","file":"image_1.jpg","media_type":"image","url":"http:\\/\\/magento2.dev\\/pub\\/media\\/catalog\\/product\\/image_1.jpg","size":879394},{"value_id":"2","file":"image_2.jpg","media_type":"image","url":"http:\\/\\/magento2.dev\\/pub\\/media\\/catalog\\/product\\/image`_2.jpg","size":399659}]';
// @codingStandardsIgnoreEnd
$images = ['images' => [['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image'], ['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image']]];
$firstStat = ['size' => 879394];
$secondStat = ['size' => 399659];
$this->content->setElement($this->galleryMock);
$this->galleryMock->expects($this->any())->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')->willReturn($mediaPath);
$this->readMock->expects($this->at(0))->method('stat')->willReturn($firstStat);
$this->readMock->expects($this->at(1))->method('stat')->willReturn($secondStat);
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($encodedString);
$this->assertSame($encodedString, $this->content->getImagesJson());
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:20,代码来源:ContentTest.php
示例15: testProcessRequestReturnsFileIfItsProperlySynchronized
public function testProcessRequestReturnsFileIfItsProperlySynchronized()
{
$relativeFilePath = '_files';
$filePath = str_replace('\\', '/', __DIR__ . '/' . $relativeFilePath);
$this->_requestMock->expects($this->any())->method('getPathInfo')->will($this->returnValue($this->_mediaDirectory . '/'));
$this->_sync->expects($this->once())->method('synchronize');
$this->_requestMock->expects($this->any())->method('getFilePath')->will($this->returnValue($filePath));
$this->directoryReadMock->expects($this->once())->method('getRelativePath')->with($filePath)->will($this->returnValue($relativeFilePath));
$this->directoryReadMock->expects($this->once())->method('isReadable')->with($relativeFilePath)->will($this->returnValue(true));
$this->_responseMock->expects($this->once())->method('setFilePath')->with($filePath);
$this->assertSame($this->_responseMock, $this->_model->launch());
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:12,代码来源:MediaTest.php
示例16: testRead
public function testRead()
{
$this->_filesystemDirectoryMock->expects($this->at(1))->method('readFile')->will($this->returnValue(file_get_contents($this->_paths[0])));
$this->_filesystemDirectoryMock->expects($this->at(3))->method('readFile')->will($this->returnValue(file_get_contents($this->_paths[1])));
$this->_moduleDirResolver->expects($this->at(0))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleOne/etc/email_templates_one.xml')->will($this->returnValue('Fixture_ModuleOne'));
$this->_moduleDirResolver->expects($this->at(1))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleTwo/etc/email_templates_two.xml')->will($this->returnValue('Fixture_ModuleTwo'));
$constraint = function (\DOMDocument $actual) {
try {
$expected = file_get_contents(__DIR__ . '/_files/email_templates_merged.xml');
$expectedNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $expected, 1);
$actualNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $actual->saveXML(), 1);
\PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedNorm, $actualNorm);
return true;
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
return false;
}
};
$expectedResult = new \stdClass();
$this->_converter->expects($this->once())->method('convert')->with($this->callback($constraint))->will($this->returnValue($expectedResult));
$this->assertSame($expectedResult, $this->_model->read('scope'));
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:ReaderTest.php
示例17: 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')->willReturnArgument(0);
$this->filesystem = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false);
$this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT, DriverPool::FILE)->willReturn($this->rootDirMock);
$this->templateEngine = $this->getMock('Magento\\Framework\\View\\TemplateEnginePool', ['render', 'get'], [], '', false);
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->templateEngine->expects($this->any())->method('get')->willReturn($this->templateEngine);
$appState = $this->getMock('Magento\\Framework\\App\\State', ['getAreaCode'], [], '', false);
$appState->expects($this->any())->method('getAreaCode')->willReturn('frontend');
$storeManagerMock = $this->getMock(StoreManager::class, [], [], '', false);
$storeMock = $this->getMock(Store::class, [], [], '', false);
$storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);
$storeMock->expects($this->any())->method('getCode')->willReturn('storeCode');
$urlBuilderMock = $this->getMock(UrlInterface::class, [], [], '', false);
$urlBuilderMock->expects($this->any())->method('getBaseUrl')->willReturn('baseUrl');
$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, 'logger' => $this->loggerMock, 'storeManager' => $storeManagerMock, 'urlBuilder' => $urlBuilderMock, 'data' => ['template' => 'template.phtml', 'module_name' => 'Fixture_Module']]);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:TemplateTest.php
示例18: testReadFileCustomProtocol
public function testReadFileCustomProtocol()
{
$path = 'filepath';
$flag = 'flag';
$context = 'context';
$protocol = 'ftp';
$contents = 'contents';
$fileMock = $this->getMock('Magento\\Framework\\Filesystem\\File\\Read', [], [], '', false);
$fileMock->expects($this->once())->method('readAll')->with($flag, $context)->will($this->returnValue($contents));
$this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path, $protocol)->will($this->returnValue($path));
$this->driver->expects($this->never())->method('fileGetContents');
$this->fileFactory->expects($this->once())->method('create')->with($path, $protocol, $this->driver)->will($this->returnValue($fileMock));
$this->assertEquals($contents, $this->read->readFile($path, $flag, $context, $protocol));
}
开发者ID:,项目名称:,代码行数:14,代码来源:
示例19: 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
示例20: 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;未经允许,请勿转载。 |
请发表评论