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


PHP Read::expects方法代码示例

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


在下文中一共展示了Read::expects方法的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: 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

示例3: 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,代码来源:

示例4: 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

示例5: 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,代码来源:

示例6: testResolve

 public function testResolve()
 {
     $requestedFile = 'file.css';
     $expected = 'some/dir/file.less';
     $theme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->any())->method('getFullPath')->will($this->returnValue('magento_theme'));
     $this->rule->expects($this->atLeastOnce())->method('getPatternDirs')->will($this->returnValue(['some/dir']));
     $fileExistsMap = [['file.css', false], ['file.less', true]];
     $this->directory->expects($this->any())->method('isExist')->will($this->returnValueMap($fileExistsMap));
     $actual = $this->object->resolve('type', $requestedFile, 'frontend', $theme, 'en_US', 'Magento_Module');
     $this->assertSame($expected, $actual);
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:12,代码来源:AlternativeTest.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: testResolveNonexistentFile

 public function testResolveNonexistentFile()
 {
     $this->readFactoryMock->expects($this->any())->method('create')->willReturn($this->directoryMock);
     $this->ruleMock->expects($this->once())->method('getPatternDirs')->willReturn(['some/dir']);
     $this->directoryMock->expects($this->once())->method('isExist')->willReturn(false);
     $this->assertFalse($this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module'));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:SimpleTest.php

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: testResolveFromCache

 public function testResolveFromCache()
 {
     $expectedPath = '/some/dir/file.ext';
     $this->cache->expects($this->once())->method('getFromCache')->with('type', 'file.ext', 'frontend', 'magento_theme', 'en_US', 'Magento_Module')->will($this->returnValue($expectedPath));
     $this->directory->expects($this->once())->method('getAbsolutePath')->with($expectedPath)->will($this->returnValue($expectedPath));
     $this->rule->expects($this->never())->method('getPatternDirs');
     $this->cache->expects($this->never())->method('saveToCache');
     $actualPath = $this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module');
     $this->assertSame($expectedPath, $actualPath);
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例14: testUploadJsFile

 public function testUploadJsFile()
 {
     $fileName = 'file.name';
     $this->_fileSizeMock->expects($this->once())->method('getMaxFileSize')->will($this->returnValue(600 * self::MB_MULTIPLIER));
     $this->_service = new \Magento\Theme\Model\Uploader\Service($this->_filesystemMock, $this->_fileSizeMock, $this->_uploaderFactory, ['js' => '500M']);
     $this->_directoryMock->expects($this->once())->method('getRelativePath')->with($fileName)->will($this->returnValue($fileName));
     $this->_directoryMock->expects($this->once())->method('readFile')->with($fileName)->will($this->returnValue('content'));
     $this->_uploader->expects($this->once())->method('validateFile')->will($this->returnValue(['name' => $fileName, 'tmp_name' => $fileName]));
     $this->_uploader->expects($this->once())->method('getFileSize')->will($this->returnValue('499'));
     $this->assertEquals(['content' => 'content', 'filename' => $fileName], $this->_service->uploadJsFile($fileName));
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例15: 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


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