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


PHP State::expects方法代码示例

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


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

示例1: configureAdminArea

 protected function configureAdminArea()
 {
     $config = ['test config'];
     $this->configLoaderMock->expects($this->once())->method('load')->with(FrontNameResolver::AREA_CODE)->will($this->returnValue($config));
     $this->objectManager->expects($this->once())->method('configure')->with($config);
     $this->stateMock->expects($this->once())->method('setAreaCode')->with(FrontNameResolver::AREA_CODE);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:AbstractIndexerCommandCommonSetup.php

示例2: testWidgetDirective

 /**
  * @return void
  */
 public function testWidgetDirective()
 {
     $result = 'some text';
     $construction = ['{{widget type="Widget\\Link" anchor_text="Test" template="block.phtml" id_path="p/1"}}', 'widget', ' type="" anchor_text="Test" template="block.phtml" id_path="p/1"'];
     $this->appStateMock->expects($this->once())->method('emulateAreaCode')->with('frontend', [$this->filterEmulate, 'generateWidget'], [$construction])->willReturn($result);
     $this->assertSame($result, $this->filterEmulate->widgetDirective($construction));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:FilterEmulateTest.php

示例3: testNotUnlockProcessInProductionMode

 public function testNotUnlockProcessInProductionMode()
 {
     $this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
     $this->filesystemMock->expects(self::never())->method('getDirectoryWrite');
     $this->lockerProcess->lockProcess(self::LOCK_NAME);
     $this->lockerProcess->unlockProcess();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:LockerProcessTest.php

示例4: testAroundDispatchDisabled

 /**
  * @dataProvider dataProvider
  */
 public function testAroundDispatchDisabled($state)
 {
     $this->configMock->expects($this->any())->method('getType')->will($this->returnValue(null));
     $this->versionMock->expects($this->never())->method('process');
     $this->stateMock->expects($this->any())->method('getMode')->will($this->returnValue($state));
     $this->responseMock->expects($this->never())->method('setHeader');
     $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:VarnishPluginTest.php

示例5: setUp

 protected function setUp()
 {
     $this->requestMock = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getBasePath', 'isSecure', 'getHttpHost'], [], '', false, false);
     $this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
     $this->requestMock->expects($this->atLeastOnce())->method('getHttpHost')->will($this->returnValue('init.host'));
     $this->appState = $this->getMock('\\Magento\\Framework\\App\\State', ['isInstalled'], [], '', false, false);
     $this->appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true));
 }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例6: testBeforeExecuteWithProductionMode

 public function testBeforeExecuteWithProductionMode()
 {
     $this->appState->expects($this->once())->method('getMode')->willReturn('production');
     $this->themeRegistration->expects($this->never())->method('register');
     $this->logger->expects($this->never())->method('critical');
     $object = new Registration($this->themeRegistration, $this->logger, $this->appState);
     $object->beforeExecute($this->abstractAction, $this->request);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:8,代码来源:RegistrationTest.php

示例7: testPublish

 public function testPublish()
 {
     $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_PRODUCTION));
     $this->staticDirRead->expects($this->once())->method('isExist')->with('some/file.ext')->will($this->returnValue(false));
     $this->rootDirWrite->expects($this->once())->method('getRelativePath')->with('/root/some/file.ext')->will($this->returnValue('some/file.ext'));
     $this->rootDirWrite->expects($this->once())->method('copyFile')->with('some/file.ext', 'some/file.ext', $this->staticDirWrite)->will($this->returnValue(true));
     $this->assertTrue($this->object->publish($this->getAsset()));
 }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: testReorderChildElementLog

 /**
  * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $loggerExpects
  * @param string $stateMode
  * @return void
  * @dataProvider reorderChildElementLogDataProvider
  */
 public function testReorderChildElementLog($loggerExpects, $stateMode)
 {
     $parentName = 'parent';
     $childName = 'child';
     $offsetOrSibling = '-';
     $this->stateMock->expects($this->once())->method('getMode')->willReturn($stateMode);
     $this->loggerMock->expects($loggerExpects)->method('critical')->with("Broken reference: the '{$childName}' tries to reorder itself towards '', but " . "their parents are different: '{$parentName}' and '' respectively.");
     $this->dataStructure->reorderChildElement($parentName, $childName, $offsetOrSibling);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:StructureTest.php

示例9: testCreateRequireJsAssetDevMode

 public function testCreateRequireJsAssetDevMode()
 {
     $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->createRequireJsAsset());
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: testLoad

 public function testLoad()
 {
     $area = $this->getMock('Magento\\Framework\\App\\Area', [], [], '', false);
     $this->appState->expects($this->once())->method('getAreaCode')->will($this->returnValue('area'));
     $this->_areaListMock->expects($this->once())->method('getArea')->with('area')->will($this->returnValue($area));
     $area->expects($this->at(0))->method('load')->with(\Magento\Framework\App\Area::PART_DESIGN)->will($this->returnValue($area));
     $area->expects($this->at(1))->method('load')->with(\Magento\Framework\App\Area::PART_TRANSLATE)->will($this->returnValue($area));
     $this->_model->load($this->_requestMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:DesignLoaderTest.php

示例11: testGetFileIfMinificationIsDisabled

 public function testGetFileIfMinificationIsDisabled()
 {
     $this->assetConfig->expects($this->once())->method('isMinifyHtml')->willReturn(false);
     $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $expected = 'some/file.ext';
     $this->resolver->expects($this->once())->method('resolve')->with(RulePool::TYPE_TEMPLATE_FILE, 'file.ext', 'frontend', $theme, null, 'Magento_Module')->will($this->returnValue($expected));
     $this->state->expects($this->never())->method('getMode');
     $actual = $this->object->getFile('frontend', $theme, 'file.ext', 'Magento_Module');
     $this->assertSame($expected, $actual);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:TemplateFileTest.php

示例12: testToHtmlWithSubscriber

 public function testToHtmlWithSubscriber()
 {
     $this->request->expects($this->any())->method('getParam')->willReturnMap([['id', null, 2], ['store', null, 1], ['subscriber', null, 3]]);
     $subscriber = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriber->expects($this->atLeastOnce())->method('load')->with(3)->willReturnSelf();
     $this->subscriberFactory->expects($this->atLeastOnce())->method('create')->willReturn($subscriber);
     $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1);
     $this->template->expects($this->atLeastOnce())->method('revertDesign');
     $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode')->with(\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, [$this->template, 'getProcessedTemplate'], [['subscriber' => $subscriber]])->willReturn('Processed Template');
     $this->assertEquals('Processed Template', $this->preview->toHtml());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:PreviewTest.php

示例13: testGetByAreaWithOtherAreaAndNumericThemeId

 public function testGetByAreaWithOtherAreaAndNumericThemeId()
 {
     $this->designMock->expects($this->once())->method('getDesignTheme')->will($this->returnValue($this->themeMock));
     $this->designMock->expects($this->once())->method('getArea')->will($this->returnValue('design_area'));
     $this->designMock->expects($this->once())->method('getConfigurationDesignTheme')->will($this->returnValue(12));
     $this->themeMock->expects($this->once())->method('getArea')->will($this->returnValue('theme_area'));
     $this->themeCollectionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->themeCollectionMock));
     $this->themeCollectionMock->expects($this->once())->method('getItemById')->with(12)->will($this->returnValue($this->themeMock));
     $this->appStateMock->expects($this->once())->method('getAreaCode')->will($this->returnValue('other_area'));
     $this->assertEquals($this->themeMock, $this->model->get());
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例14: testAroundResultWithPluginDeveloperMode

 public function testAroundResultWithPluginDeveloperMode()
 {
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->willReturn(true);
     $this->state->expects($this->once())->method('getMode')->willReturn(\Magento\Framework\App\State::MODE_DEVELOPER);
     $this->header->expects($this->any())->method('getFieldValue')->willReturnOnConsecutiveCalls('test', 'tag,tag2');
     $this->response->expects($this->any())->method('setHeader')->withConsecutive(['X-Magento-Cache-Control', 'test'], ['X-Magento-Cache-Debug', 'MISS', true], ['X-Magento-Tags', 'tag,tag2,' . \Magento\PageCache\Model\Cache\Type::CACHE_TAG]);
     $this->response->expects($this->once())->method('clearHeader')->with('X-Magento-Tags');
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->will($this->returnValue(true));
     $this->kernel->expects($this->once())->method('process')->with($this->response);
     $result = call_user_func($this->closure);
     $this->assertSame($result, $this->plugin->aroundRenderResult($this->subject, $this->closure, $this->response));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:BuiltinPluginTest.php

示例15: testLaunchDispatchesCronEvent

 public function testLaunchDispatchesCronEvent()
 {
     $configLoader = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
     $eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface', $configLoader], ['Magento\\Framework\\Event\\ManagerInterface', $eventManagerMock]]));
     $crontabConfig = ['config'];
     $configLoader->expects($this->once())->method('load')->with(Area::AREA_CRONTAB)->willReturn($crontabConfig);
     $this->objectManager->expects($this->once())->method('configure')->with($crontabConfig);
     $this->_stateMock->expects($this->once())->method('setAreaCode')->with(Area::AREA_CRONTAB);
     $eventManagerMock->expects($this->once())->method('dispatch')->with('default');
     $this->_responseMock->expects($this->once())->method('setCode')->with(0);
     $this->assertEquals($this->_responseMock, $this->_model->launch());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:CronTest.php


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