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


PHP Repository::expects方法代码示例

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


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

示例1: testConvertModuleNotationToPathModularSeparator

 /**
  * @param string $assetRelPath
  * @param string $relatedFieldId
  * @param string $similarRelPath
  * @param string $expectedResult
  * @dataProvider convertModuleNotationToPathModularSeparatorDataProvider
  */
 public function testConvertModuleNotationToPathModularSeparator($assetRelPath, $relatedFieldId, $similarRelPath, $expectedResult)
 {
     $similarAsset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $similarAsset->expects($this->any())->method('getPath')->will($this->returnValue($similarRelPath));
     $this->asset->expects($this->once())->method('getPath')->will($this->returnValue($assetRelPath));
     $this->assetRepo->expects($this->once())->method('createSimilar')->with($relatedFieldId, $this->asset)->will($this->returnValue($similarAsset));
     $this->assertEquals($expectedResult, $this->object->convertModuleNotationToPath($this->asset, $relatedFieldId));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ModuleTest.php

示例2: testGetViewFileUrl

 /**
  * @param bool $isSecure
  * @dataProvider getViewFileUrlDataProvider
  */
 public function testGetViewFileUrl($isSecure)
 {
     $this->request->expects($this->once())->method('isSecure')->will($this->returnValue($isSecure));
     $this->assetRepo->expects($this->once())->method('getUrlWithParams')->with('some file', $this->callback(function ($value) use($isSecure) {
         return isset($value['_secure']) && $value['_secure'] === $isSecure;
     }))->will($this->returnValue('result url'));
     $this->assertEquals('result url', $this->model->getViewFileUrl('some file'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:ReviewTest.php

示例3: testGetTranslationFilePath

 public function testGetTranslationFilePath()
 {
     $path = 'path';
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
     $this->assertEquals($path, $this->model->getTranslationFilePath());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:8,代码来源:FileManagerTest.php

示例4: setUp

 protected function setUp()
 {
     $baseUrl = 'http://example.com/pub/static/';
     $path = 'frontend/Magento/blank/en_US';
     $this->context = $this->getMock('\\Magento\\Framework\\View\\Asset\\File\\Context', null, [$baseUrl, DirectoryList::STATIC_VIEW, $path]);
     $this->assetRepo = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false);
     $this->assetRepo->expects($this->any())->method('getStaticViewFileContext')->will($this->returnValue($this->context));
     $this->object = new \Magento\Framework\View\Asset\NotationResolver\Variable($this->assetRepo);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:VariableTest.php

示例5: testCreateTranslateConfigAsset

 public function testCreateTranslateConfigAsset()
 {
     $path = 'relative path';
     $expectedPath = $path . '/' . FileManager::TRANSLATION_CONFIG_FILE_NAME;
     $fileMock = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->once())->method('getPath')->willReturn($path);
     $this->assetRepoMock->expects($this->once())->method('createArbitrary')->with($expectedPath, '')->willReturn($fileMock);
     $this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:FileManagerTest.php

示例6: testCreateRequireJsAssetDevMode

 public function testCreateRequireJsAssetDevMode()
 {
     $this->config->expects($this->once())->method('getConfigFileRelativePath')->will($this->returnValue('requirejs/file.js'));
     $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir));
     $this->assetRepo->expects($this->once())->method('createArbitrary')->with('requirejs/file.js', '')->will($this->returnValue($this->asset));
     $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
     $this->dir->expects($this->never())->method('isExist');
     $data = 'requirejs config data';
     $this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data));
     $this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data);
     $this->assertSame($this->asset, $this->object->createRequireJsConfigAsset());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:FileManagerTest.php

示例7: getViewFileUrlWithException

 public function getViewFileUrlWithException()
 {
     $params = ['a' => 'b'];
     $paramsSecure = ['a' => 'b', '_secure' => false];
     $fileId = 'file id';
     $fileUrl = 'exception url';
     $this->requestMock->expects($this->once())->method('isSecure')->willReturn(false);
     $exception = new LocalizedException('message');
     $this->repositoryMock->expects($this->once())->method('getUrlWithParams')->with($fileId, $paramsSecure)->willThrowException($exception);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception);
     $this->urlMock->expects($this->once())->method('getUrl')->with('', ['_direct' => 'core/index/notFound'])->willReturn($fileUrl);
     $this->assertEquals($fileUrl, $this->model->getViewFileUrl($fileId, $params));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:CcConfigTest.php

示例8: testExecute

 /**
  * Run test for execute method
  */
 public function testExecute()
 {
     /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
     $assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
     $this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
     $message = sprintf('<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', self::AREA_TEST_VALUE, self::LOCALE_TEST_VALUE, self::THEME_TEST_VALUE, self::TYPE_TEST_VALUE);
     $outputMock->expects(self::at(0))->method('writeln')->with($message);
     $outputMock->expects(self::at(1))->method('writeln')->with('<comment>-> file-test-value/test/file</comment>');
     $outputMock->expects(self::at(2))->method('writeln')->with('<info>Successfully processed.</info>');
     $this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_TEST_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
     $this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock);
     $assetMock->expects(self::once())->method('getFilePath')->willReturn(self::FILE_TEST_VALUE);
     $this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:SourceThemeDeployCommandTest.php

示例9: testExecute

 public function testExecute()
 {
     $file = 'css/styles-m' . '.less';
     $this->configLoader->expects($this->once())->method('load')->with('frontend')->willReturn([]);
     $this->objectManager->expects($this->once())->method('configure');
     $this->sourceFileGeneratorPool->expects($this->once())->method('create')->with('less')->willReturn($this->getMock('Magento\\Framework\\Less\\FileGenerator', [], [], '', false));
     $this->assetRepo->expects($this->once())->method('createAsset')->with($file, ['area' => 'frontend', 'theme' => 'Magento/blank', 'locale' => 'en_US'])->willReturn($this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\LocalInterface'));
     $this->assetSource->expects($this->once())->method('findSource')->willReturn('/dev/null');
     $this->chainFactory->expects($this->once())->method('create')->willReturn($this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false));
     $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], [], '', false));
     $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);
     $commandTester = new CommandTester($this->command);
     $commandTester->execute(['type' => 'less']);
     $this->assertContains('Successfully processed LESS and/or SASS files', $commandTester->getDisplay());
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:CssDeployCommandTest.php

示例10: testCreateMinResolverAsset

 public function testCreateMinResolverAsset()
 {
     $this->configMock->expects($this->any())->method('getMinResolverRelativePath')->willReturn('relative path');
     $this->assetRepoMock->expects($this->once())->method('createArbitrary')->with('relative path');
     $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir));
     $this->object->createMinResolverAsset();
 }
开发者ID:Coplex,项目名称:magento2,代码行数:7,代码来源:FileManagerTest.php

示例11: testClearBundleJsPool

 public function testClearBundleJsPool()
 {
     $context = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContext')->disableOriginalConstructor()->getMock();
     $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->willReturn($this->dir);
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($context);
     $context->expects($this->once())->method('getPath')->willReturn('/path/to/directory');
     $this->dir->expects($this->once())->method('delete')->with('/path/to/directory/' . \Magento\Framework\RequireJs\Config::BUNDLE_JS_DIR)->willReturn(true);
     $this->assertTrue($this->object->clearBundleJsPool());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:FileManagerTest.php

示例12: testProcessException

 public function testProcessException()
 {
     $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, '//@magento_import "some/file.css";', 'css');
     $exception = new \LogicException('Error happened');
     $this->assetRepo->expects($this->once())->method('createRelated')->will($this->throwException($exception));
     $this->errorHandler->expects($this->once())->method('processException')->with($exception);
     $this->object->process($chain);
     $this->assertEquals('', $chain->getContent());
     $this->assertEquals('css', $chain->getContentType());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:MagentoImportTest.php

示例13: testGetSkinImagePlaceholderPath

 /**
  * @covers \Magento\Cms\Model\Wysiwyg\Config::getSkinImagePlaceholderPath
  */
 public function testGetSkinImagePlaceholderPath()
 {
     $staticPath = 'pub/static';
     $placeholderPath = 'adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
     $expectedResult = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getBaseStaticDir')->willReturn($staticPath);
     $this->assetRepoMock->expects($this->any())->method('createAsset')->with(\Magento\Cms\Model\Wysiwyg\Config::WYSIWYG_SKIN_IMAGE_PLACEHOLDER_ID)->willReturn($this->assetFileMock);
     $this->assetFileMock->expects($this->once())->method('getPath')->willReturn($placeholderPath);
     $this->assertEquals($expectedResult, $this->wysiwygConfig->getSkinImagePlaceholderPath());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:ConfigTest.php

示例14: testExecuteNonExistingValue

 /**
  * Run test for execute method with non existing theme
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Verify entered values of the argument and options.
  */
 public function testExecuteNonExistingValue()
 {
     /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
     $assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
     $this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
     $this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_NONEXISTING_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
     $this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock)->willThrowException(new \Magento\Framework\View\Asset\File\NotFoundException());
     $valueMap = [['area', self::AREA_TEST_VALUE], ['locale', self::LOCALE_TEST_VALUE], ['theme', self::THEME_NONEXISTING_VALUE], ['type', self::TYPE_TEST_VALUE]];
     $this->sourceThemeDeployCommand->run($this->getInputMock($valueMap), $outputMock);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:17,代码来源:SourceThemeDeployCommandTest.php

示例15: testGetViewConfig

 public function testGetViewConfig()
 {
     $themeMock = $this->getMock('Magento\\Theme\\Model\\Theme', ['getId', 'getCustomization', 'getCustomViewConfigPath'], [], '', false);
     $themeMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2));
     $themeMock->expects($this->once())->method('getCustomization')->will($this->returnSelf());
     $themeMock->expects($this->once())->method('getCustomViewConfigPath')->will($this->returnValue(''));
     $params = ['themeModel' => $themeMock];
     $configFile = 'config.xml';
     $this->repositoryMock->expects($this->atLeastOnce())->method('updateDesignParams')->with($this->equalTo($params))->will($this->returnSelf());
     $iterator = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false);
     $iterator->expects($this->once())->method('toArray')->will($this->returnValue([]));
     $this->readerMock->expects($this->once())->method('getConfigurationFiles')->with($this->equalTo(basename(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME)))->will($this->returnValue($iterator));
     $this->directoryReadMock->expects($this->once())->method('isExist')->with($this->anything())->will($this->returnValue(true));
     $this->fileSystemMock->expects($this->once())->method('getFilename')->with($this->equalTo(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME), $params)->will($this->returnValue($configFile));
     $this->directoryReadMock->expects($this->any())->method('getRelativePath')->with($this->equalTo($configFile))->will($this->returnArgument(0));
     $xmlData = '<view><vars module="Magento_Catalog"><var name="test">1</var></vars></view>';
     $this->directoryReadMock->expects($this->once())->method('readFile')->with($this->equalTo($configFile))->will($this->returnValue($xmlData));
     $this->assertInstanceOf('Magento\\Framework\\Config\\View', $this->config->getViewConfig($params));
     // lazy load test
     $this->assertInstanceOf('Magento\\Framework\\Config\\View', $this->config->getViewConfig($params));
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:21,代码来源:ConfigTest.php


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