当前位置: 首页>>代码示例>>PHP>>正文


PHP AdapterInterface::expects方法代码示例

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


在下文中一共展示了AdapterInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

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

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

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

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

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

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

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

示例10: testSelectTokenByCustomerId

 public function testSelectTokenByCustomerId()
 {
     $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->tokenResource->selectTokenByCustomerId(5);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:9,代码来源:TokenTest.php

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

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

示例13: testGetFkName

 public function testGetFkName()
 {
     $tableName = 'table';
     $refTable = 'ref_table';
     $columnName = 'columnName';
     $refColumnName = 'refColumnName';
     $this->connection->expects($this->once())->method('getForeignKeyName')->with($tableName, $columnName, $refTable, $refColumnName)->will($this->returnValue('fkName'));
     $this->assertEquals('fkName', $this->setup->getFkName($tableName, $columnName, $refTable, $refColumnName));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:SetupTest.php

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

示例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::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。