668d9b197349e5484761dfb7376056c08a90384d
[phpyaz-moved-to-github.git] / tests / cql.phpt
1 --TEST--
2 cql
3 --SKIPIF--
4 <?php if (!extension_loaded("yaz") || !function_exists("yaz_cql_parse")) print "skip"; ?>
5 --FILE--
6 <?php
7 $z = yaz_connect("bogus");
8 if (yaz_cql_parse($z, "computer", $res, false)) {
9    echo $res['rpn'] . "\n";
10 } else {
11    echo $res['errorcode'] . "\n";
12 }
13 yaz_cql_conf($z, array(
14  "set.cql" => "info:srw/cql-context-set/1/cql-v1.2",
15  "index.cql.serverChoice" => "1=1016",
16  "relation.eq" => "3=3",
17  "structure.*" => "4=1",
18  "position.any" => "6=1"
19  ));
20 if (yaz_cql_parse($z, "computer", $res, false)) {
21    echo $res['rpn'] . "\n";
22 } else {
23    echo $res['errorcode'] . "\n";
24 }
25 if (yaz_cql_parse($z, "computer and", $res, true)) {
26    echo $res['cql'] . "\n";
27 } else {
28    echo $res['errorcode'] . "\n";
29 }
30 if (yaz_cql_parse($z, "computer", $res, true)) {
31    echo $res['cql'] . "\n";
32 } else {
33    echo $res['errorcode'] . "\n";
34 }
35 if (yaz_cql_parse($z, "@and a @attr 1=1016 b", $res, true)) {
36    echo $res['cql'] . "\n";
37 } else {
38    echo $res['errorcode'] . "\n";
39 }
40 if (yaz_cql_parse($z, "@and a", $res, true)) {
41    echo $res['cql'] . "\n";
42 } else {
43    echo $res['errorcode'] . "\n";
44 }
45 --EXPECT--
46 15
47 @attr 3=3 @attr 4=1 @attr 6=1 @attr 1=1016 "computer"
48 0
49 computer
50 a and b
51 0