Annotation of embedaddon/php/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: mysqli_set_local_infile_handler() - do not use the file pointer
        !             3: --SKIPIF--
        !             4: <?php
        !             5: require_once('skipif.inc');
        !             6: require_once('skipifemb.inc');
        !             7: require_once('skipifconnectfailure.inc');
        !             8: 
        !             9: if (!function_exists('mysqli_set_local_infile_handler'))
        !            10:        die("skip - function not available.");
        !            11: 
        !            12: require_once('connect.inc');
        !            13: if (!$TEST_EXPERIMENTAL)
        !            14:        die("skip - experimental (= unsupported) feature");
        !            15: 
        !            16: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        !            17:        die("skip Cannot connect to MySQL");
        !            18: 
        !            19: include_once("local_infile_tools.inc");
        !            20: if ($msg = check_local_infile_support($link, $engine))
        !            21:        die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
        !            22: 
        !            23: mysqli_close($link);
        !            24: ?>
        !            25: --INI--
        !            26: mysqli.allow_local_infile=1
        !            27: --FILE--
        !            28: <?php
        !            29:        require_once("table.inc");
        !            30:        require_once('local_infile_tools.inc');
        !            31: 
        !            32:        function callback_closefile($fp, &$buffer, $buflen, &$error) {
        !            33:                static $invocation = 0;
        !            34: 
        !            35:                printf("Callback: %d\n", $invocation++);
        !            36:                flush();
        !            37:                if (is_resource($fp))
        !            38:                        fclose($fp);
        !            39:                $buffer = "1;'a';\n";
        !            40:                if ($invocation > 10)
        !            41:                        return 0;
        !            42: 
        !            43:                return strlen($buffer);
        !            44:        }
        !            45: 
        !            46:        $file = create_standard_csv(1);
        !            47:        $expected = array(array('id' => 1, 'label' => 'a'));
        !            48:        try_handler(20, $link, $file, 'callback_closefile', $expected);
        !            49: 
        !            50:        mysqli_close($link);
        !            51:        print "done!";
        !            52: ?>
        !            53: --CLEAN--
        !            54: <?php
        !            55:        require_once("clean_table.inc");
        !            56: ?>
        !            57: --EXPECTF--
        !            58: Callback set to 'callback_closefile'
        !            59: Callback: 0
        !            60: Callback: 1
        !            61: Callback: 2
        !            62: Callback: 3
        !            63: Callback: 4
        !            64: Callback: 5
        !            65: Callback: 6
        !            66: Callback: 7
        !            67: Callback: 8
        !            68: Callback: 9
        !            69: Callback: 10
        !            70: done!

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>