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

Last change on this file since 5441 was 5441, checked in by alec, 18 months ago
  • Added 'address' and 'envelope' tests support
  • Added 'body' extension support (RFC5173)
  • Added 'subaddress' extension support (RFC5233)
  • Added comparators support
  • Changed Sender/Recipient? labels to From/To?
  • Fixed importing rule names from Ingo
  • Fixed handling of extensions disabled in config
File size: 2.0 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","envelope"];
10# rule:[spam]
11if anyof (header :contains "X-DSPAM-Result" "Spam")
12{
13        fileinto "Spam";
14        stop;
15}
16# rule:[test1]
17if anyof (header :comparator "i;ascii-casemap" :contains ["From","To"] "test@domain.tld")
18{
19        discard;
20        stop;
21}
22# rule:[test2]
23if anyof (not header :comparator "i;octet" :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# rule:[address test]
50if address :all :is "From" "nagios@domain.tld"
51{
52        fileinto "domain.tld";
53        stop;
54}
55# rule:[envelope test]
56if envelope :domain :is "From" "domain.tld"
57{
58        fileinto "domain.tld";
59        stop;
60}
61';
62
63$s = new rcube_sieve_script($txt);
64echo $s->as_text();
65
66// -------------------------------------------------------------------------------
67?>
68--EXPECT--
69require ["fileinto","reject","envelope"];
70# rule:[spam]
71if header :contains "X-DSPAM-Result" "Spam"
72{
73        fileinto "Spam";
74        stop;
75}
76# rule:[test1]
77if header :contains ["From","To"] "test@domain.tld"
78{
79        discard;
80        stop;
81}
82# rule:[test2]
83if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]")
84{
85        fileinto "test";
86        stop;
87}
88# rule:[comments]
89if true
90{
91        stop;
92}
93# rule:[reject]
94if size :over 5000K
95{
96        reject "Message over 5MB size limit. Please contact me before sending this.";
97}
98# rule:[false]
99if false # size :over 5000K
100{
101        stop;
102}
103# rule:[true]
104if true
105{
106        stop;
107}
108fileinto "Test";
109# rule:[address test]
110if address :all :is "From" "nagios@domain.tld"
111{
112        fileinto "domain.tld";
113        stop;
114}
115# rule:[envelope test]
116if envelope :domain :is "From" "domain.tld"
117{
118        fileinto "domain.tld";
119        stop;
120}
Note: See TracBrowser for help on using the repository browser.