Example #1
0
 /**
  * @covers ::checkRedundantIndicesOnPrimaryKey
  */
 public function testCheckRedundantIndicesOnPrimaryKey()
 {
     /**
      * Column
      */
     $column = new Table\Column(['Field' => 'id', 'Type' => 'int(10) unsigned', 'Collation' => '', 'Null' => 'NO', 'Key' => 'PRI', 'Default' => '', 'Extra' => 'auto_increment']);
     $columns = new Table\ColumnCollection();
     $columns->add($column);
     /**
      * Indicies
      */
     $indices = new Table\IndexCollection();
     $indices->add(new Table\Index('PRIMARY', true, ['id']));
     $indices->add(new Table\Index('unique', true, ['id']));
     $indices->add(new Table\Index('key', false, ['id']));
     /**
      * Table
      */
     $table = new Table(null, null, new Table\ColumnCollection(), new Table\IndexCollection());
     $result = $table->checkRedundantIndicesOnPrimaryKey($columns, $indices);
     $expected = [['type' => 'index', 'key' => 'unique', 'description' => 'An unique index on the primary key column is redundant'], ['type' => 'index', 'key' => 'key', 'description' => 'An key index on the primary key column is redundant']];
     $this->assertSame($expected, $result);
 }