• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Adapter\AdapterInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface类的具体用法?PHP AdapterInterface怎么用?PHP AdapterInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AdapterInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: generateExpression

 /**
  * @param Dimension $dimension
  * @param AdapterInterface $adapter
  * @return string
  */
 private function generateExpression(Dimension $dimension, AdapterInterface $adapter)
 {
     $identifier = $dimension->getName();
     $value = $dimension->getValue();
     if (self::DEFAULT_DIMENSION_NAME === $identifier) {
         $identifier = self::STORE_FIELD_NAME;
         $value = $this->scopeResolver->getScope($value)->getId();
     }
     return sprintf('%s = %s', $adapter->quoteIdentifier($identifier), $adapter->quote($value));
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Dimensions.php


示例4: checkDatabasePrivileges

 /**
  * Checks database privileges
  *
  * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
  * @param string $dbName
  * @return bool
  * @throws \Magento\Setup\Exception
  */
 private function checkDatabasePrivileges(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $dbName)
 {
     $grantInfo = $connection->query('SHOW GRANTS FOR current_user()')->fetchAll(\PDO::FETCH_NUM);
     foreach ($grantInfo as $grantRow) {
         if (preg_match('/(ALL|ALL\\sPRIVILEGES)\\sON\\s[^a-zA-Z\\d\\s]?(\\*|' . $dbName . ')/', $grantRow[0]) === 1) {
             return true;
         }
     }
     throw new \Magento\Setup\Exception('Database user does not have enough privileges.');
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:18,代码来源:DbValidator.php


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: runQuery

 public function runQuery($query)
 {
     $this->addQueryToLog($query);
     $this->connection->query($query);
     $this->connection->resetDdlCache();
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:AbstractModifier.php


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: 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,代码来源:


示例18: testSelectByCompositeKey

 public function testSelectByCompositeKey()
 {
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock));
     $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock));
     $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock);
     $this->connectionMock->expects($this->once())->method('fetchRow');
     $this->nonceResource->selectByCompositeKey('nonce', 5);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:NonceTest.php


示例19: testCheckDatabaseConnectionIncompatible

 /**
  * @expectedException \Magento\Setup\Exception
  * @expectedExceptionMessage Sorry, but we support MySQL version
  */
 public function testCheckDatabaseConnectionIncompatible()
 {
     $this->connection
         ->expects($this->once())
         ->method('fetchOne')
         ->with('SELECT version()')
         ->willReturn('5.5.40-0ubuntu0.12.04.1');
     $this->dbValidator->checkDatabaseConnection('name', 'host', 'user', 'password');
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:DbValidatorTest.php


示例20: testDeleteRaiseException

 /**
  * @expectedException \Exception
  */
 public function testDeleteRaiseException()
 {
     $this->actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true));
     $this->adapterMock->expects($this->once())->method('beginTransaction');
     $this->resourceMock->expects($this->once())->method('delete')->will($this->throwException(new \Exception()));
     $this->resourceMock->expects($this->never())->method('commit');
     $this->resourceMock->expects($this->once())->method('rollBack');
     $this->model->delete();
 }
开发者ID:,项目名称:,代码行数:12,代码来源:



注:本文中的Magento\Framework\DB\Adapter\AdapterInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Pdo\Mysql类代码示例发布时间:2022-05-23
下一篇:
PHP DB\Select类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap