/**
  * @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);
 }
 /**
  * @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);
 }
 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);
 }
 /**
  * @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));
 }
 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();
 }
Exemple #6
0
 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);
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
 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);
 }
Exemple #11
0
 /**
  * @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();
 }
 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);
 }
 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));
 }
Exemple #14
0
 /**
  * @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');
 }
Exemple #15
0
 /**
  * @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);
 }
Exemple #16
0
 public function testQuery()
 {
     $selectResult = ['documents' => [['product_id' => 1, 'sku' => 'Product']], 'aggregations' => ['aggregation_name' => ['aggregation1' => [1, 3], 'aggregation2' => [2, 4]]]];
     $this->connectionAdapter->expects($this->at(0))->method('fetchAssoc')->will($this->returnValue($selectResult['documents']));
     $this->mapper->expects($this->once())->method('buildQuery')->with($this->request)->will($this->returnValue($this->select));
     $this->responseFactory->expects($this->once())->method('create')->with($selectResult)->will($this->returnArgument(0));
     $this->aggregatioBuilder->expects($this->once())->method('build')->willReturn($selectResult['aggregations']);
     $response = $this->adapter->query($this->request);
     $this->assertEquals($selectResult, $response);
 }
 public function testSaveNumResults()
 {
     /** @var \Magento\Search\Model\Query|\PHPUnit_Framework_MockObject_MockObject $model */
     $model = $this->getMockBuilder('Magento\\Search\\Model\\Query')->disableOriginalConstructor()->getMock();
     $model->expects($this->any())->method('getStoreId')->willReturn(1);
     $model->expects($this->any())->method('getQueryText')->willReturn('queryText');
     $model->expects($this->any())->method('getNumResults')->willReturn(30);
     $this->adapter->expects($this->once())->method('insertOnDuplicate');
     $this->model->saveNumResults($model);
 }
 /**
  * @return \Magento\Framework\DB\Ddl\Table|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createTemporaryTable()
 {
     $table = $this->getMockBuilder('Magento\\Framework\\DB\\Ddl\\Table')->disableOriginalConstructor()->getMock();
     $table->expects($this->at(1))->method('addColumn')->with(TemporaryStorage::FIELD_ENTITY_ID, Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false, 'primary' => true], 'Entity ID');
     $table->expects($this->at(2))->method('addColumn')->with('score', Table::TYPE_DECIMAL, [32, 16], ['unsigned' => true, 'nullable' => false], 'Score');
     $table->expects($this->once())->method('setOption')->with('type', 'memory');
     $this->adapter->expects($this->once())->method('newTable')->with($this->tableName)->willReturn($table);
     $this->adapter->expects($this->once())->method('dropTemporaryTable');
     $this->adapter->expects($this->once())->method('createTemporaryTable')->with($table);
     return $table;
 }
Exemple #19
0
 public function testGetTimeInSecondsSinceCreation()
 {
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $selectMock->expects($this->any())->method('from')->will($this->returnValue($selectMock));
     $selectMock->expects($this->any())->method('reset')->will($this->returnValue($selectMock));
     $selectMock->expects($this->any())->method('columns')->will($this->returnValue($selectMock));
     $selectMock->expects($this->any())->method('where')->will($this->returnValue($selectMock));
     $this->connectionMock->expects($this->any())->method('select')->willReturn($selectMock);
     $this->connectionMock->expects($this->once())->method('fetchOne');
     $this->consumerResource->getTimeInSecondsSinceCreation(1);
 }
 public function testGetCILike()
 {
     $field = 'field';
     $value = 'value';
     $options = [];
     $this->_adapterMock->expects($this->once())->method('quoteIdentifier')->with($field)->will($this->returnArgument(0));
     $this->_model->expects($this->once())->method('addLikeEscape')->with($value, $options)->will($this->returnArgument(0));
     $result = $this->_model->getCILike($field, $value, $options);
     $this->assertInstanceOf('Zend_Db_Expr', $result);
     $this->assertEquals($field . ' LIKE ' . $value, (string) $result);
 }
 /**
  * @param string $field
  * @param string $from
  * @param string $to
  * @param string $expectedResult
  * @dataProvider buildQueryDataProvider
  */
 public function testBuildQuery($field, $from, $to, $expectedResult)
 {
     $this->requestFilter->expects($this->once())->method('getField')->will($this->returnValue($field));
     $this->requestFilter->expects($this->once())->method('getFrom')->will($this->returnValue($from));
     $this->requestFilter->expects($this->once())->method('getTo')->will($this->returnValue($to));
     $this->adapter->expects($this->any())->method('quote')->will($this->returnCallback(function ($value) {
         return '\'' . $value . '\'';
     }));
     $actualResult = $this->filter->buildFilter($this->requestFilter);
     $this->assertEquals($expectedResult, $actualResult);
 }
 public function testAddOrdersFilter()
 {
     $this->resourceConnectionMock->expects($this->exactly(2))->method('getConnection')->willReturn($this->connectionMock);
     $this->resourceConnectionMock->expects($this->once())->method('getTableName')->with('paypal_billing_agreement_order')->willReturn('pref_paypal_billing_agreement_order');
     $this->connectionMock->expects($this->once())->method('select')->willReturn($this->selectMock);
     $this->selectMock->expects($this->once())->method('from')->with(['pbao' => 'pref_paypal_billing_agreement_order'], ['order_id'], null)->willReturnSelf();
     $this->selectMock->expects($this->exactly(2))->method('where')->withConsecutive(['pbao.agreement_id IN(?)', [100]], ['main_table.entity_id IN (?)', [500]])->willReturnSelf();
     $this->connectionMock->expects($this->once())->method('fetchCol')->with($this->selectMock, [])->willReturn([500]);
     $this->collectionMock->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
     $this->assertEquals($this->agreementResource, $this->agreementResource->addOrdersFilter($this->collectionMock, 100));
 }
 public function testExecute()
 {
     $identifier = '100000001';
     $context = ['store_id' => 1];
     $expectedData = ['entity_id' => 1];
     $this->select->expects($this->once())->method('from')->with(['t' => 'entity_table'])->willReturnSelf();
     $this->select->expects($this->at(1))->method('where')->with('identifier = ?', $identifier)->willReturnSelf();
     $this->select->expects($this->at(2))->method('where')->with('store_id = ?', 1)->willReturnSelf();
     $this->connection->expects($this->once())->method('fetchRow')->willReturn($expectedData);
     $actualData = $this->subject->execute('Test\\Entity\\Type', $identifier, $context);
     $this->assertEquals($expectedData, $actualData);
 }
 public function testGetTaxItemsByOrderId()
 {
     $orderId = 1;
     $taxItems = [['tax_id' => 1, 'tax_percent' => 5, 'item_id' => 1, 'taxable_item_type' => 4, 'associated_item_id' => 1, 'real_amount' => 12, 'real_base_amount' => 12]];
     $select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->connectionMock->expects($this->once())->method('select')->willReturn($select);
     $select->expects($this->once())->method('from')->with(['item' => 'sales_order_tax_item'], ['tax_id', 'tax_percent', 'item_id', 'taxable_item_type', 'associated_item_id', 'real_amount', 'real_base_amount'])->willReturnSelf();
     $select->expects($this->once())->method('join')->with(['tax' => 'sales_order_tax'], 'item.tax_id = tax.tax_id', ['code', 'title', 'order_id'])->willReturnSelf();
     $select->expects($this->once())->method('where')->with('tax.order_id = ?', $orderId)->willReturnSelf();
     $this->connectionMock->expects($this->once())->method('fetchAll')->with($select)->willReturn($taxItems);
     $this->assertEquals($taxItems, $this->taxItem->getTaxItemsByOrderId($orderId));
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Expected Exception
  * @throws \Exception
  */
 public function testSaveFailed()
 {
     $this->modelMock->expects($this->any())->method('getEventPrefix')->will($this->returnValue('event_prefix'));
     $this->modelMock->expects($this->any())->method('getEventObject')->will($this->returnValue('event_object'));
     $this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $exception = new \Exception('Expected Exception');
     $this->modelMock->expects($this->any())->method('getId')->will($this->throwException($exception));
     $this->connectionMock->expects($this->once())->method('beginTransaction');
     $this->connectionMock->expects($this->once())->method('rollback');
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('event_prefix_save_attribute_before', ['event_object' => $this->attribute, 'object' => $this->modelMock, 'attribute' => ['attribute']]);
     $this->attribute->saveAttribute($this->modelMock, 'attribute');
 }
 public function testGetUnnotifiedForInstance()
 {
     $orderId = 100000512;
     $entityType = 'order';
     $order = $this->getMock('Magento\\Sales\\Model\\Order', ['__wakeup', 'getEntityType', 'getId'], [], '', false);
     $order->expects($this->once())->method('getEntityType')->will($this->returnValue($entityType));
     $order->expects($this->once())->method('getId')->will($this->returnValue($orderId));
     $this->connectionMock = $this->collection->getResource()->getConnection();
     $this->connectionMock->expects($this->exactly(3))->method('prepareSqlCondition')->will($this->returnValueMap([['entity_name', $entityType, 'sql-string'], ['is_customer_notified', 0, 'sql-string'], ['parent_id', $orderId, 'sql-string']]));
     $result = $this->collection->getUnnotifiedForInstance($order);
     $this->assertEquals($this->historyItemMock, $result);
 }
 /**
  * Mock class dependencies
  */
 protected function setUp()
 {
     $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
     $this->fetchStrategyMock = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->connectionMock->expects($this->atLeastOnce())->method('select')->will($this->returnValue($this->selectMock));
     $this->resourceMock = $this->getMock('Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $objectManager = new ObjectManager($this);
     $this->collection = $objectManager->getObject('Magento\\Quote\\Model\\ResourceModel\\Quote\\Item\\Collection', ['entityFactory' => $this->entityFactoryMock, 'fetchStrategy' => $this->fetchStrategyMock, 'eventManager' => $this->eventManagerMock, 'resource' => $this->resourceMock]);
 }
 /**
  * @param string $type
  * @param array $result
  * @dataProvider typesDataProvider
  * @return void
  */
 public function testUpdateReportRatingPos($type, $result)
 {
     $mainTable = 'mainTable';
     $column = 'column';
     $aggregationTable = 'aggregationTable';
     $selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $selectMock->expects($this->any())->method('from')->willReturnSelf();
     $selectMock->expects($this->once())->method('group')->willReturnSelf();
     $selectMock->expects($this->once())->method('order')->willReturnSelf();
     $selectMock->expects($this->once())->method('insertFromSelect')->with($aggregationTable, $result)->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('select')->willReturn($selectMock);
     $this->helper->updateReportRatingPos($this->connectionMock, $type, $column, $mainTable, $aggregationTable);
 }
 public function testApply()
 {
     $filter = new Filter();
     $filter->setValue('test');
     $this->collectionAbstractDbMock->expects($this->any())->method('getMainTable')->willReturn('testTable');
     $this->collectionAbstractDbMock->expects($this->once())->method('getConnection')->willReturn($this->connectionMock);
     $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock);
     $this->connectionMock->expects($this->once())->method('getIndexList')->willReturn([['INDEX_TYPE' => 'FULLTEXT', 'COLUMNS_LIST' => ['col1', 'col2']]]);
     $this->selectMock->expects($this->once())->method('getPart')->willReturn([]);
     $this->selectMock->expects($this->once())->method('where')->willReturn(null);
     $this->collectionAbstractDbMock->expects($this->exactly(2))->method('getSelect')->willReturn($this->selectMock);
     $this->fulltextFilter->apply($this->collectionAbstractDbMock, $filter);
 }
 public function testFetchItem()
 {
     $data = [1 => 'test'];
     $statementMock = $this->getMock('Zend_Db_Statement_Pdo', ['fetch'], [], '', false);
     $statementMock->expects($this->once())->method('fetch')->will($this->returnValue($data));
     $this->connectionMock->expects($this->once())->method('query')->with($this->selectMock, $this->anything())->will($this->returnValue($statementMock));
     $objectMock = $this->getMock('Magento\\Framework\\Model\\AbstractModel', ['setData'], [], '', false);
     $objectMock->expects($this->once())->method('setData')->with($data);
     $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Review\\Model\\Review\\Summary')->will($this->returnValue($objectMock));
     $item = $this->collection->fetchItem();
     $this->assertEquals($objectMock, $item);
     $this->assertEquals('id', $item->getIdFieldName());
 }