thomascube
2012-03-31 48e9c14ebded89d858c8be0333f77f77a81b0877
commit | author | age
48e9c1 1 --TEST--
T 2 Main test of script parser
3 --SKIPIF--
4 --FILE--
5 <?php
6 include '../lib/rcube_sieve_script.php';
7
8 $txt = '
9 require ["fileinto","reject","envelope"];
10 # rule:[spam]
11 if anyof (header :contains "X-DSPAM-Result" "Spam")
12 {
13     fileinto "Spam";
14     stop;
15 }
16 # rule:[test1]
17 if anyof (header :comparator "i;ascii-casemap" :contains ["From","To"] "test@domain.tld")
18 {
19     discard;
20     stop;
21 }
22 # rule:[test2]
23 if anyof (not header :comparator "i;octet" :contains ["Subject"] "[test]", header :contains "Subject" "[test2]")
24 {
25     fileinto "test";
26     stop;
27 }
28 # rule:[comments]
29 if anyof (true) /* comment
30  * "comment" #comment */ {
31     /* comment */ stop;
32 # comment
33 }
34 # rule:[reject]
35 if size :over 5000K {
36     reject "Message over 5MB size limit. Please contact me before sending this.";
37 }
38 # rule:[false]
39 if false # size :over 5000K
40 {
41     stop; /* rule disabled */
42 }
43 # rule:[true]
44 if true
45 {
46     stop;
47 }
48 fileinto "Test";
49 # rule:[address test]
50 if address :all :is "From" "nagios@domain.tld"
51 {
52     fileinto "domain.tld";
53     stop;
54 }
55 # rule:[envelope test]
56 if envelope :domain :is "From" "domain.tld"
57 {
58     fileinto "domain.tld";
59     stop;
60 }
61 ';
62
63 $s = new rcube_sieve_script($txt);
64 echo $s->as_text();
65
66 // -------------------------------------------------------------------------------
67 ?>
68 --EXPECT--
69 require ["fileinto","reject","envelope"];
70 # rule:[spam]
71 if header :contains "X-DSPAM-Result" "Spam"
72 {
73     fileinto "Spam";
74     stop;
75 }
76 # rule:[test1]
77 if header :contains ["From","To"] "test@domain.tld"
78 {
79     discard;
80     stop;
81 }
82 # rule:[test2]
83 if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]")
84 {
85     fileinto "test";
86     stop;
87 }
88 # rule:[comments]
89 if true
90 {
91     stop;
92 }
93 # rule:[reject]
94 if size :over 5000K
95 {
96     reject "Message over 5MB size limit. Please contact me before sending this.";
97 }
98 # rule:[false]
99 if false # size :over 5000K
100 {
101     stop;
102 }
103 # rule:[true]
104 if true
105 {
106     stop;
107 }
108 fileinto "Test";
109 # rule:[address test]
110 if address :all :is "From" "nagios@domain.tld"
111 {
112     fileinto "domain.tld";
113     stop;
114 }
115 # rule:[envelope test]
116 if envelope :domain :is "From" "domain.tld"
117 {
118     fileinto "domain.tld";
119     stop;
120 }