!C99Shell v.2.1 [PHP 7 Update] [1.12.2019]!

Software: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16. PHP/5.4.16 

uname -a: Linux roko-bkp 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 

uid=48(apache) gid=48(apache) groups=48(apache),1003(webmaster) 

Safe-mode: OFF (not secure)

/usr/share/phpMyAdmin/test/classes/plugin/import/   drwxr-xr-x
Free 8.86 GB of 93.48 GB (9.48%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ImportLdi_test.php (6.89 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
 * Tests for ImportLdi class
 *
 * @package PhpMyAdmin-test
 */

/*
 * we must set $GLOBALS['server'] here
 * since 'check_user_privileges.lib.php' will use it globally
 */
$GLOBALS['server'] = 0;
$GLOBALS['plugin_param'] = "table";

/*
 * Include to test.
 */
require_once 'libraries/Util.class.php';
require_once 
'libraries/Message.class.php';
require_once 
'libraries/sanitizing.lib.php';
require_once 
'libraries/url_generating.lib.php';
require_once 
'libraries/php-gettext/gettext.inc';
require_once 
'libraries/Table.class.php';
require_once 
'libraries/Tracker.class.php';
require_once 
'libraries/database_interface.inc.php';
require_once 
'libraries/import.lib.php';
require_once 
'libraries/plugins/import/ImportLdi.class.php';


/**
 * Tests for ImportLdi class
 *
 * @package PhpMyAdmin-test
 */
class ImportLdi_Test extends PHPUnit_Framework_TestCase
{
    
/**
     * @access protected
     */
    
protected $object;

    
/**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     *
     * @access protected
     * @return void
     */
    
protected function setUp()
    {
        
//setting
        
$GLOBALS['finished'] = false;
        
$GLOBALS['read_limit'] = 100000000;
        
$GLOBALS['offset'] = 0;
        
$GLOBALS['cfg']['Server']['DisableIS'] = false;
        
$GLOBALS['cfg']['ServerDefault'] = 0;
        
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;

        
$GLOBALS['import_file'] = 'test/test_data/db_test_ldi.csv';
        
$GLOBALS['import_text'] = 'ImportLdi_Test';
        
$GLOBALS['compression'] = 'none';
        
$GLOBALS['read_multiply'] = 10;
        
$GLOBALS['import_type'] = 'csv';
        
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');

        
//setting for Ldi
        
$GLOBALS['cfg']['Import']['ldi_replace'] = false;
        
$GLOBALS['cfg']['Import']['ldi_ignore'] = false;
        
$GLOBALS['cfg']['Import']['ldi_terminated'] = ';';
        
$GLOBALS['cfg']['Import']['ldi_enclosed'] = '"';
        
$GLOBALS['cfg']['Import']['ldi_escaped'] = '\\';
        
$GLOBALS['cfg']['Import']['ldi_new_line'] = 'auto';
        
$GLOBALS['cfg']['Import']['ldi_columns'] = '';
        
$GLOBALS['cfg']['Import']['ldi_local_option'] = false;
        
$GLOBALS['table'] = "phpmyadmintest";

        
//Mock DBI
        
$dbi $this->getMockBuilder('PMA_DatabaseInterface')
            ->
disableOriginalConstructor()
            ->
getMock();

        
$dbi->expects($this->any())->method('tryQuery')
            ->
will($this->returnValue(true));

        
$dbi->expects($this->any())->method('numRows')
            ->
will($this->returnValue(10));

        
$fetchRowResult = array(
            
"PMA_row",
            
"ON"
        
);

        
$dbi->expects($this->any())->method('fetchRow')
            ->
will($this->returnValue($fetchRowResult));

        
$GLOBALS['dbi'] = $dbi;

        
$this->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 getProperties for ldi_local_option = auto
     *
     * @return void
     *
     * @group medium
     */
    
public function testGetPropertiesAutoLdi()
    {
        
$GLOBALS['cfg']['Import']['ldi_local_option'] = 'auto';
        
$this->object = new ImportLdi();
        
$properties $this->object->getProperties();
        
$this->assertEquals(
            
true,
            
$GLOBALS['cfg']['Import']['ldi_local_option']
        );
        
$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;

        
//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']
        );
    }

    
/**
     * Test for doImport : invalid import file
     *
     * @return void
     *
     * @group medium
     */
    
public function testDoImportInvalidFile()
    {
        global 
$import_file;
        
$import_file 'none';

        
//Test function called
        
$this->object->doImport();

        
// We handle only some kind of data!
        
$this->assertContains(
            
__('This plugin does not support compressed imports!'),
            
$GLOBALS['message']->__toString()
        );

        
$this->assertEquals(
            
true,
            
$GLOBALS['error']
        );
    }

    
/**
     * Test for doImport with LDI setting
     *
     * @return void
     *
     * @group medium
     */
    
public function testDoImportLDISetting()
    {
        global 
$ldi_local_option$ldi_replace$ldi_ignore$ldi_terminated,
        
$ldi_enclosed$ldi_new_line$skip_queries;

        
//$sql_query_disabled will show the import SQL detail
        
global $sql_query$sql_query_disabled;
        
$sql_query_disabled false;

        
$ldi_local_option true;
        
$ldi_replace true;
        
$ldi_ignore true;
        
$ldi_terminated ',';
        
$ldi_enclosed ')';
        
$ldi_new_line 'newline_mark';
        
$skip_queries true;

        
//Test function called
        
$this->object->doImport();

        
//asset that all sql are executed
        //replace
        
$this->assertContains(
            
"LOAD DATA LOCAL INFILE 'test/test_data/db_test_ldi.csv' REPLACE INTO "
            
"TABLE `phpmyadmintest`",
            
$sql_query
        
);

        
//FIELDS TERMINATED
        
$this->assertContains(
            
"FIELDS TERMINATED BY ','",
            
$sql_query
        
);

        
//LINES TERMINATED
        
$this->assertContains(
            
"LINES TERMINATED BY 'newline_mark'",
            
$sql_query
        
);

        
//IGNORE
        
$this->assertContains(
            
"IGNORE 1 LINES",
            
$sql_query
        
);

        
$this->assertEquals(
            
true,
            
$GLOBALS['finished']
        );
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v.2.1 [PHP 7 Update] [1.12.2019] maintained by KaizenLouie and updated by cermmik | C99Shell Github (MySQL update) | Generation time: 0.0041 ]--