当前位置: 首页>>代码示例>>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;未经允许,请勿转载。