Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert managesieve test scripts to PHPUnit, add them to the suite
- Loading branch information
Showing
27 changed files
with
276 additions
and
487 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,54 @@ | |||
<?php | |||
|
|||
class Parser extends PHPUnit_Framework_TestCase | |||
{ | |||
|
|||
function setUp() | |||
{ | |||
include_once dirname(__FILE__) . '/../lib/rcube_sieve_script.php'; | |||
} | |||
|
|||
/** | |||
* Sieve script parsing | |||
* | |||
* @dataProvider data_parser | |||
*/ | |||
function test_parser($input, $output, $message) | |||
{ | |||
$script = new rcube_sieve_script($input); | |||
$result = $script->as_text(); | |||
|
|||
$this->assertEquals(trim($result), trim($output), $message); | |||
} | |||
|
|||
/** | |||
* Data provider for test_parser() | |||
*/ | |||
function data_parser() | |||
{ | |||
$dir_path = realpath(dirname(__FILE__) . '/src'); | |||
$dir = opendir($dir_path); | |||
$result = array(); | |||
|
|||
while ($file = readdir($dir)) { | |||
if (preg_match('/^[a-z_]+$/', $file)) { | |||
$input = file_get_contents($dir_path . '/' . $file); | |||
|
|||
if (file_exists($dir_path . '/' . $file . '.out')) { | |||
$output = file_get_contents($dir_path . '/' . $file . '.out'); | |||
} | |||
else { | |||
$output = $input; | |||
} | |||
|
|||
$result[] = array( | |||
'input' => $input, | |||
'output' => $output, | |||
'message' => "Error in parsing '$file' file", | |||
); | |||
} | |||
} | |||
|
|||
return $result; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
<?php | |||
|
|||
class Tokenizer extends PHPUnit_Framework_TestCase | |||
{ | |||
|
|||
function setUp() | |||
{ | |||
include_once dirname(__FILE__) . '/../lib/rcube_sieve_script.php'; | |||
} | |||
|
|||
function data_tokenizer() | |||
{ | |||
return array( | |||
array(1, "text: #test\nThis is test ; message;\nMulti line\n.\n;\n", '"This is test ; message;\nMulti line"'), | |||
array(0, '["test1","test2"]', '[["test1","test2"]]'), | |||
array(1, '["test"]', '["test"]'), | |||
array(1, '"te\\"st"', '"te\\"st"'), | |||
array(0, 'test #comment', '["test"]'), | |||
array(0, "text:\ntest\n.\ntext:\ntest\n.\n", '["test","test"]'), | |||
array(1, '"\\a\\\\\\"a"', '"a\\\\\\"a"'), | |||
); | |||
} | |||
|
|||
/** | |||
* @dataProvider data_tokenizer | |||
*/ | |||
function test_tokenizer($num, $input, $output) | |||
{ | |||
$res = json_encode(rcube_sieve_script::tokenize($input, $num)); | |||
|
|||
$this->assertEquals(trim($res), trim($output)); | |||
} | |||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.