diff options
Diffstat (limited to 'tests/Framework')
-rw-r--r-- | tests/Framework/BaseReplacer.php | 28 | ||||
-rw-r--r-- | tests/Framework/Csv2vcard.php | 18 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/Framework/BaseReplacer.php b/tests/Framework/BaseReplacer.php index 44a9604ac..2255e9af2 100644 --- a/tests/Framework/BaseReplacer.php +++ b/tests/Framework/BaseReplacer.php @@ -31,4 +31,32 @@ class Framework_BaseReplacer extends PHPUnit_Framework_TestCase $this->assertSame('<A href="http://shouldbethislink.com">Test URL</A>', $response); } + + /** + * Data for absolute_url() test + */ + function data_absolute_url() + { + return array( + array('', 'http://test', 'http://test/'), + array('http://test', 'http://anything', 'http://test'), + array('cid:test', 'http://anything', 'cid:test'), + array('/test', 'http://test', 'http://test/test'), + array('./test', 'http://test', 'http://test/test'), + array('../test1', 'http://test/test2', 'http://test1'), + array('../test1', 'http://test/test2/', 'http://test/test1'), + ); + } + + /** + * Test absolute_url() + * @dataProvider data_absolute_url + */ + function test_absolute_url($path, $base, $expected) + { + $replacer = new rcube_base_replacer('test'); + $result = $replacer->absolute_url($path, $base); + + $this->assertSame($expected, $result); + } } diff --git a/tests/Framework/Csv2vcard.php b/tests/Framework/Csv2vcard.php index 4f48dfaa2..34faf7d8d 100644 --- a/tests/Framework/Csv2vcard.php +++ b/tests/Framework/Csv2vcard.php @@ -73,4 +73,22 @@ class Framework_Csv2vcard extends PHPUnit_Framework_TestCase $this->assertEquals($vcf_text, $vcard); } + + function test_import_outlook() + { + $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/outlook.csv'); + $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/outlook.vcf'); + + $csv = new rcube_csv2vcard; + $csv->import($csv_text); + $result = $csv->export(); + $vcard = $result[0]->export(false); + + $this->assertCount(1, $result); + + $vcf_text = trim(str_replace("\r\n", "\n", $vcf_text)); + $vcard = trim(str_replace("\r\n", "\n", $vcard)); + + $this->assertEquals($vcf_text, $vcard); + } } |