34 protected function setUp()
38 \
Magento\Framework\Setup\ModuleDataSetupInterface::class
40 $this->_connection =
$installer->getConnection();
41 $this->_tableName = $this->_connection->getTableName(
'table_two_column_idx');
42 $this->_oneColumnIdxName = $this->_connection->getIndexName($this->_tableName, [
'column1']);
43 $this->_twoColumnIdxName = $this->_connection->getIndexName($this->_tableName, [
'column1',
'column2']);
45 $table = $this->_connection->newTable(
51 [
'identity' =>
true,
'unsigned' =>
true,
'nullable' =>
false,
'primary' =>
true],
60 $this->_oneColumnIdxName,
63 $this->_twoColumnIdxName,
64 [
'column1',
'column2']
66 $this->_connection->createTable(
$table);
74 $this->_connection->dropTable($this->_tableName);
75 $this->_connection->resetDdlCache($this->_tableName);
76 $this->_connection =
null;
82 $this->_connection->tableColumnExists($this->_tableName,
'column1'),
83 'Table column "column1" must be provided by the fixture.' 86 $this->_connection->tableColumnExists($this->_tableName,
'column2'),
87 'Table column "column2" must be provided by the fixture.' 92 'Single-column index must be provided by the fixture.' 95 [
'column1',
'column2'],
97 'Multiple-column index must be provided by the fixture.' 111 foreach ($this->_connection->getIndexList(
$tableName, $schemaName) as $idxData) {
112 if ($idxData[
'KEY_NAME'] == $indexName) {
113 return $idxData[
'COLUMNS_LIST'];
121 $this->_connection->dropColumn($this->_tableName,
'column1');
123 $this->_connection->tableColumnExists($this->_tableName,
'column1'),
124 'Table column must not exist after it has been dropped.' 133 $this->_connection->dropColumn($this->_tableName,
'column1');
136 'Column index must be dropped along with the column.' 141 'References to the dropped column must be removed from the multiple-column indexes.' 150 $this->_connection->dropColumn($this->_tableName,
'column2');
154 'Column index must be preserved.' 158 'Multiple-column index must be dropped to not duplicate existing index by indexed columns.' 170 $this->_connection->insertArray($this->_tableName,
$columns,
$data);
171 $select = $this->_connection->select()->from($this->_tableName, array_keys($expected[0]))->order(
'column1');
173 $this->assertEquals($expected,
$result);
187 [[
'column1' => 1,
'column2' =>
null], [
'column1' => 2,
'column2' =>
null]],
189 'one column simple' => [
192 [[
'column1' => 1,
'column2' =>
null], [
'column1' => 2,
'column2' =>
null]],
195 [
'column1',
'column2'],
197 [[
'column1' => 1,
'column2' => 2], [
'column1' => 3,
'column2' => 4]],
199 'several columns with identity' => [
200 [
'id',
'column1',
'column2'],
201 [[1, 0, 0], [2, 1, 1], [3, 2, 2]],
203 [
'id' => 1,
'column1' => 0,
'column2' => 0],
204 [
'id' => 2,
'column1' => 1,
'column2' => 1],
205 [
'id' => 3,
'column1' => 2,
'column2' => 2]
216 $this->_connection->insertArray($this->_tableName, [
'column1',
'column2'], [1, 2]);
224 $this->_connection->insertMultiple($this->_tableName,
$data);
226 $select = $this->_connection->select()->from($this->_tableName);
237 $this->_connection->insertOnDuplicate($this->_tableName,
$data);
239 $select = $this->_connection->select()->from($this->_tableName);
250 $this->assertEquals(1, $this->_connection->insertForce($this->_tableName,
$data));
252 $select = $this->_connection->select()->from($this->_tableName);
265 return [
'column with identity field' => [[
'id' => 1,
'column1' => 10,
'column2' => 20]]];
insertArrayDataProvider()
_getIndexColumns($tableName, $indexName, $schemaName=null)
testDropColumnRemoveIndexDuplicate()
testInsertOnDuplicate($data)
testInsertArrayTwoColumnsWithSimpleData()
testInsertMultiple($data)
testInsertArray(array $columns, array $data, array $expected)
testDropColumnRemoveFromIndexes()
static getObjectManager()