From 884add1419729cb8eb5ed8fb47ea68e5f6ce6682 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sat, 3 Mar 2012 14:23:04 +0000 Subject: Tagging plugins for 0.8-beta --- plugins/managesieve/tests/Makefile | 7 ++ plugins/managesieve/tests/parser.phpt | 120 +++++++++++++++++++++++ plugins/managesieve/tests/parser_body.phpt | 49 +++++++++ plugins/managesieve/tests/parser_imapflags.phpt | 28 ++++++ plugins/managesieve/tests/parser_include.phpt | 30 ++++++ plugins/managesieve/tests/parser_kep14.phpt | 19 ++++ plugins/managesieve/tests/parser_prefix.phpt | 25 +++++ plugins/managesieve/tests/parser_relational.phpt | 25 +++++ plugins/managesieve/tests/parser_vacation.phpt | 39 ++++++++ plugins/managesieve/tests/parser_variables.phpt | 39 ++++++++ plugins/managesieve/tests/parset_subaddress.phpt | 38 +++++++ plugins/managesieve/tests/tokenize.phpt | 66 +++++++++++++ 12 files changed, 485 insertions(+) create mode 100644 plugins/managesieve/tests/Makefile create mode 100644 plugins/managesieve/tests/parser.phpt create mode 100644 plugins/managesieve/tests/parser_body.phpt create mode 100644 plugins/managesieve/tests/parser_imapflags.phpt create mode 100644 plugins/managesieve/tests/parser_include.phpt create mode 100644 plugins/managesieve/tests/parser_kep14.phpt create mode 100644 plugins/managesieve/tests/parser_prefix.phpt create mode 100644 plugins/managesieve/tests/parser_relational.phpt create mode 100644 plugins/managesieve/tests/parser_vacation.phpt create mode 100644 plugins/managesieve/tests/parser_variables.phpt create mode 100644 plugins/managesieve/tests/parset_subaddress.phpt create mode 100644 plugins/managesieve/tests/tokenize.phpt (limited to 'plugins/managesieve/tests') diff --git a/plugins/managesieve/tests/Makefile b/plugins/managesieve/tests/Makefile new file mode 100644 index 000000000..072be2f2c --- /dev/null +++ b/plugins/managesieve/tests/Makefile @@ -0,0 +1,7 @@ + +clean: + rm -f *.log *.php *.diff *.exp *.out + + +test: + pear run-tests *.phpt diff --git a/plugins/managesieve/tests/parser.phpt b/plugins/managesieve/tests/parser.phpt new file mode 100644 index 000000000..aec042187 --- /dev/null +++ b/plugins/managesieve/tests/parser.phpt @@ -0,0 +1,120 @@ +--TEST-- +Main test of script parser +--SKIPIF-- +--FILE-- +as_text(); + +// ------------------------------------------------------------------------------- +?> +--EXPECT-- +require ["fileinto","reject","envelope"]; +# rule:[spam] +if header :contains "X-DSPAM-Result" "Spam" +{ + fileinto "Spam"; + stop; +} +# rule:[test1] +if header :contains ["From","To"] "test@domain.tld" +{ + discard; + stop; +} +# rule:[test2] +if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]") +{ + fileinto "test"; + stop; +} +# rule:[comments] +if true +{ + stop; +} +# rule:[reject] +if size :over 5000K +{ + reject "Message over 5MB size limit. Please contact me before sending this."; +} +# rule:[false] +if false # size :over 5000K +{ + stop; +} +# rule:[true] +if true +{ + stop; +} +fileinto "Test"; +# rule:[address test] +if address :all :is "From" "nagios@domain.tld" +{ + fileinto "domain.tld"; + stop; +} +# rule:[envelope test] +if envelope :domain :is "From" "domain.tld" +{ + fileinto "domain.tld"; + stop; +} diff --git a/plugins/managesieve/tests/parser_body.phpt b/plugins/managesieve/tests/parser_body.phpt new file mode 100644 index 000000000..08ad54959 --- /dev/null +++ b/plugins/managesieve/tests/parser_body.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test of Sieve body extension (RFC5173) +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["body","fileinto"]; +if body :raw :contains "MAKE MONEY FAST" +{ + stop; +} +if body :content "text" :contains ["missile","coordinates"] +{ + fileinto "secrets"; +} +if body :content "audio/mp3" :contains "" +{ + fileinto "jukebox"; +} +if body :text :contains "project schedule" +{ + fileinto "project/schedule"; +} diff --git a/plugins/managesieve/tests/parser_imapflags.phpt b/plugins/managesieve/tests/parser_imapflags.phpt new file mode 100644 index 000000000..a4bc465a3 --- /dev/null +++ b/plugins/managesieve/tests/parser_imapflags.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test of Sieve vacation extension (RFC5232) +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["imapflags"]; +# rule:[imapflags] +if header :matches "Subject" "^Test$" +{ + setflag "\\Seen"; + addflag ["\\Answered","\\Deleted"]; +} diff --git a/plugins/managesieve/tests/parser_include.phpt b/plugins/managesieve/tests/parser_include.phpt new file mode 100644 index 000000000..addc0d449 --- /dev/null +++ b/plugins/managesieve/tests/parser_include.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test of Sieve include extension +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["include"]; +include "script.sieve"; +# rule:[two] +if true +{ + include :optional "second.sieve"; +} diff --git a/plugins/managesieve/tests/parser_kep14.phpt b/plugins/managesieve/tests/parser_kep14.phpt new file mode 100644 index 000000000..dcdbd48a0 --- /dev/null +++ b/plugins/managesieve/tests/parser_kep14.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test of Kolab's KEP:14 implementation +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +# EDITOR Roundcube +# EDITOR_VERSION 123 diff --git a/plugins/managesieve/tests/parser_prefix.phpt b/plugins/managesieve/tests/parser_prefix.phpt new file mode 100644 index 000000000..c87e9658f --- /dev/null +++ b/plugins/managesieve/tests/parser_prefix.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test of prefix comments handling +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +# this is a comment +# and the second line + +require ["variables"]; +set "b" "c"; diff --git a/plugins/managesieve/tests/parser_relational.phpt b/plugins/managesieve/tests/parser_relational.phpt new file mode 100644 index 000000000..6b6f29f4c --- /dev/null +++ b/plugins/managesieve/tests/parser_relational.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test of Sieve relational extension (RFC5231) +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["relational","comparator-i;ascii-numeric"]; +# rule:[redirect] +if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14" +{ + redirect "test@test.tld"; +} diff --git a/plugins/managesieve/tests/parser_vacation.phpt b/plugins/managesieve/tests/parser_vacation.phpt new file mode 100644 index 000000000..a603ff6c1 --- /dev/null +++ b/plugins/managesieve/tests/parser_vacation.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test of Sieve vacation extension (RFC5230) +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["vacation"]; +# rule:[test-vacation] +if header :contains "Subject" "vacation" +{ + vacation :days 1 text: +# test +test test /* test */ +test +. +; + stop; +} diff --git a/plugins/managesieve/tests/parser_variables.phpt b/plugins/managesieve/tests/parser_variables.phpt new file mode 100644 index 000000000..cf1f8fcad --- /dev/null +++ b/plugins/managesieve/tests/parser_variables.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test of Sieve variables extension +--SKIPIF-- +--FILE-- +as_text(); + +?> +--EXPECT-- +require ["variables"]; +set "honorific" "Mr"; +set "vacation" text: +Dear ${HONORIFIC} ${last_name}, +I am out, please leave a message after the meep. +. +; +set :length "b" "${a}"; +set :lower "b" "${a}"; +set :upperfirst "b" "${a}"; +set :upperfirst :lower "b" "${a}"; +set :quotewildcard "b" "Rock*"; diff --git a/plugins/managesieve/tests/parset_subaddress.phpt b/plugins/managesieve/tests/parset_subaddress.phpt new file mode 100644 index 000000000..6d4d03c6e --- /dev/null +++ b/plugins/managesieve/tests/parset_subaddress.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test of Sieve subaddress extension (RFC5233) +--SKIPIF-- +--FILE-- +as_text(); + +// ------------------------------------------------------------------------------- +?> +--EXPECT-- +require ["envelope","subaddress","fileinto"]; +if envelope :user "To" "postmaster" +{ + fileinto "postmaster"; + stop; +} +if envelope :detail :is "To" "mta-filters" +{ + fileinto "mta-filters"; + stop; +} diff --git a/plugins/managesieve/tests/tokenize.phpt b/plugins/managesieve/tests/tokenize.phpt new file mode 100644 index 000000000..f988653ee --- /dev/null +++ b/plugins/managesieve/tests/tokenize.phpt @@ -0,0 +1,66 @@ +--TEST-- +Script parsing: tokenizer +--SKIPIF-- +--FILE-- + $t) { + echo "[$idx]---------------\n"; + var_dump(rcube_sieve_script::tokenize($t[1], $t[0])); +} +?> +--EXPECT-- +[1]--------------- +string(34) "This is test ; message; +Multi line" +[2]--------------- +array(1) { + [0]=> + array(2) { + [0]=> + string(5) "test1" + [1]=> + string(5) "test2" + } +} +[3]--------------- +array(1) { + [0]=> + string(4) "test" +} +[4]--------------- +string(5) "te"st" +[5]--------------- +array(1) { + [0]=> + string(4) "test" +} +[6]--------------- +array(2) { + [0]=> + string(4) "test" + [1]=> + string(4) "test" +} +[7]--------------- +string(4) "a\"a" -- cgit v1.2.3