doImport() public method

Handles the whole import logic
public doImport ( &$sql_data = [] ) : void
return void
Example #1
0
 /**
  * Executes import of given file
  *
  * @param string $filename Name of test file
  *
  * @return void
  */
 protected function runImport($filename)
 {
     $GLOBALS['import_file'] = $filename;
     $GLOBALS['import_handle'] = new File($filename);
     $GLOBALS['import_handle']->setDecompressContent(true);
     $GLOBALS['import_handle']->open();
     $GLOBALS['message'] = '';
     $GLOBALS['error'] = false;
     $this->object->doImport();
     $this->assertEquals('', $GLOBALS['message']);
     $this->assertFalse($GLOBALS['error']);
 }
 /**
  * Test for doImport
  *
  * @return void
  *
  * @group medium
  */
 public function testDoImport()
 {
     //$sql_query_disabled will show the import SQL detail
     //$import_notice will show the import detail result
     global $import_notice, $sql_query, $sql_query_disabled;
     $sql_query_disabled = false;
     //Test function called
     $this->object->doImport();
     //asset that all sql are executed
     $this->assertContains('CREATE DATABASE IF NOT EXISTS `SHP_DB` DEFAULT CHARACTER ' . 'SET utf8 COLLATE utf8_general_ci', $sql_query);
     $this->assertContains('CREATE TABLE IF NOT EXISTS `SHP_DB`.`TBL_NAME` ' . '(`SPATIAL` geometry) DEFAULT CHARACTER ' . 'SET utf8 COLLATE utf8_general_ci;', $sql_query);
     $this->assertContains("INSERT INTO `SHP_DB`.`TBL_NAME` (`SPATIAL`) VALUES", $sql_query);
     $this->assertContains("GeomFromText('POINT(1294523.1759236", $sql_query);
     //asset that all databases and tables are imported
     $this->assertContains('The following structures have either been created or altered.', $import_notice);
     $this->assertContains('Go to database: `SHP_DB`', $import_notice);
     $this->assertContains('Edit settings for `SHP_DB`', $import_notice);
     $this->assertContains('Go to table: `TBL_NAME`', $import_notice);
     $this->assertContains('Edit settings for `TBL_NAME`', $import_notice);
     //asset that the import process is finished
     $this->assertEquals(true, $GLOBALS['finished']);
 }
Example #3
0
 /**
  * Executes import of given file
  *
  * @param string $filename Name of test file
  *
  * @return void
  */
 protected function runImport($filename)
 {
     $GLOBALS['import_file'] = $filename;
     $GLOBALS['import_handle'] = @fopen($filename, 'r');
     $this->object->doImport();
 }