source: subversion/trunk/plugins/managesieve/tests/parser.phpt @ 5440

Last change on this file since 5440 was 5440, checked in by alec, 18 months ago
  • Fixed import of rules with unsupported tests
File size: 1.5 KB
Line 
1--TEST--
2Main test of script parser
3--SKIPIF--
4--FILE--
5<?php
6include '../lib/rcube_sieve_script.php';
7
8$txt = '
9require ["fileinto","reject"];
10# rule:[spam]
11if anyof (header :contains "X-DSPAM-Result" "Spam")
12{
13        fileinto "Spam";
14        stop;
15}
16# rule:[test1]
17if anyof (header :contains ["From","To"] "test@domain.tld")
18{
19        discard;
20        stop;
21}
22# rule:[test2]
23if anyof (not header :contains ["Subject"] "[test]", header :contains "Subject" "[test2]")
24{
25        fileinto "test";
26        stop;
27}
28# rule:[comments]
29if anyof (true) /* comment
30 * "comment" #comment */ {
31    /* comment */ stop;
32# comment
33}
34# rule:[reject]
35if size :over 5000K {
36        reject "Message over 5MB size limit. Please contact me before sending this.";
37}
38# rule:[false]
39if false # size :over 5000K
40{
41        stop; /* rule disabled */
42}
43# rule:[true]
44if true
45{
46        stop;
47}
48fileinto "Test";
49';
50
51$s = new rcube_sieve_script($txt);
52echo $s->as_text();
53
54?>
55--EXPECT--
56require ["fileinto","reject"];
57# rule:[spam]
58if header :contains "X-DSPAM-Result" "Spam"
59{
60        fileinto "Spam";
61        stop;
62}
63# rule:[test1]
64if header :contains ["From","To"] "test@domain.tld"
65{
66        discard;
67        stop;
68}
69# rule:[test2]
70if anyof (not header :contains "Subject" "[test]", header :contains "Subject" "[test2]")
71{
72        fileinto "test";
73        stop;
74}
75# rule:[comments]
76if true
77{
78        stop;
79}
80# rule:[reject]
81if size :over 5000K
82{
83        reject "Message over 5MB size limit. Please contact me before sending this.";
84}
85# rule:[false]
86if false # size :over 5000K
87{
88        stop;
89}
90# rule:[true]
91if true
92{
93        stop;
94}
95fileinto "Test";
Note: See TracBrowser for help on using the repository browser.