34 $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
35 $this->_connectionMock = $this->createMock(\
Magento\Framework\DB\Adapter\AdapterInterface::class);
36 $this->_resourceMock = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
37 $this->_productIndexerHelper = $this->createMock(\
Magento\Catalog\
Helper\
Product\Flat\Indexer::class);
42 $flatTable =
'flat_table';
43 $flatDropName =
'flat_table_to_drop';
44 $temporaryFlatTableName =
'flat_tmp';
46 $this->_connectionMock->expects($this->exactly(2))->method(
'dropTable')->with($flatDropName);
47 $this->_connectionMock->expects(
54 $this->returnValue(
false)
57 $this->_connectionMock->expects(
62 [[
'oldName' =>
'flat_tmp',
'newName' =>
'flat_table']]
65 $this->_resourceMock->expects(
70 $this->returnValue($this->_connectionMock)
73 $model = $this->_objectManager->getObject(
75 [
'resource' => $this->_resourceMock,
'productIndexerHelper' => $this->_productIndexerHelper]
78 $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
83 $flatTable =
'flat_table';
84 $flatDropName =
'flat_table_to_drop';
85 $temporaryFlatTableName =
'flat_tmp';
88 'column_11' =>
'column_definition',
89 'column_2' =>
'column_definition',
90 'column_3' =>
'column_definition',
94 'column_1' =>
'column_definition',
95 'column_2' =>
'column_definition',
96 'column_3' =>
'column_definition',
99 $selectMock = $this->createMock(\
Magento\Framework\DB\Select::class);
100 $selectMock->expects(
105 [
'tf' => sprintf(
'%s_tmp_indexer', $flatTable)],
106 [
'column_2',
'column_3']
109 $selectMock->expects(
115 [
'column_2',
'column_3']
117 $this->returnValue($sql)
120 $this->_connectionMock->expects($this->once())->method(
'query')->with($sql);
122 $this->_connectionMock->expects($this->once())->method(
'select')->will($this->returnValue($selectMock));
124 $this->_connectionMock->expects(
131 $this->returnValue(
true)
134 $this->_connectionMock->expects(
141 $this->returnValue($describedColumns)
144 $this->_productIndexerHelper->expects(
149 $this->returnValue($flatColumns)
152 $this->_connectionMock->expects(
157 sprintf(
'%s_tmp_indexer', $flatTable)
160 $this->_resourceMock->expects(
165 $this->returnValue($this->_connectionMock)
168 $model = $this->_objectManager->getObject(
170 [
'resource' => $this->_resourceMock,
'productIndexerHelper' => $this->_productIndexerHelper]
173 $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
testMoveWithNonExistentFlatTable()
testMoveWithExistentFlatTable()