Annotation of embedaddon/php/ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: SQLite3::blobOpen test, testing stream with wrong parameter count
        !             3: --CREDITS--
        !             4: Michelangelo van Dam
        !             5: # Belgian PHP Testfest 2009
        !             6: --SKIPIF--
        !             7: <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
        !             8: --FILE--
        !             9: <?php
        !            10: class SQLite3_Test_Stream
        !            11: {
        !            12:        private $position;
        !            13:        public static $string_length = 10;
        !            14:        public static $string = "abcdefg\0hi";
        !            15: 
        !            16:        public function stream_open($path, $mode, $options, &$opened_path)
        !            17:        {
        !            18:                $this->position = 0;
        !            19:                return true;
        !            20:        }
        !            21: 
        !            22:        public function stream_read($count)
        !            23:        {
        !            24:                $ret = substr(self::$string, $this->position, $count);
        !            25:                $this->position += strlen($ret);
        !            26:                return $ret;
        !            27:        }
        !            28: 
        !            29:        public function stream_write($data)
        !            30:        {
        !            31:                return 0;
        !            32:        }
        !            33: 
        !            34:        public function stream_stat()
        !            35:        {
        !            36:                return array('size' => self::$string_length);
        !            37:        }
        !            38: 
        !            39:        public function stream_tell()
        !            40:        {
        !            41:                return $this->position;
        !            42:        }
        !            43: 
        !            44:        public function stream_eof()
        !            45:        {
        !            46:                return ($this->position >= self::$string_length);
        !            47:        }
        !            48: }
        !            49: 
        !            50: $db = new SQLite3(':memory:');
        !            51: stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream");
        !            52: echo "Creating table: " . var_export($db->exec('CREATE TABLE test (id STRING, data BLOB)'),true) . "\n";
        !            53: 
        !            54: echo "PREPARING insert\n";
        !            55: $insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (?, ?)");
        !            56: 
        !            57: echo "BINDING Parameters:\n";
        !            58: var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT));
        !            59: var_dump($insert_stmt->bindValue(2, 'TEST TEST', SQLITE3_BLOB));
        !            60: $insert_stmt->execute();
        !            61: echo "Closing statement: " . var_export($insert_stmt->close(), true) . "\n";
        !            62: 
        !            63: echo "Open BLOB with wrong parameter count\n";
        !            64: $stream = $db->openBlob();
        !            65: var_dump($stream);
        !            66: echo "Done\n";
        !            67: ?>
        !            68: --EXPECTF--
        !            69: Creating table: true
        !            70: PREPARING insert
        !            71: BINDING Parameters:
        !            72: bool(true)
        !            73: bool(true)
        !            74: Closing statement: true
        !            75: Open BLOB with wrong parameter count
        !            76: 
        !            77: Warning: SQLite3::openBlob() expects at least 3 parameters, 0 given in %s on line %d
        !            78: NULL
        !            79: Done

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