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