commit | author | age
|
f72815
|
1 |
<?php |
AM |
2 |
|
|
3 |
class Managesieve_Vacation extends PHPUnit_Framework_TestCase |
|
4 |
{ |
|
5 |
|
|
6 |
function setUp() |
|
7 |
{ |
0ea079
|
8 |
include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_engine.php'; |
AM |
9 |
include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_vacation.php'; |
f72815
|
10 |
} |
AM |
11 |
|
|
12 |
/** |
|
13 |
* Plugin object construction test |
|
14 |
*/ |
|
15 |
function test_constructor() |
|
16 |
{ |
|
17 |
$vacation = new rcube_sieve_vacation(true); |
|
18 |
|
|
19 |
$this->assertInstanceOf('rcube_sieve_vacation', $vacation); |
|
20 |
} |
|
21 |
|
|
22 |
function test_build_regexp_tests() |
|
23 |
{ |
|
24 |
$tests = rcube_sieve_vacation::build_regexp_tests('2014-02-20', '2014-03-05', $error); |
|
25 |
|
|
26 |
$this->assertCount(2, $tests); |
|
27 |
$this->assertSame('header', $tests[0]['test']); |
|
28 |
$this->assertSame('regex', $tests[0]['type']); |
|
29 |
$this->assertSame('received', $tests[0]['arg1']); |
|
30 |
$this->assertSame('(20|21|22|23|24|25|26|27|28) Feb 2014', $tests[0]['arg2']); |
|
31 |
$this->assertSame('header', $tests[1]['test']); |
|
32 |
$this->assertSame('regex', $tests[1]['type']); |
|
33 |
$this->assertSame('received', $tests[1]['arg1']); |
|
34 |
$this->assertSame('([ 0]1|[ 0]2|[ 0]3|[ 0]4|[ 0]5) Mar 2014', $tests[1]['arg2']); |
|
35 |
|
|
36 |
$tests = rcube_sieve_vacation::build_regexp_tests('2014-02-20', '2014-01-05', $error); |
|
37 |
|
|
38 |
$this->assertSame(null, $tests); |
|
39 |
$this->assertSame('managesieve.invaliddateformat', $error); |
|
40 |
} |
|
41 |
|
|
42 |
function test_parse_regexp_tests() |
|
43 |
{ |
|
44 |
$tests = array( |
|
45 |
array( |
|
46 |
'test' => 'header', |
|
47 |
'type' => 'regex', |
|
48 |
'arg1' => 'received', |
|
49 |
'arg2' => '(20|21|22|23|24|25|26|27|28) Feb 2014', |
|
50 |
), |
|
51 |
array( |
|
52 |
'test' => 'header', |
|
53 |
'type' => 'regex', |
|
54 |
'arg1' => 'received', |
|
55 |
'arg2' => '([ 0]1|[ 0]2|[ 0]3|[ 0]4|[ 0]5) Mar 2014', |
|
56 |
) |
|
57 |
); |
|
58 |
|
|
59 |
$result = rcube_sieve_vacation::parse_regexp_tests($tests); |
|
60 |
|
|
61 |
$this->assertCount(2, $result); |
|
62 |
$this->assertSame('20 Feb 2014', $result['from']); |
|
63 |
$this->assertSame('05 Mar 2014', $result['to']); |
|
64 |
} |
|
65 |
} |
|
66 |
|