diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Framework/BaseReplacer.php | 28 | ||||
-rw-r--r-- | tests/Framework/Csv2vcard.php | 18 | ||||
-rw-r--r-- | tests/src/Csv2vcard/gmail.csv | bin | 3760 -> 3992 bytes | |||
-rw-r--r-- | tests/src/Csv2vcard/gmail.vcf | 4 | ||||
-rw-r--r-- | tests/src/Csv2vcard/outlook.csv | 2 | ||||
-rw-r--r-- | tests/src/Csv2vcard/outlook.vcf | 7 |
6 files changed, 58 insertions, 1 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); + } } diff --git a/tests/src/Csv2vcard/gmail.csv b/tests/src/Csv2vcard/gmail.csv Binary files differindex 9f67fe9f5..b95cb0144 100644 --- a/tests/src/Csv2vcard/gmail.csv +++ b/tests/src/Csv2vcard/gmail.csv diff --git a/tests/src/Csv2vcard/gmail.vcf b/tests/src/Csv2vcard/gmail.vcf index 5337d7e63..e9486b29b 100644 --- a/tests/src/Csv2vcard/gmail.vcf +++ b/tests/src/Csv2vcard/gmail.vcf @@ -5,9 +5,11 @@ N:Lastname;Firstname;Middle;Prefix;Suffix NICKNAME:nick BDAY;VALUE=date:1975-12-12 NOTE:note"note -CATEGORIES:My Contacts +CATEGORIES:My Contacts,Test EMAIL;TYPE=INTERNET;TYPE=HOME:home@aaa.pl EMAIL;TYPE=INTERNET;TYPE=WORK:work@email.pl +EMAIL;TYPE=INTERNET;TYPE=OTHER:unknown@email.com +EMAIL;TYPE=INTERNET;TYPE=OTHER:other@email.com TEL;TYPE=pager:pager TEL;TYPE=pref:mainphone TEL;TYPE=home:homephone diff --git a/tests/src/Csv2vcard/outlook.csv b/tests/src/Csv2vcard/outlook.csv new file mode 100644 index 000000000..ffa082840 --- /dev/null +++ b/tests/src/Csv2vcard/outlook.csv @@ -0,0 +1,2 @@ +E-mail Address,E-mail 2 Address,E-mail 3 Address +test1@domain.tld,test2@domain.tld,test3@domain.tld diff --git a/tests/src/Csv2vcard/outlook.vcf b/tests/src/Csv2vcard/outlook.vcf new file mode 100644 index 000000000..ffd7e0550 --- /dev/null +++ b/tests/src/Csv2vcard/outlook.vcf @@ -0,0 +1,7 @@ +BEGIN:VCARD +VERSION:3.0 +FN:test1@domain.tld +EMAIL;TYPE=INTERNET;TYPE=PREF:test1@domain.tld +EMAIL;TYPE=INTERNET;TYPE=OTHER:test2@domain.tld +EMAIL;TYPE=INTERNET;TYPE=OTHER:test3@domain.tld +END:VCARD |