public function testMoveWithExistentFlatTable() { $flatTable = 'flat_table'; $flatDropName = 'flat_table_to_drop'; $temporaryFlatTableName = 'flat_tmp'; $describedColumns = array('column_11' => 'column_definition', 'column_2' => 'column_definition', 'column_3' => 'column_definition'); $flatColumns = array('column_1' => 'column_definition', 'column_2' => 'column_definition', 'column_3' => 'column_definition'); $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', array(), array(), '', false); $selectMock->expects($this->once())->method('from')->with(array('tf' => sprintf('%s_tmp_indexer', $flatTable)), array('column_2', 'column_3')); $sql = md5(time()); $selectMock->expects($this->once())->method('insertFromSelect')->with($flatTable, array('column_2', 'column_3'))->will($this->returnValue($sql)); $this->_connectionMock->expects($this->once())->method('query')->with($sql); $this->_connectionMock->expects($this->once())->method('select')->will($this->returnValue($selectMock)); $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue(true)); $this->_connectionMock->expects($this->once())->method('describeTable')->with($flatTable)->will($this->returnValue($describedColumns)); $this->_productIndexerHelper->expects($this->once())->method('getFlatColumns')->will($this->returnValue($flatColumns)); $this->_connectionMock->expects($this->once())->method('dropTable')->with(sprintf('%s_tmp_indexer', $flatTable)); $this->_resourceMock->expects($this->any())->method('getConnection')->with('write')->will($this->returnValue($this->_connectionMock)); $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\Action\\Rows\\TableData', array('resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper)); $model->move($flatTable, $flatDropName, $temporaryFlatTableName); }