Annotation of embedaddon/php/ext/pdo_oci/tests/pdo_oci_stream_1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: PDO_OCI: stream_get_contents length & offset test
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
6: require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
7: if (!strpos(strtolower(getenv('PDOTEST_DSN')), 'charset=we8mswin1252')) die('skip expected output valid for WE8MSWIN1252 character set');
8: PDOTest::skip();
9: ?>
10: --FILE--
11: <?php
12:
13: require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc');
14:
15: $dbh = PDOTest::factory();
16:
17: $dbh->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
18:
19: // Initialization
20: @$dbh->exec("drop table pdo_oci_stream_1_tab");
21:
22: $stmtarray = array(
23: "create table pdo_oci_stream_1_tab (id number, data clob)",
24: );
25:
26: foreach ($stmtarray as $stmt) {
27: $dbh->exec($stmt);
28: }
29:
30: $dbh->exec("
31: declare
32: lob1 clob := 'abc' || lpad('j',30000,'j') || 'xyz';
33: begin
34: insert into pdo_oci_stream_1_tab (id,data) values (1, 'abcdefghijklmnopqrstuvwxyz');
35: insert into pdo_oci_stream_1_tab (id,data) values (2, lob1);
36: end;");
37:
38: echo "Test 1\n";
39:
40: $s = $dbh->prepare("select data from pdo_oci_stream_1_tab where id = 1");
41: $s->execute();
42: $r = $s->fetch();
43:
44: // stream_get_contents ( resource $handle [, int $maxlength = -1 [, int $offset = -1 ]] )
45: echo 'Read '.stream_get_contents($r['data'], 1, 1)."$\n"; // b
46: echo 'Read '.stream_get_contents($r['data'], 2, 1)."$\n"; // cd
47: echo 'Read '.stream_get_contents($r['data'], 2, 0)."$\n"; // ab
48: echo 'Read '.stream_get_contents($r['data'], 26, 0)."$\n"; // abcdefghijklmnopqrstuvwxyz
49: echo 'Read '.stream_get_contents($r['data'], 27, 0)."$\n"; // abcdefghijklmnopqrstuvwxyz
50: echo 'Read '.stream_get_contents($r['data'], 27, 1)."$\n"; // bcdefghijklmnopqrstuvwxyz
51: echo 'Read '.stream_get_contents($r['data'], 1, 20)."$\n"; // u
52: echo 'Read '.stream_get_contents($r['data'], 1, 25)."$\n"; // z
53: echo 'Read '.stream_get_contents($r['data'], 1, 26)."$\n"; // <blank>
54: echo 'Read '.stream_get_contents($r['data'], 1, 0)."$\n"; // a
55:
56: echo "\nTest 2\n";
57:
58: $s = $dbh->prepare("select data from pdo_oci_stream_1_tab where id = 2");
59: $s->execute();
60: $r = $s->fetch();
61:
62: echo 'Read '.stream_get_contents($r['data'], 5, 0)."\n"; // abcjj
63: echo 'Read '.stream_get_contents($r['data'], 5, 2)."\n"; // cjjjj
64: echo 'Read '.stream_get_contents($r['data'], 6, 1)."\n"; // bcjjjj
65: echo 'Read '.strlen(stream_get_contents($r['data'], -1,0))."\n"; // 30006
66: echo 'Read '.strlen(stream_get_contents($r['data'], 0,0))."\n"; // 0
67: echo 'Read '.strlen(stream_get_contents($r['data'], 0,1))."\n"; // 0
68: echo 'Read '.strlen(stream_get_contents($r['data'], 10,100))."\n"; // 10
69: echo 'Read '.stream_get_contents($r['data'], 6, 30000)."\n"; // jjjxyz
70: echo 'Read '.stream_get_contents($r['data'], 7, 30000)."\n"; // jjjxyz
71: echo 'Read '.strlen(stream_get_contents($r['data']))."\n"; // 0
72: echo 'Read '.strlen(stream_get_contents($r['data'], 0))."\n"; // 0
73: echo 'Read '.strlen(stream_get_contents($r['data'], -1))."\n"; // 0
74: echo 'Read '.stream_get_contents($r['data'], -1, 30000)."\n"; // jjjxyz
75:
76: // Clean up
77:
78: $stmtarray = array(
79: "drop table pdo_oci_stream_1_tab"
80: );
81:
82: foreach ($stmtarray as $stmt) {
83: $dbh->exec($stmt);
84: }
85:
86: ?>
87: --EXPECTF--
88: Test 1
89: Read b$
90: Read cd$
91: Read ab$
92: Read abcdefghijklmnopqrstuvwxyz$
93: Read abcdefghijklmnopqrstuvwxyz$
94: Read bcdefghijklmnopqrstuvwxyz$
95: Read u$
96: Read z$
97: Read $
98: Read a$
99:
100: Test 2
101: Read abcjj
102: Read cjjjj
103: Read bcjjjj
104: Read 30006
105: Read 0
106: Read 0
107: Read 10
108: Read jjjxyz
109: Read jjjxyz
110: Read 0
111: Read 0
112: Read 0
113: Read jjjxyz
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>