本文整理匯總了PHP中Magento\Framework\App\ResourceConnection::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResourceConnection::method方法的具體用法?PHP ResourceConnection::method怎麽用?PHP ResourceConnection::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\App\ResourceConnection
的用法示例。
在下文中一共展示了ResourceConnection::method方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}