xref: /PHP-8.1/ext/oci8/tests/coll_018.phpt (revision b5a14e6c)
1--TEST--
2Collection trim tests
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require __DIR__."/connect.inc";
14require __DIR__."/create_type.inc";
15
16$coll1 = oci_new_collection($c, $type_name);
17
18echo "\nTest 2.\n";
19var_dump($coll1->trim(0));
20
21echo "\nTest 3.\n";
22var_dump($coll1->append(1));
23var_dump($coll1->append(2));
24var_dump($coll1->append(3));
25var_dump($coll1->append(4));
26
27var_dump($coll1->getElem(-1));  // check before the beginning
28var_dump($coll1->getElem(0));
29var_dump($coll1->getElem(1));
30var_dump($coll1->getElem(2));
31var_dump($coll1->getElem(3));
32var_dump($coll1->getElem(4));  // check past the end
33
34echo "\nTest 4.\n";
35var_dump($coll1->trim(1));
36var_dump($coll1->getElem(2));  // this should be the last element
37var_dump($coll1->getElem(3));  // this element should have gone
38
39echo "\nTest 5.\n";
40var_dump($coll1->trim(2));
41var_dump($coll1->getElem(0));  // this should be the last element
42var_dump($coll1->getElem(1));  // this element should have gone
43
44echo "\nTest 6.\n";
45var_dump($coll1->trim(0));
46var_dump($coll1->getElem(0));  // this should still be the last element
47
48echo "\nTest 7.\n";
49var_dump($coll1->trim(1));
50var_dump($coll1->getElem(0));  // this should have gone
51
52echo "Done\n";
53
54require __DIR__."/drop_type.inc";
55
56?>
57--EXPECT--
58Test 2.
59bool(true)
60
61Test 3.
62bool(true)
63bool(true)
64bool(true)
65bool(true)
66bool(false)
67float(1)
68float(2)
69float(3)
70float(4)
71bool(false)
72
73Test 4.
74bool(true)
75float(3)
76bool(false)
77
78Test 5.
79bool(true)
80float(1)
81bool(false)
82
83Test 6.
84bool(true)
85float(1)
86
87Test 7.
88bool(true)
89bool(false)
90Done
91