From 739b048bbb5913a02faa87b92423cced81976e6e Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Thu, 23 May 2013 23:54:05 +0800 Subject: [PATCH 1/2] add test case for PMA_Index_test --- test/classes/PMA_Index_test.php | 69 +++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/test/classes/PMA_Index_test.php b/test/classes/PMA_Index_test.php index fd50b56ca3..c3f900a467 100644 --- a/test/classes/PMA_Index_test.php +++ b/test/classes/PMA_Index_test.php @@ -33,7 +33,7 @@ class PMA_Index_Test extends PHPUnit_Framework_TestCase $this->_params['Index_type'] = "PMA_Index_type"; $this->_params['Comment'] = "PMA_Comment"; $this->_params['Index_comment'] = "PMA_Index_comment"; - $this->_params['Non_unique'] = "PMA_Non_unique"; + $this->_params['Non_unique'] = "0"; $this->_params['Packed'] = "PMA_Packed"; //test add columns @@ -79,7 +79,7 @@ class PMA_Index_Test extends PHPUnit_Framework_TestCase $index->getPacked() ); $this->assertEquals( - 'PMA_Non_unique', + '0', $index->getNonUnique() ); $this->assertContains( @@ -96,7 +96,70 @@ class PMA_Index_Test extends PHPUnit_Framework_TestCase ); } - + + /** + * Test for singleton + * + * @return void + */ + public function testSingleton() + { + $index = PMA_Index::singleton("pma_database", "pma_table", "pma_index"); + $this->assertEquals( + 'pma_index', + $index->getName() + ); + } + + /** + * Test for getIndexChoices + * + * @return void + */ + public function testGetIndexChoices() + { + $index_choices = PMA_Index::getIndexChoices(); + $this->assertEquals( + 5, + count($index_choices) + ); + $this->assertEquals( + 'PRIMARY,INDEX,UNIQUE,SPATIAL,FULLTEXT', + implode(",", $index_choices) + ); + } + + /** + * Test for generateIndexSelector + * + * @return void + */ + public function testGenerateIndexSelector() + { + $index = new PMA_Index($this->_params); + $this->assertContains( + '