當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StoreManagerInterface::expects方法代碼示例

本文整理匯總了PHP中Magento\Store\Model\StoreManagerInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP StoreManagerInterface::expects方法的具體用法?PHP StoreManagerInterface::expects怎麽用?PHP StoreManagerInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Store\Model\StoreManagerInterface的用法示例。


在下文中一共展示了StoreManagerInterface::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->any())->method('quoteInto')->willReturnCallback(function ($query, $expression) {
         return str_replace('?', $expression, $query);
     });
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->getMock();
     $this->resource->method('getTableName')->willReturnCallback(function ($table) {
         return 'prefix_' . $table;
     });
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->website = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\WebsiteInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->website->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->store->expects($this->any())->method('getId')->willReturn(self::STORE_ID);
     $this->storeManager = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getWebsite')->willReturn($this->website);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $this->attributeCollection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection')->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory->expects($this->once())->method('create')->willReturn($this->attributeCollection);
     $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Search\\TableMapper', ['resource' => $this->resource, 'storeManager' => $this->storeManager, 'attributeCollectionFactory' => $attributeCollectionFactory]);
     $this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMock();
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:26,代碼來源:TableMapperTest.php

示例2: testDispatch

 /**
  * @param bool $isWebsiteScope
  * @param array $websites
  * @param int $quoteId
  * @dataProvider dispatchDataProvider
  */
 public function testDispatch($isWebsiteScope, $websites, $quoteId)
 {
     $this->configMock->expects($this->once())->method('isWebsiteScope')->will($this->returnValue($isWebsiteScope));
     $customerDataObjectMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $customerDataObjectMock->expects($this->any())->method('getGroupId')->will($this->returnValue(1));
     $customerDataObjectMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue(2));
     if ($isWebsiteScope) {
         $websites = $websites[0];
         $this->storeManagerMock->expects($this->once())->method('getWebsite')->with(2)->will($this->returnValue($websites));
     } else {
         $this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
     }
     $origCustomerDataObjectMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $origCustomerDataObjectMock->expects($this->any())->method('getGroupId')->will($this->returnValue(2));
     $this->eventMock->expects($this->any())->method('getCustomerDataObject')->will($this->returnValue($customerDataObjectMock));
     $this->eventMock->expects($this->any())->method('getOrigCustomerDataObject')->will($this->returnValue($origCustomerDataObjectMock));
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote $quoteMock */
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->setMethods(['setWebsite', 'setCustomerGroupId', 'collectTotals', '__wakeup'])->disableOriginalConstructor()->getMock();
     $websiteCount = count($websites);
     if ($quoteId) {
         $this->quoteRepositoryMock->expects($this->exactly($websiteCount))->method('getForCustomer')->will($this->returnValue($quoteMock));
         $quoteMock->expects($this->exactly($websiteCount))->method('setWebsite');
         $quoteMock->expects($this->exactly($websiteCount))->method('setCustomerGroupId');
         $quoteMock->expects($this->exactly($websiteCount))->method('collectTotals');
         $this->quoteRepositoryMock->expects($this->exactly($websiteCount))->method('save')->with($quoteMock);
     } else {
         $this->quoteRepositoryMock->expects($this->exactly($websiteCount))->method('getForCustomer')->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
         $quoteMock->expects($this->never())->method('setCustomerGroupId');
         $quoteMock->expects($this->never())->method('collectTotals');
         $this->quoteRepositoryMock->expects($this->never())->method('save');
     }
     $this->customerQuote->dispatch($this->observerMock);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:39,代碼來源:CustomerQuoteTest.php

示例3: testSetNotIntStoreId

 public function testSetNotIntStoreId()
 {
     $this->_storeManagerInterface->expects($this->once())->method('getStore');
     $store = $this->_model->setStoreId('test');
     $storeId = $store->getStoreId();
     $this->assertEquals(0, $storeId);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:7,代碼來源:FlatTest.php

示例4: testGetRssData

 public function testGetRssData()
 {
     $rssData = ['title' => 'Pending product review(s)', 'description' => 'Pending product review(s)', 'link' => 'http://rss.magento.com', 'charset' => 'UTF-8', 'entries' => ['title' => 'Product: "Product Name" reviewed by: Product Nick', 'link' => 'http://product.magento.com', 'description' => ['rss_url' => 'http://rss.magento.com', 'name' => 'Product Name', 'summary' => 'Product Title', 'review' => 'Product Detail', 'store' => 'Store Name']]];
     $rssUrl = 'http://rss.magento.com';
     $productModel = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product', ['getStoreId', 'getId', 'getReviewId', 'getName', 'getDetail', 'getTitle', 'getNickname', 'getProductUrl'], [], '', false);
     $storeModel = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->storeManagerInterface->expects($this->once())->method('getStore')->will($this->returnValue($storeModel));
     $storeModel->expects($this->once())->method('getName')->will($this->returnValue($rssData['entries']['description']['store']));
     $this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue($rssUrl));
     $this->urlBuilder->expects($this->once())->method('setScope')->will($this->returnSelf());
     $productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
     $productModel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $productModel->expects($this->once())->method('getReviewId')->will($this->returnValue(1));
     $productModel->expects($this->any())->method('getNickName')->will($this->returnValue('Product Nick'));
     $productModel->expects($this->any())->method('getName')->will($this->returnValue($rssData['entries']['description']['name']));
     $productModel->expects($this->once())->method('getDetail')->will($this->returnValue($rssData['entries']['description']['review']));
     $productModel->expects($this->once())->method('getTitle')->will($this->returnValue($rssData['entries']['description']['summary']));
     $productModel->expects($this->any())->method('getProductUrl')->will($this->returnValue('http://product.magento.com'));
     $this->rss->expects($this->once())->method('getProductCollection')->will($this->returnValue([$productModel]));
     $data = $this->block->getRssData();
     $this->assertEquals($rssData['title'], $data['title']);
     $this->assertEquals($rssData['description'], $data['description']);
     $this->assertEquals($rssData['link'], $data['link']);
     $this->assertEquals($rssData['charset'], $data['charset']);
     $this->assertEquals($rssData['entries']['title'], $data['entries'][0]['title']);
     $this->assertEquals($rssData['entries']['link'], $data['entries'][0]['link']);
     $this->assertContains($rssData['entries']['description']['rss_url'], $data['entries'][0]['description']);
     $this->assertContains($rssData['entries']['description']['name'], $data['entries'][0]['description']);
     $this->assertContains($rssData['entries']['description']['summary'], $data['entries'][0]['description']);
     $this->assertContains($rssData['entries']['description']['review'], $data['entries'][0]['description']);
     $this->assertContains($rssData['entries']['description']['store'], $data['entries'][0]['description']);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:32,代碼來源:RssTest.php

示例5: testSearch

 public function testSearch()
 {
     $requestName = 'requestName';
     $storeId = 333;
     $filterField = 'filterField';
     $filterValue = 'filterValue';
     $filter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->disableOriginalConstructor()->getMock();
     $filter->expects($this->once())->method('getField')->willReturn($filterField);
     $filter->expects($this->once())->method('getValue')->willReturn($filterValue);
     $filterGroup = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->disableOriginalConstructor()->getMock();
     $filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
     $searchCriteria = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchCriteriaInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $searchCriteria->expects($this->once())->method('getRequestName')->willReturn($requestName);
     $searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getId')->willReturn($storeId);
     $searchResult = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchResult')->disableOriginalConstructor()->getMockForAbstractClass();
     $request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $response = $this->getMockBuilder('Magento\\Framework\\Search\\ResponseInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->requestBuilder->expects($this->once())->method('setRequestName')->with($requestName);
     $this->requestBuilder->expects($this->once())->method('bindDimension')->with('scope', $storeId);
     $this->requestBuilder->expects($this->any())->method('bind');
     $this->requestBuilder->expects($this->once())->method('create')->willReturn($request);
     $this->searchEngine->expects($this->once())->method('search')->with($request)->willReturn($response);
     $this->searchResponseBuilder->expects($this->once())->method('build')->with($response)->willReturn($searchResult);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $searchResult = $this->model->search($searchCriteria);
     $this->assertInstanceOf('Magento\\Framework\\Api\\Search\\SearchResultInterface', $searchResult);
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:29,代碼來源:SearchTest.php

示例6: testWidgetDirectiveWithoutRequiredVariable

 public function testWidgetDirectiveWithoutRequiredVariable()
 {
     $construction = '{{widget type="\\Magento\\Cms\\Block\\Widget\\Page\\Link" page_id="1"}}';
     $this->storeManager->expects($this->never())->method('getStore');
     $result = $this->filter->widgetDirective([0 => $construction, 1 => 'type="\\Magento\\Cms\\Block\\Widget\\Page\\Link" page_id="1"']);
     $this->assertEquals($construction, $result);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:7,代碼來源:FilterTest.php

示例7: setUp

 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->assignedWebsites = [self::SECOND_WEBSITE_ID];
     $this->websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->secondWebsiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->websiteRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\WebsiteRepositoryInterface')->setMethods(['getList', 'getDefault'])->getMockForAbstractClass();
     $this->websiteRepositoryMock->expects($this->any())->method('getDefault')->willReturn($this->websiteMock);
     $this->websiteRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
     $this->groupRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\GroupRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->storeRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\StoreRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->locatorMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Locator\\LocatorInterface')->setMethods(['getProduct', 'getWebsiteIds'])->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->setMethods(['getId'])->getMockForAbstractClass();
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->locatorMock->expects($this->any())->method('getWebsiteIds')->willReturn($this->assignedWebsites);
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['isSingleStoreMode'])->getMockForAbstractClass();
     $this->storeManagerMock->expects($this->any())->method('isSingleStoreMode')->willReturn(false);
     $this->groupMock = $this->getMockBuilder('Magento\\Store\\Model\\ResourceModel\\Group\\Collection')->setMethods(['getId', 'getName', 'getWebsiteId'])->disableOriginalConstructor()->getMock();
     $this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn(self::WEBSITE_ID);
     $this->groupMock->expects($this->any())->method('getId')->willReturn(self::GROUP_ID);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->groupMock]);
     $this->storeViewMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getName', 'getId', 'getStoreGroupId'])->disableOriginalConstructor()->getMock();
     $this->storeViewMock->expects($this->any())->method('getName')->willReturn(self::STORE_VIEW_NAME);
     $this->storeViewMock->expects($this->any())->method('getStoreGroupId')->willReturn(self::GROUP_ID);
     $this->storeViewMock->expects($this->any())->method('getId')->willReturn(self::STORE_VIEW_ID);
     $this->storeRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->storeViewMock]);
     $this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
     $this->secondWebsiteMock->expects($this->any())->method('getId')->willReturn($this->assignedWebsites[0]);
     $this->websiteMock->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:30,代碼來源:WebsitesTest.php

示例8: setUp

 /**
  * Initialize repository
  */
 public function setUp()
 {
     $this->blockResource = $this->getMockBuilder('Magento\\Cms\\Model\\ResourceModel\\Block')->disableOriginalConstructor()->getMock();
     $this->dataObjectProcessor = $this->getMockBuilder('Magento\\Framework\\Reflection\\DataObjectProcessor')->disableOriginalConstructor()->getMock();
     $blockFactory = $this->getMockBuilder('Magento\\Cms\\Model\\BlockFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $blockDataFactory = $this->getMockBuilder('Magento\\Cms\\Api\\Data\\BlockInterfaceFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $blockSearchResultFactory = $this->getMockBuilder('Magento\\Cms\\Api\\Data\\BlockSearchResultsInterfaceFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $collectionFactory = $this->getMockBuilder('Magento\\Cms\\Model\\ResourceModel\\Block\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getId')->willReturn(0);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($store);
     $this->block = $this->getMockBuilder('Magento\\Cms\\Model\\Block')->disableOriginalConstructor()->getMock();
     $this->blockData = $this->getMockBuilder('Magento\\Cms\\Api\\Data\\BlockInterface')->getMock();
     $this->blockSearchResult = $this->getMockBuilder('Magento\\Cms\\Api\\Data\\BlockSearchResultsInterface')->getMock();
     $this->collection = $this->getMockBuilder('Magento\\Cms\\Model\\ResourceModel\\Block\\Collection')->disableOriginalConstructor()->setMethods(['addFieldToFilter', 'getSize', 'setCurPage', 'setPageSize', 'load', 'addOrder'])->getMock();
     $blockFactory->expects($this->any())->method('create')->willReturn($this->block);
     $blockDataFactory->expects($this->any())->method('create')->willReturn($this->blockData);
     $blockSearchResultFactory->expects($this->any())->method('create')->willReturn($this->blockSearchResult);
     $collectionFactory->expects($this->any())->method('create')->willReturn($this->collection);
     /**
      * @var \Magento\Cms\Model\BlockFactory $blockFactory
      * @var \Magento\Cms\Api\Data\BlockInterfaceFactory $blockDataFactory
      * @var \Magento\Cms\Api\Data\BlockSearchResultsInterfaceFactory $blockSearchResultFactory
      * @var \Magento\Cms\Model\ResourceModel\Block\CollectionFactory $collectionFactory
      */
     $this->dataHelper = $this->getMockBuilder('Magento\\Framework\\Api\\DataObjectHelper')->disableOriginalConstructor()->getMock();
     $this->repository = new BlockRepository($this->blockResource, $blockFactory, $blockDataFactory, $collectionFactory, $blockSearchResultFactory, $this->dataHelper, $this->dataObjectProcessor, $this->storeManager);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:32,代碼來源:BlockRepositoryTest.php

示例9: setUp

 protected function setUp()
 {
     $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
     $this->managerInterfaceMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->configMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->entityFactoryMock2 = $this->getMock('Magento\\Eav\\Model\\EntityFactory', [], [], '', false);
     $this->helperMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Helper', [], [], '', false);
     $entity = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', [], [], '', false);
     $adapter = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', [], '', false);
     $entity->expects($this->any())->method('getReadConnection')->will($this->returnValue($adapter));
     $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([]));
     $this->universalFactoryMock = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false);
     $this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity));
     $this->storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnCallback(function ($store) {
         return is_object($store) ? $store : new \Magento\Framework\Object(['id' => 42]);
     }));
     $this->catalogHelperMock = $this->getMock('Magento\\Catalog\\Helper\\Data', [], [], '', false);
     $this->stateMock = $this->getMock('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\State', [], [], '', false);
     $this->scopeConfigInterfaceMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->optionFactoryMock = $this->getMock('Magento\\Catalog\\Model\\Product\\OptionFactory', [], [], '', false);
     $this->urlMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Url', [], [], '', false);
     $this->timezoneInterfaceMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface');
     $this->sessionMock = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->dateTimeMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime');
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->collection = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Resource\\Product\\Link\\Product\\Collection', ['entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, 'eventManager' => $this->managerInterfaceMock, 'eavConfig' => $this->configMock, 'resource' => $this->resourceMock, 'eavEntityFactory' => $this->entityFactoryMock2, 'resourceHelper' => $this->helperMock, 'universalFactory' => $this->universalFactoryMock, 'storeManager' => $this->storeManagerMock, 'catalogData' => $this->catalogHelperMock, 'catalogProductFlatState' => $this->stateMock, 'scopeConfig' => $this->scopeConfigInterfaceMock, 'productOptionFactory' => $this->optionFactoryMock, 'catalogUrl' => $this->urlMock, 'localeDate' => $this->timezoneInterfaceMock, 'customerSession' => $this->sessionMock, 'dateTime' => $this->dateTimeMock]);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:31,代碼來源:CollectionTest.php

示例10: testGetTreeHasLevelField

 public function testGetTreeHasLevelField()
 {
     $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
     $storeGroups = [];
     $storeId = 1;
     $rootLevel = 2;
     $level = 3;
     $this->collection->expects($this->any())->method('addAttributeToSelect')->willReturnMap([['url_key', false, $this->collection], ['is_anchor', false, $this->collection]]);
     $this->childNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($level);
     $this->rootNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($rootLevel);
     $this->rootNode->expects($this->once())->method('hasChildren')->willReturn(true);
     $this->rootNode->expects($this->once())->method('getChildren')->willReturn([$this->childNode]);
     $this->categoryTree->expects($this->once())->method('load')->with(null, 3)->willReturnSelf();
     $this->categoryTree->expects($this->atLeastOnce())->method('addCollectionData')->with($this->collection)->willReturnSelf();
     $this->categoryTree->expects($this->once())->method('getNodeById')->with($rootId)->willReturn($this->rootNode);
     $this->store->expects($this->atLeastOnce())->method('getId')->willReturn($storeId);
     $this->storeManager->expects($this->once())->method('getGroups')->willReturn($storeGroups);
     $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($this->store);
     $this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
     $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
     /** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */
     $chooser = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser', ['categoryTree' => $this->categoryTree, 'context' => $this->context]);
     $chooser->setData('category_collection', $this->collection);
     $result = $chooser->getTree();
     $this->assertEquals($level, $result[0]['level']);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:28,代碼來源:ChooserTest.php

示例11: testLoadValidOrderNotEmptyPost

 public function testLoadValidOrderNotEmptyPost()
 {
     $post = ['oar_order_id' => 1, 'oar_type' => 'email', 'oar_billing_lastname' => 'oar_billing_lastname', 'oar_email' => 'oar_email', 'oar_zip' => 'oar_zip'];
     $storeId = '1';
     $incrementId = $post['oar_order_id'];
     $protectedCode = 'protectedCode';
     $this->sessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false);
     $requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $requestMock->expects($this->once())->method('getPostValue')->willReturn($post);
     $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->willReturn($this->storeModelMock);
     $this->storeModelMock->expects($this->once())->method('getId')->willReturn($storeId);
     $this->orderFactoryMock->expects($this->once())->method('create')->willReturn($this->salesOrderMock);
     $this->salesOrderMock->expects($this->once())->method('loadByIncrementIdAndStoreId')->willReturnSelf();
     $this->salesOrderMock->expects($this->any())->method('getId')->willReturn($incrementId);
     $billingAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['getLastname', 'getEmail', '__wakeup'], [], '', false);
     $billingAddressMock->expects($this->once())->method('getLastname')->willReturn($post['oar_billing_lastname']);
     $billingAddressMock->expects($this->once())->method('getEmail')->willReturn($post['oar_email']);
     $this->salesOrderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
     $this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode);
     $metaDataMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata', [], [], '', false);
     $metaDataMock->expects($this->once())->method('setPath')->with(Guest::COOKIE_PATH)->willReturnSelf();
     $metaDataMock->expects($this->once())->method('setHttpOnly')->with(true)->willReturnSelf();
     $this->cookieMetadataFactoryMock->expects($this->once())->method('createPublicCookieMetadata')->willReturn($metaDataMock);
     $this->cookieManagerMock->expects($this->once())->method('setPublicCookie')->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock);
     $this->assertTrue($this->guest->loadValidOrder($requestMock));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:26,代碼來源:GuestTest.php

示例12: setUp

 protected function setUp()
 {
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $this->storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->filter = $objectManager->getObject('Magento\\Cms\\Model\\Template\\Filter', ['storeManager' => $this->storeManagerMock]);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:8,代碼來源:FilterTest.php

示例13: testGetAllOptions

 /**
  * Test for getAllOptions method
  *
  * @param $cachedDataSrl
  * @param $cachedDataUnsrl
  *
  * @dataProvider testGetAllOptionsDataProvider
  */
 public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl)
 {
     $this->storeMock->expects($this->once())->method('getCode')->will($this->returnValue('store_code'));
     $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->cacheConfig->expects($this->once())->method('load')->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code'))->will($this->returnValue($cachedDataSrl));
     $countryOfManufacture = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Countryofmanufacture', ['storeManager' => $this->storeManagerMock, 'configCacheType' => $this->cacheConfig]);
     $this->assertEquals($cachedDataUnsrl, $countryOfManufacture->getAllOptions());
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:16,代碼來源:CountryofmanufactureTest.php

示例14: testGetStoreWebsiteId

 /**
  * Run test getStoreWebsiteId method
  *
  * @return void
  */
 public function testGetStoreWebsiteId()
 {
     $storeId = 20;
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false);
     $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($storeMock));
     $storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('return-value'));
     $this->assertEquals('return-value', $this->attribute->getStoreWebsiteId($storeId));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:AttributeTest.php

示例15: testAfterSaveDispatchWithStore

 public function testAfterSaveDispatchWithStore()
 {
     $this->designConfig->expects($this->exactly(2))->method('getScope')->willReturn('store');
     $this->designConfig->expects($this->once())->method('getScopeId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getStore')->with(1)->willReturn($this->store);
     $this->eventManager->expects($this->once())->method('dispatch')->with('admin_system_config_changed_section_design', ['website' => '', 'store' => $this->store]);
     $this->plugin->afterSave($this->repository, $this->designConfig);
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:8,代碼來源:PluginTest.php


注:本文中的Magento\Store\Model\StoreManagerInterface::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。