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


PHP Adapter\AdapterInterface類代碼示例

本文整理匯總了PHP中Magento\Framework\DB\Adapter\AdapterInterface的典型用法代碼示例。如果您正苦於以下問題:PHP AdapterInterface類的具體用法?PHP AdapterInterface怎麽用?PHP AdapterInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AdapterInterface類的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: getIdsSelect

 /**
  * @param AdapterInterface $dbAdapter
  *
  * @return Select|string
  */
 public function getIdsSelect($dbAdapter)
 {
     if ($this->getTable() && $this->getPkFieldName()) {
         $select = $dbAdapter->select()->from($this->getTable(), $this->getPkFieldName());
         return $select;
     }
     return '';
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:13,代碼來源:Condition.php

示例3: getWhereFromApiCriteria

 public function getWhereFromApiCriteria(\Magento\Framework\Api\Search\SearchCriteriaInterface $criteria, \Praxigento\Core\Repo\Query\Criteria\IMapper $mapper = null)
 {
     $result = '';
     $filterGroups = $criteria->getFilterGroups();
     foreach ($filterGroups as $filterGroup) {
         $processed = [];
         // I don't know what is it "filter group" so uniquelize conditions inside one group only
         /** @var \Magento\Framework\Api\Filter $item */
         foreach ($filterGroup->getFilters() as $item) {
             $field = $item->getField();
             if ($mapper) {
                 $field = $mapper->get($field);
             }
             $cond = $item->getConditionType();
             $value = $item->getValue();
             $where = $this->_conn->prepareSqlCondition($field, [$cond => $value]);
             if (!in_array($where, $processed)) {
                 $result .= "({$where}) AND ";
                 $processed[] = $where;
             }
         }
     }
     $result .= '1';
     return $result;
 }
開發者ID:praxigento,項目名稱:mobi_mod_mage2_core,代碼行數:25,代碼來源:Adapter.php

示例4: testResetSearchResult

 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', 'core_read')->willReturn('table_name_search_query');
     $this->adapter->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
     $result = $this->target->resetSearchResults();
     $this->assertEquals($this->target, $result);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:7,代碼來源:FulltextTest.php

示例5: testDeleteRecordsOlderThen

 /**
  * @return void
  */
 public function testDeleteRecordsOlderThen()
 {
     $timestamp = 12345;
     $this->resourceMock->expects($this->once())->method('getConnection')->willReturn($this->dbAdapterMock);
     $this->dbAdapterMock->expects($this->once())->method('delete')->with($this->model->getMainTable(), ['created_at < ?' => $this->dateTimeMock->formatDate($timestamp)])->willReturnSelf();
     $this->assertEquals($this->model, $this->model->deleteRecordsOlderThen($timestamp));
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:10,代碼來源:PasswordResetRequestEventTest.php

示例6: testPrepareProductIndexForBundleProduct

 /**
  * @magentoDataFixture Magento/Bundle/_files/product.php
  * @covers \Magento\Indexer\Model\Indexer::reindexAll
  * @covers \Magento\Bundle\Model\Product\Type::getSearchableData
  */
 public function testPrepareProductIndexForBundleProduct()
 {
     $this->indexer->reindexAll();
     $select = $this->connectionMock->select()->from($this->resource->getTableName('catalogsearch_fulltext_scope1'))->where('`data_index` LIKE ?', '%' . 'Bundle Product Items' . '%');
     $result = $this->connectionMock->fetchAll($select);
     $this->assertCount(1, $result);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:TypeTest.php

示例7: runQuery

 public function runQuery($query)
 {
     $this->addQueryToLog($query);
     $this->connection->query($query);
     $this->connection->resetDdlCache();
     return $this;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:7,代碼來源:AbstractModifier.php

示例8: restore

 /**
  * Restore max_heap_table_size value
  *
  * @throws \RuntimeException
  * @return void
  */
 public function restore()
 {
     if (null === $this->currentMaxHeapTableSize) {
         throw new \RuntimeException('max_heap_table_size parameter is not set');
     }
     $this->connection->query('SET SESSION max_heap_table_size = ' . $this->currentMaxHeapTableSize);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:13,代碼來源:MaxHeapTableSizeProcessor.php

示例9: testSaveEntityIndexes

 /**
  * @dataProvider saveEntityIndexesDataProvider
  */
 public function testSaveEntityIndexes($storeId, $entityIndexes, $expected)
 {
     if ($expected) {
         $this->connection->expects($this->once())->method('insertOnDuplicate')->with(null, $expected, ['data_index'])->willReturnSelf();
     }
     $this->target->saveEntityIndexes($storeId, $entityIndexes);
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:10,代碼來源:EngineTest.php

示例10: testResetSearchResult

 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', ResourceConnection::DEFAULT_CONNECTION)->willReturn('table_name_search_query');
     $this->connection->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
     $result = $this->target->resetSearchResults();
     $this->assertEquals($this->target, $result);
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:7,代碼來源:FulltextTest.php

示例11: testExecute

 /**
  * @param $inputData
  * @param $tableData
  * @param $preparedData
  * @param $finalData
  * @dataProvider executeDataProvider
  */
 public function testExecute($inputData, $tableData, $preparedData, $finalData)
 {
     $this->connection->expects($this->any())->method('describeTable')->with('entity_table')->willReturn($tableData);
     $this->connection->expects($this->once())->method('insert')->with('entity_table', $preparedData);
     $actualData = $this->subject->execute('Test\\Entity\\Type', $inputData);
     $this->assertEquals($finalData, $actualData);
 }
開發者ID:hientruong90,項目名稱:magento2_installer,代碼行數:14,代碼來源:CreateEntityRowTest.php

示例12: testGetStoreOptionValues

 /**
  * @dataProvider dataForGetStoreOptionValues
  */
 public function testGetStoreOptionValues($values)
 {
     $this->block->expects($this->once())->method('getData')->with('store_option_values_1')->willReturn($values);
     if ($values === null) {
         $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
         $option = $this->getMock('\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Option', ['getId', 'getValue', 'getLabel'], [], '', false);
         $attrOptionCollectionMock = $objectManager->getCollectionMock('\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Option\\Collection', [$option, $option]);
         $this->attrOptionCollectionFactoryMock->expects($this->once())->method('create')->willReturn($attrOptionCollectionMock);
         $attribute = $this->getMock('\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute', ['getId'], [], '', false);
         $attribute->expects($this->once())->method('getId')->willReturn(23);
         $this->registryMock->expects($this->once())->method('registry')->with('entity_attribute')->willReturn($attribute);
         $attrOptionCollectionMock->expects($this->once())->method('setAttributeFilter')->with(23)->will($this->returnSelf());
         $this->connectionMock->expects($this->any())->method('quoteInto')->willReturn('quoted_string_with_value');
         $attrOptionCollectionMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
         $zendDbSelectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
         $attrOptionCollectionMock->expects($this->any())->method('getSelect')->willReturn($zendDbSelectMock);
         $zendDbSelectMock->expects($this->any())->method('joinLeft')->willReturnSelf();
         $option->expects($this->at(0))->method('getId')->willReturn(14);
         $option->expects($this->at(1))->method('getValue')->willReturn('Blue');
         $option->expects($this->at(2))->method('getId')->willReturn(14);
         $option->expects($this->at(3))->method('getLabel')->willReturn('#0000FF');
         $option->expects($this->at(4))->method('getId')->willReturn(15);
         $option->expects($this->at(5))->method('getValue')->willReturn('Black');
         $option->expects($this->at(6))->method('getId')->willReturn(15);
         $option->expects($this->at(7))->method('getLabel')->willReturn('#000000');
         $values = [14 => 'Blue', 'swatch' => [14 => '#0000FF', 15 => '#000000'], 15 => 'Black'];
     }
     $result = $this->block->getStoreOptionValues(1);
     $this->assertEquals($result, $values);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:33,代碼來源:AbstractSwatchTest.php

示例13: testAddStoreFilterIfStoreIsInt

 /**
  * @param int $storeId
  * @param bool $withAdmin
  * @param array $condition
  * @dataProvider dataProviderForTestAddStoreFilterIfStoreIsInt
  * @covers \Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection
  */
 public function testAddStoreFilterIfStoreIsInt($storeId, $withAdmin, $condition)
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->once())->method('getId')->will($this->returnValue($storeId));
     $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store));
     $this->connectionMock->expects($this->once())->method('prepareSqlCondition')->with('store_id', ['in' => $condition]);
     $this->collection->addStoreFilter($storeId, $withAdmin);
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:15,代碼來源:UrlRewriteCollectionTest.php

示例14: testBuildQuery

 /**
  * @param string $field
  * @param string $value
  * @param string $expectedResult
  * @dataProvider buildQueryDataProvider
  */
 public function testBuildQuery($field, $value, $expectedResult)
 {
     $this->requestFilter->expects($this->once())->method('getField')->will($this->returnValue($field));
     $this->requestFilter->expects($this->once())->method('getValue')->will($this->returnValue($value));
     $this->adapter->expects($this->once())->method('quote')->will($this->returnArgument(0));
     $actualResult = $this->filter->buildFilter($this->requestFilter);
     $this->assertEquals($expectedResult, $actualResult);
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:14,代碼來源:TermTest.php

示例15: testMove

 /**
  * @param string $flatTable
  * @param bool $isFlatTableExists
  * @param string $flatDropName
  * @param string $temporaryFlatTableName
  * @param array $expectedRenameTablesArgument
  * @dataProvider moveDataProvider
  */
 public function testMove($flatTable, $isFlatTableExists, $flatDropName, $temporaryFlatTableName, $expectedRenameTablesArgument)
 {
     $this->_connectionMock->expects($this->exactly(2))->method('dropTable')->with($flatDropName);
     $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue($isFlatTableExists));
     $this->_connectionMock->expects($this->once())->method('renameTablesBatch')->with($expectedRenameTablesArgument);
     $this->_resourceMock->expects($this->any())->method('getConnection')->with('write')->will($this->returnValue($this->_connectionMock));
     $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\TableData', array('resource' => $this->_resourceMock));
     $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
 }
開發者ID:,項目名稱:,代碼行數:17,代碼來源:


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