From daa3a45ed8f1a8d86467407cf179964c50082186 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 30 Jun 2013 13:56:22 +0800 Subject: [PATCH] add UT from LDI --- test/classes/plugin/import/ImportLdi_test.php | 148 ++++++++++++++++++ test/test_data/db_test_ldi.csv | 1 + 2 files changed, 149 insertions(+) create mode 100644 test/classes/plugin/import/ImportLdi_test.php create mode 100644 test/test_data/db_test_ldi.csv diff --git a/test/classes/plugin/import/ImportLdi_test.php b/test/classes/plugin/import/ImportLdi_test.php new file mode 100644 index 0000000000..9a68cd191d --- /dev/null +++ b/test/classes/plugin/import/ImportLdi_test.php @@ -0,0 +1,148 @@ +object = new ImportLdi(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getProperties + * + * @return void + * + * @group medium + */ + public function testGetProperties() + { + $properties = $this->object->getProperties(); + $this->assertEquals( + __('CSV using LOAD DATA'), + $properties->getText() + ); + $this->assertEquals( + 'ldi', + $properties->getExtension() + ); + } + + /** + * Test for doImport + * + * @return void + * + * @group medium + */ + public function testDoImport() + { + //$sql_query_disabled will show the import SQL detail + global $sql_query, $sql_query_disabled; + $sql_query_disabled = false; + + //Mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + $GLOBALS['dbi'] = $dbi; + + //Test function called + $this->object->doImport(); + + //asset that all sql are executed + $this->assertContains( + "LOAD DATA INFILE 'test/test_data/db_test_ldi.csv' INTO TABLE `phpmyadmintest`", + $sql_query + ); + + $this->assertEquals( + true, + $GLOBALS['finished'] + ); + + } +} + + + diff --git a/test/test_data/db_test_ldi.csv b/test/test_data/db_test_ldi.csv new file mode 100644 index 0000000000..569b95c599 --- /dev/null +++ b/test/test_data/db_test_ldi.csv @@ -0,0 +1 @@ +"1","dbbase",,"ddd","SELECT * FROM `db_content` WHERE 1"