diff --git a/test/classes/PMA_Index_test.php b/test/classes/PMA_Index_test.php index 153264ec86..3a683453db 100644 --- a/test/classes/PMA_Index_test.php +++ b/test/classes/PMA_Index_test.php @@ -35,6 +35,14 @@ class PMA_Index_Test extends PHPUnit_Framework_TestCase $this->_params['Index_comment'] = "PMA_Index_comment"; $this->_params['Non_unique'] = "PMA_Non_unique"; $this->_params['Packed'] = "PMA_Packed"; + + //test add columns + $column1 = array("Column_name"=>"column1","Seq_in_index"=>"index1"); + $column2 = array("Column_name"=>"column2","Seq_in_index"=>"index2"); + $column3 = array("Column_name"=>"column3","Seq_in_index"=>"index3"); + $this->_params['columns'][] = $column1; + $this->_params['columns'][] = $column2; + $this->_params['columns'][] = $column3; } /** @@ -66,4 +74,44 @@ class PMA_Index_Test extends PHPUnit_Framework_TestCase $index->getNonUnique() ); } + + /** + * Test for add Columns + * + * @return void + */ + public function testAddColumns() + { + $index = new PMA_Index(); + $index->addColumns($this->_params['columns']); + $this->assertTrue($index->hasColumn("column1")); + $this->assertTrue($index->hasColumn("column2")); + $this->assertTrue($index->hasColumn("column3")); + $this->assertEquals( + 3, + $index->getColumnCount() + ); + } + + /** + * Test for PMA_Index_Column + * + * @return void + */ + public function testPMA_Index_Column() + { + $index = new PMA_Index(); + $index->addColumns($this->_params['columns']); + + $index_columns = $index->getColumns(); + $index_column = $index_columns['column1']; + $this->assertEquals( + 'column1', + $index_column->getName() + ); + $this->assertEquals( + 'index1', + $index_column->getSeqInIndex() + ); + } }