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


PHP Registry::expects方法代码示例

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


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

示例1: testAddFieldsToResponseSuccess

 /**
  * Test for addFieldsToResponse method
  *
  * @return void
  */
 public function testAddFieldsToResponseSuccess()
 {
     $testData = $this->getAddFieldsToResponseSuccessTestData();
     $observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $orderPaymentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $instanceMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost')->disableOriginalConstructor()->getMock();
     $requestToAuthorizenetMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Request')->disableOriginalConstructor()->setMethods(['setControllerActionName', 'setIsSecure', 'getData'])->getMock();
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getControllerName'])->getMockForAbstractClass();
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->coreRegistryMock->expects($this->once())->method('registry')->with('directpost_order')->willReturn($orderMock);
     $orderMock->expects($this->once())->method('getId')->willReturn($testData['order.getId']);
     $orderMock->expects($this->once())->method('getPayment')->willReturn($orderPaymentMock);
     $orderPaymentMock->expects($this->once())->method('getMethod')->willReturn($testData['orderPayment.getMethod']);
     $this->paymentMock->expects($this->exactly(2))->method('getCode')->willReturn($testData['payment.getCode']);
     $observerMock->expects($this->atLeastOnce())->method('getData')->willReturnMap($testData['observer.getData']);
     $this->resultMock->expects($this->once())->method('getData')->willReturn($testData['result.getData']);
     $orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($testData['order.getIncrementId']);
     $this->sessionMock->expects($this->once())->method('addCheckoutOrderIncrementId')->with($testData['session.addCheckoutOrderIncrementId']);
     $this->sessionMock->expects($this->once())->method('setLastOrderIncrementId')->with($testData['session.setLastOrderIncrementId']);
     $orderPaymentMock->expects($this->once())->method('getMethodInstance')->willReturn($instanceMock);
     $instanceMock->expects($this->once())->method('generateRequestFromOrder')->with($orderMock)->willReturn($requestToAuthorizenetMock);
     $this->actionMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $requestMock->expects($this->once())->method('getControllerName')->willReturn($testData['request.getControllerName']);
     $requestToAuthorizenetMock->expects($this->once())->method('setControllerActionName')->with($testData['requestToAuthorizenet.setControllerActionName']);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('isCurrentlySecure')->willReturn($testData['store.isCurrentlySecure']);
     $requestToAuthorizenetMock->expects($this->once())->method('setIsSecure')->with($testData['requestToAuthorizenet.setIsSecure']);
     $requestToAuthorizenetMock->expects($this->once())->method('getData')->willReturn($testData['requestToAuthorizenet.getData']);
     $this->resultMock->expects($this->once())->method('setData')->with($testData['result.setData']);
     $this->addFieldsToResponseObserver->execute($observerMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:37,代码来源:AddFieldsToResponseObserverTest.php

示例2: testCanReturnItemsToStock

 /**
  * @param bool $canReturnToStock
  * @param bool $manageStock
  * @param bool $result
  * @dataProvider canReturnItemsToStockDataProvider
  */
 public function testCanReturnItemsToStock($canReturnToStock, $manageStock, $result)
 {
     $productId = 7;
     $property = new \ReflectionProperty($this->items, '_canReturnToStock');
     $property->setAccessible(true);
     $this->assertNull($property->getValue($this->items));
     $this->stockConfiguration->expects($this->once())->method('canSubtractQty')->will($this->returnValue($canReturnToStock));
     if ($canReturnToStock) {
         $orderItem = $this->getMock('Magento\\Sales\\Model\\Order\\Item', ['getProductId', '__wakeup', 'getStore'], [], '', false);
         $store = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false);
         $store->expects($this->once())->method('getWebsiteId')->will($this->returnValue(10));
         $orderItem->expects($this->any())->method('getStore')->will($this->returnValue($store));
         $orderItem->expects($this->once())->method('getProductId')->will($this->returnValue($productId));
         $creditMemoItem = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo\\Item', ['setCanReturnToStock', 'getOrderItem', '__wakeup'], [], '', false);
         $creditMemo = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', [], [], '', false);
         $creditMemo->expects($this->once())->method('getAllItems')->will($this->returnValue([$creditMemoItem]));
         $creditMemoItem->expects($this->any())->method('getOrderItem')->will($this->returnValue($orderItem));
         $this->stockItemMock->expects($this->once())->method('getManageStock')->will($this->returnValue($manageStock));
         $creditMemoItem->expects($this->once())->method('setCanReturnToStock')->with($this->equalTo($manageStock))->will($this->returnSelf());
         $order = $this->getMock('Magento\\Sales\\Model\\Order', ['setCanReturnToStock', '__wakeup'], [], '', false);
         $order->expects($this->once())->method('setCanReturnToStock')->with($this->equalTo($manageStock))->will($this->returnSelf());
         $creditMemo->expects($this->once())->method('getOrder')->will($this->returnValue($order));
         $this->registryMock->expects($this->any())->method('registry')->with('current_creditmemo')->will($this->returnValue($creditMemo));
     }
     $this->assertSame($result, $this->items->canReturnItemsToStock());
     $this->assertSame($result, $property->getValue($this->items));
     // lazy load test
     $this->assertSame($result, $this->items->canReturnItemsToStock());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:ItemsTest.php

示例3: testGetStore

 public function testGetStore()
 {
     $this->registryMock->expects($this->once())->method('registry')->with('current_store')->willReturn($this->storeMock);
     $this->assertInstanceOf(StoreInterface::class, $this->model->getStore());
     // Lazy loading
     $this->assertInstanceOf(StoreInterface::class, $this->model->getStore());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:RegistryLocatorTest.php

示例4: testToHtml

 /**
  *  Test protected `_toHtml` method via public `toHtml` method.
  */
 public function testToHtml()
 {
     $eventManager = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->disableOriginalConstructor()->setMethods(['dispatch'])->getMock();
     $eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true));
     $scopeConfig = $this->getMockBuilder('\\Magento\\Framework\\App\\Config')->setMethods(['getValue'])->disableOriginalConstructor()->getMock();
     $scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()->will($this->returnValue(false));
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])->getMock();
     $product->expects($this->once())->method('setStoreId')->will($this->returnSelf());
     $product->expects($this->once())->method('load')->will($this->returnSelf());
     $product->expects($this->once())->method('getId')->will($this->returnValue(1));
     $optionsBlock = $this->getMockBuilder('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Options\\Option')->setMethods(['setIgnoreCaching', 'setProduct', 'getOptionValues'])->disableOriginalConstructor()->getMock();
     $optionsBlock->expects($this->once())->method('setIgnoreCaching')->with(true)->will($this->returnSelf());
     $optionsBlock->expects($this->once())->method('setProduct')->with($product)->will($this->returnSelf());
     $optionsBlock->expects($this->once())->method('getOptionValues')->will($this->returnValue([]));
     $layout = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Element\\Layout')->disableOriginalConstructor()->setMethods(['createBlock'])->getMock();
     $layout->expects($this->once())->method('createBlock')->with('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Options\\Option')->will($this->returnValue($optionsBlock));
     $request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->setMethods(['getParam'])->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('getParam')->with('store')->will($this->returnValue(0));
     $this->context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
     $this->context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
     $this->context->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
     $this->context->expects($this->once())->method('getRequest')->will($this->returnValue($request));
     $this->registry->expects($this->once())->method('registry')->with('import_option_products')->will($this->returnValue([1]));
     $this->productFactory->expects($this->once())->method('create')->will($this->returnValue($product));
     $this->block = $this->objectManagerHelper->getObject('Magento\\Catalog\\Block\\Adminhtml\\Product\\Options\\Ajax', ['context' => $this->context, 'jsonEncoder' => $this->encoderInterface, 'productFactory' => $this->productFactory, 'registry' => $this->registry]);
     $this->block->toHtml();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:AjaxTest.php

示例5: testToOptionArray

 public function testToOptionArray()
 {
     $inputTypesSet = [['value' => 'text', 'label' => 'Text Field'], ['value' => 'textarea', 'label' => 'Text Area'], ['value' => 'date', 'label' => 'Date'], ['value' => 'boolean', 'label' => 'Yes/No'], ['value' => 'multiselect', 'label' => 'Multiple Select'], ['value' => 'select', 'label' => 'Dropdown'], ['value' => 'price', 'label' => 'Price'], ['value' => 'media_image', 'label' => 'Media Image']];
     $this->registry->expects($this->once())->method('registry');
     $this->registry->expects($this->once())->method('register');
     $this->assertEquals($inputTypesSet, $this->inputtypeModel->toOptionArray());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:InputtypeTest.php

示例6: testGetLinkData

 public function testGetLinkData()
 {
     $expectingFileData = ['file' => ['file' => 'file/link.gif', 'name' => '<a href="final_url">link.gif</a>', 'size' => '1.1', 'status' => 'old'], 'sample_file' => ['file' => 'file/sample.gif', 'name' => '<a href="final_url">sample.gif</a>', 'size' => '1.1', 'status' => 'old']];
     $this->productModel->expects($this->any())->method('getTypeId')->will($this->returnValue('downloadable'));
     $this->productModel->expects($this->any())->method('getTypeInstance')->will($this->returnValue($this->downloadableProductModel));
     $this->productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(0));
     $this->downloadableProductModel->expects($this->any())->method('getLinks')->will($this->returnValue([$this->downloadableLinkModel]));
     $this->coreRegistry->expects($this->any())->method('registry')->will($this->returnValue($this->productModel));
     $this->downloadableLinkModel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->downloadableLinkModel->expects($this->any())->method('getTitle')->will($this->returnValue('Link Title'));
     $this->downloadableLinkModel->expects($this->any())->method('getPrice')->will($this->returnValue('10'));
     $this->downloadableLinkModel->expects($this->any())->method('getNumberOfDownloads')->will($this->returnValue('6'));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkUrl')->will($this->returnValue(null));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkType')->will($this->returnValue('file'));
     $this->downloadableLinkModel->expects($this->any())->method('getSampleFile')->will($this->returnValue('file/sample.gif'));
     $this->downloadableLinkModel->expects($this->any())->method('getSampleType')->will($this->returnValue('file'));
     $this->downloadableLinkModel->expects($this->any())->method('getSortOrder')->will($this->returnValue(0));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkFile')->will($this->returnValue('file/link.gif'));
     $this->downloadableLinkModel->expects($this->any())->method('getStoreTitle')->will($this->returnValue('Store Title'));
     $this->escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue('Link Title'));
     $this->fileHelper->expects($this->any())->method('getFilePath')->will($this->returnValue('/file/path/link.gif'));
     $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem')->will($this->returnValue(true));
     $this->fileHelper->expects($this->any())->method('getFileSize')->will($this->returnValue('1.1'));
     $this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue('final_url'));
     $linkData = $this->block->getLinkData();
     foreach ($linkData as $link) {
         $fileSave = $link->getFileSave(0);
         $sampleFileSave = $link->getSampleFileSave(0);
         $this->assertEquals($expectingFileData['file'], $fileSave);
         $this->assertEquals($expectingFileData['sample_file'], $sampleFileSave);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:LinksTest.php

示例7: testToHtml

 public function testToHtml()
 {
     $fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
     $form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
     $attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
     $directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
     $this->formFactory->expects($this->any())->method('create')->willReturn($form);
     $form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
     $form->expects($this->any())->method('getElement')->willReturn($formElement);
     $fieldSet->expects($this->any())->method('addField')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
     $attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getId')->willReturn(1);
     $attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
     $attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
     $attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
     $entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
     $this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
     $formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
     $this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
     $directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
     $this->block->setData(['action' => 'save']);
     $this->block->toHtml();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:29,代码来源:AdvancedTest.php

示例8: setUp

 protected function setUp()
 {
     $this->registryMock = $this->getMockBuilder(Registry::class)->disableOriginalConstructor()->getMock();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['isReadonly', 'isDuplicable'])->getMockForAbstractClass();
     $this->registryMock->expects(static::any())->method('registry')->with('current_product')->willReturn($this->productMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->saveButton = $this->objectManagerHelper->getObject(SaveButton::class, ['registry' => $this->registryMock]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:SaveTest.php

示例9: testGetButtonData

 /**
  * @param array $result
  * @param bool $expectedValue
  * @dataProvider getButtonDataProvider
  */
 public function testGetButtonData($result, $expectedValue)
 {
     $this->registryMock->expects($this->any())->method('registry')->willReturn(1);
     $this->customerRegistryMock->expects($this->once())->method('retrieve')->willReturn($this->customerModelMock);
     $this->customerModelMock->expects($this->once())->method('isCustomerLocked')->willReturn($expectedValue);
     $this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://website.com/');
     $this->assertEquals($result, $this->block->getButtonData());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:UnlockButtonTest.php

示例10: testGetCurrentCategoryKey

 public function testGetCurrentCategoryKey()
 {
     $categoryKey = 101;
     $category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
     $category->expects($this->any())->method('getPath')->willReturn($categoryKey);
     $this->registry->expects($this->any())->method('registry')->with('current_category')->willReturn($category);
     $this->assertEquals($categoryKey, $this->block->getCurrentCategoryKey());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:NavigationTest.php

示例11: setUp

 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->registryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['registry'])->getMock();
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->getMockForAbstractClass();
     $this->registryMock->expects($this->once())->method('registry')->with('current_product')->willReturn($this->productMock);
     $this->model = $this->objectManager->getObject('Magento\\Catalog\\Model\\Locator\\RegistryLocator', ['registry' => $this->registryMock]);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:8,代码来源:RegistryLocatorTest.php

示例12: testGetHeaderText

 /**
  * @covers \Magento\Cms\Block\Adminhtml\Block\Edit::getHeaderText
  * @param integer|null $modelBlockId
  *
  * @dataProvider getHeaderTextDataProvider
  */
 public function testGetHeaderText($modelBlockId)
 {
     $title = 'some title';
     $escapedTitle = 'escaped title';
     $this->registryMock->expects($this->atLeastOnce())->method('registry')->with('cms_block')->willReturn($this->modelBlockMock);
     $this->modelBlockMock->expects($this->atLeastOnce())->method('getId')->willReturn($modelBlockId);
     $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->with($title)->willReturn($escapedTitle);
     $this->assertInstanceOf('Magento\\Framework\\Phrase', $this->this->getHeaderText());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:EditTest.php

示例13: testToOptionArray

 public function testToOptionArray()
 {
     $collection = $this->getMock('Magento\\Email\\Model\\Resource\\Template\\Collection', [], [], '', false);
     $collection->expects($this->once())->method('toOptionArray')->will($this->returnValue([['value' => 'template_one', 'label' => 'Template One'], ['value' => 'template_two', 'label' => 'Template Two']]));
     $this->_coreRegistry->expects($this->once())->method('registry')->with('config_system_email_template')->will($this->returnValue($collection));
     $this->_emailConfig->expects($this->once())->method('getTemplateLabel')->with('template_new')->will($this->returnValue('Template New'));
     $expectedResult = [['value' => 'template_new', 'label' => 'Template New (Default)'], ['value' => 'template_one', 'label' => 'Template One'], ['value' => 'template_two', 'label' => 'Template Two']];
     $this->_model->setPath('template/new');
     $this->assertEquals($expectedResult, $this->_model->toOptionArray());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:TemplateTest.php

示例14: testGetMediaEmptyGalleryDataJson

 /**
  * Test getMediaEmptyGalleryDataJson()
  */
 public function testGetMediaEmptyGalleryDataJson()
 {
     $mediaGalleryData = [];
     $this->coreRegistry->expects($this->any())->method('registry')->willReturn($this->productModelMock);
     $typeInstance = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Type\\AbstractType', [], [], '', false);
     $typeInstance->expects($this->any())->method('getStoreFilter')->willReturn('_cache_instance_store_filter');
     $this->productModelMock->expects($this->any())->method('getTypeInstance')->willReturn($typeInstance);
     $this->productModelMock->expects($this->any())->method('getMediaGalleryImages')->willReturn($mediaGalleryData);
     $this->gallery->getMediaGalleryDataJson();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:GalleryTest.php

示例15: testPrepareLayoutSuccessOnFalseGetId

 public function testPrepareLayoutSuccessOnFalseGetId()
 {
     $tab = 'tab';
     $this->registryMock->expects($this->once())->method('registry')->willReturn($this->layoutInterfaceMock);
     $this->layoutInterfaceMock->expects($this->any())->method('createBlock')->willReturnSelf();
     $this->layoutInterfaceMock->expects($this->once())->method('setRole')->willReturnSelf();
     $this->layoutInterfaceMock->expects($this->once())->method('setActive')->willReturn($tab);
     $this->layoutInterfaceMock->expects($this->once())->method('getId')->willReturn(false);
     $this->assertInstanceOf('Magento\\Backend\\Block\\Widget\\Tabs', $this->invokeMethod($this->model, '_prepareLayout'));
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:10,代码来源:EditTest.php


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