public/phpmyadmin/test/classes/Dbi/DbiMysqliTest.php
/**
     * Test for mysqli related functions, using runkit_function_redefine
     *
     * @return void
     *
     * @group medium
     */
Test for mysqli related functions, using runkit_function_redefine
@return void

@group medium
Test for mysqli related functions using runkit_function_redefine @return void @group medium
public function testMysqliDBI()
    {
        if (! PMA_HAS_RUNKIT) {
            $this->markTestSkipped("Cannot redefine function");
        }
        runkit_function_redefine(
            'mysqli_real_connect', '', 'return "mysqli_real_connect";'
        );
        runkit_function_redefine('mysqli_init', '', 'return "mysqli_init";');
        runkit_function_redefine('mysqli_options', '', 'return "mysqli_options";');
        runkit_function_redefine('mysqli_query', '', 'return "mysqli_query";');
        runkit_function_redefine(
            'mysqli_multi_query', '', 'return "mysqli_multi_query";'
        );
        runkit_function_redefine(
            'mysqli_fetch_array', '', 'return "mysqli_fetch_array";'
        );
        runkit_function_redefine(
            'mysqli_data_seek', '', 'return "mysqli_data_seek";'
        );
        runkit_function_redefine(
            'mysqli_more_results', '', 'return "mysqli_more_results";'
        );
        runkit_function_redefine(
            'mysqli_next_result', '', 'return "mysqli_next_result";'
        );
        runkit_function_redefine(
            'mysqli_get_host_info', '', 'return "mysqli_get_host_info";'
        );
        runkit_function_redefine(
            'mysqli_get_proto_info', '', 'return "mysqli_get_proto_info";'
        );
        runkit_function_redefine(
            'mysqli_get_client_info', '', 'return "mysqli_get_client_info";'
        );
        $user = 'PMA_user';
        $password = 'PMA_password';
        $server = array(
            'port' => 8080,
            'socket' => 123,
            'host' => 'locahost',
            'compress' => false,
            'ssl' => false,
        );
        $ret = $this->object->connect(
            $user, $password, $server
        );
        $this->assertEquals(
            'mysqli_init',
            $ret
        );
        $query = 'select * from DBI';
        $link = $ret;
        $options = 0;
        $ret = $this->object->realQuery($query, $link, $options);
        $this->assertEquals(
            'mysqli_query',
            $ret
        );
        $ret = $this->object->realMultiQuery($link, $query);
        $this->assertEquals(
            'mysqli_multi_query',
            $ret
        );
        $result = $ret;
        $ret = $this->object->fetchArray($result);
        $this->assertEquals(
            'mysqli_fetch_array',
            $ret
        );
        $result = $ret;
        $ret = $this->object->fetchAssoc($result);
        $this->assertEquals(
            'mysqli_fetch_array',
            $ret
        );
        $result = $ret;
        $ret = $this->object->fetchRow($result);
        $this->assertEquals(
            'mysqli_fetch_array',
            $ret
        );
        $result = $ret;
        $offset = 10;
        $ret = $this->object->dataSeek($result, $offset);
        $this->assertEquals(
            'mysqli_data_seek',
            $ret
        );
        $link = $ret;
        $ret = $this->object->moreResults($link);
        $this->assertEquals(
            'mysqli_more_results',
            $ret
        );
        $link = $ret;
        $ret = $this->object->nextResult($link);
        $this->assertEquals(
            'mysqli_next_result',
            $ret
        );
        $link = $ret;
        $ret = $this->object->getHostInfo($link);
        $this->assertEquals(
            'mysqli_get_host_info',
            $ret
        );
        $link = $ret;
        $ret = $this->object->getProtoInfo($link);
        $this->assertEquals(
            'mysqli_get_proto_info',
            $ret
        );
        $ret = $this->object->getClientInfo();
        $this->assertEquals(
            'mysqli_get_client_info',
            $ret
        );
    }
public function testMysqliDBI ( ) { if ( ! PMA_HAS_RUNKIT ) { $ this -> markTestSkipped ( " Cannot redefine function " ) ; } runkit_function_redefine ( 'mysqli_real_connect' , '' , 'return "mysqli_real_connect";' ) ; runkit_function_redefine ( 'mysqli_init' , '' , 'return "mysqli_init";' ) ; runkit_function_redefine ( 'mysqli_options' , '' , 'return "mysqli_options";' ) ; runkit_function_redefine ( 'mysqli_query' , '' , 'return "mysqli_query";' ) ; runkit_function_redefine ( 'mysqli_multi_query' , '' , 'return "mysqli_multi_query";' ) ; runkit_function_redefine ( 'mysqli_fetch_array' , '' , 'return "mysqli_fetch_array";' ) ; runkit_function_redefine ( 'mysqli_data_seek' , '' , 'return "mysqli_data_seek";' ) ; runkit_function_redefine ( 'mysqli_more_results' , '' , 'return "mysqli_more_results";' ) ; runkit_function_redefine ( 'mysqli_next_result' , '' , 'return "mysqli_next_result";' ) ; runkit_function_redefine ( 'mysqli_get_host_info' , '' , 'return "mysqli_get_host_info";' ) ; runkit_function_redefine ( 'mysqli_get_proto_info' , '' , 'return "mysqli_get_proto_info";' ) ; runkit_function_redefine ( 'mysqli_get_client_info' , '' , 'return "mysqli_get_client_info";' ) ; $ user = 'PMA_user' ; $ password = 'PMA_password' ; $ server = array ( 'port' => 8080 , 'socket' => 123 , 'host' => 'locahost' , 'compress' => false , 'ssl' => false , ) ; $ ret = $ this -> object -> connect ( $ user , $ password , $ server ) ; $ this -> assertEquals ( 'mysqli_init' , $ ret ) ; $ query = 'select * from DBI' ; $ link = $ ret ; $ options = 0 ; $ ret = $ this -> object -> realQuery ( $ query , $ link , $ options ) ; $ this -> assertEquals ( 'mysqli_query' , $ ret ) ; $ ret = $ this -> object -> realMultiQuery ( $ link , $ query ) ; $ this -> assertEquals ( 'mysqli_multi_query' , $ ret ) ; $ result = $ ret ; $ ret = $ this -> object -> fetchArray ( $ result ) ; $ this -> assertEquals ( 'mysqli_fetch_array' , $ ret ) ; $ result = $ ret ; $ ret = $ this -> object -> fetchAssoc ( $ result ) ; $ this -> assertEquals ( 'mysqli_fetch_array' , $ ret ) ; $ result = $ ret ; $ ret = $ this -> object -> fetchRow ( $ result ) ; $ this -> assertEquals ( 'mysqli_fetch_array' , $ ret ) ; $ result = $ ret ; $ offset = 10 ; $ ret = $ this -> object -> dataSeek ( $ result , $ offset ) ; $ this -> assertEquals ( 'mysqli_data_seek' , $ ret ) ; $ link = $ ret ; $ ret = $ this -> object -> moreResults ( $ link ) ; $ this -> assertEquals ( 'mysqli_more_results' , $ ret ) ; $ link = $ ret ; $ ret = $ this -> object -> nextResult ( $ link ) ; $ this -> assertEquals ( 'mysqli_next_result' , $ ret ) ; $ link = $ ret ; $ ret = $ this -> object -> getHostInfo ( $ link ) ; $ this -> assertEquals ( 'mysqli_get_host_info' , $ ret ) ; $ link = $ ret ; $ ret = $ this -> object -> getProtoInfo ( $ link ) ; $ this -> assertEquals ( 'mysqli_get_proto_info' , $ ret ) ; $ ret = $ this -> object -> getClientInfo ( ) ; $ this -> assertEquals ( 'mysqli_get_client_info' , $ ret ) ; }
Test for mysqli related functions, using runkit_function_redefine
 @return void
Test for mysqli related functions using runkit_function_redefine @return void
//FOR UT, we just test the right mysql client API is called //test for connect //test for realQuery //test for realMultiQuery //test for fetchArray //test for fetchAssoc //test for fetchRow //test for dataSeek //test for moreResults //test for nextResult //test for getHostInfo //test for getProtoInfo //test for getClientInfo