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


PHP ObjectManager::getCollectionMock方法代碼示例

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


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

示例1: testGetListReturnsTheListOfActiveCheckoutAgreements

 public function testGetListReturnsTheListOfActiveCheckoutAgreements()
 {
     $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null)->will($this->returnValue(true));
     $agreementData = array('id' => 1, 'name' => 'Checkout Agreement', 'content' => 'Agreement content: <b>HTML</b>', 'content_height' => '100px', 'checkbox_text' => 'Checkout Agreement Checkbox Text', 'active' => true, 'html' => true);
     $storeId = 1;
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false);
     $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
     $collectionMock = $this->objectManager->getCollectionMock('Magento\\CheckoutAgreements\\Model\\Resource\\Agreement\\Collection', array($this->getAgreementMock($agreementData)));
     $this->factoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('addStoreFilter')->with($storeId);
     $collectionMock->expects($this->once())->method('addFieldToFilter')->with('is_active', 1);
     $agreementDataObject = $this->getMock('Magento\\CheckoutAgreements\\Service\\V1\\Data\\Agreement', array(), array(), '', false);
     $this->agreementBuilderMock->expects($this->once())->method('populateWithArray')->with($agreementData);
     $this->agreementBuilderMock->expects($this->once())->method('create')->will($this->returnValue($agreementDataObject));
     $this->assertEquals(array($agreementDataObject), $this->service->getList());
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:17,代碼來源:ReadServiceTest.php


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