xref: /php-src/ext/sqlite3/tests/stream_test.inc (revision 902d6439)
1<?php
2
3class SQLite3_Test_Stream
4{
5    public $context;
6    private $position;
7    public static $string_length = 10;
8    public static $string = "abcdefg\0hi";
9
10    public function stream_open($path, $mode, $options, &$opened_path)
11    {
12        $this->position = 0;
13        return true;
14    }
15
16    public function stream_read($count)
17    {
18        $ret = substr(self::$string, $this->position, $count);
19        $this->position += strlen($ret);
20        return $ret;
21    }
22
23    public function stream_write($data)
24    {
25        return 0;
26    }
27
28    public function stream_stat()
29    {
30        return array('size' => self::$string_length);
31    }
32
33    public function stream_tell()
34    {
35        return $this->position;
36    }
37
38    public function stream_eof()
39    {
40        return ($this->position >= self::$string_length);
41    }
42}
43
44stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream");
45
46?>
47