summaryrefslogtreecommitdiff
path: root/tests/Framework
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-11-17 16:24:09 +0100
committerThomas Bruederli <thomas@roundcube.net>2012-11-17 16:24:09 +0100
commit6ddb16d181e285d4f0ef0ef55bdd0ba787f1b583 (patch)
tree5f186f89d5d7f77592acf3aec676b48367a96d48 /tests/Framework
parentbc66f7d6d208ac99dcec57992c4eb955570d85bc (diff)
parent9ab34604d94270f6c1795c7dd7b615273d05db0c (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'tests/Framework')
-rw-r--r--tests/Framework/Csv2vcard.php57
-rw-r--r--tests/Framework/Utils.php13
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/Framework/Csv2vcard.php b/tests/Framework/Csv2vcard.php
new file mode 100644
index 000000000..6fa3e163c
--- /dev/null
+++ b/tests/Framework/Csv2vcard.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Test class to test rcube_csv2vcard class
+ *
+ * @package Tests
+ */
+class Framework_Csv2vcard extends PHPUnit_Framework_TestCase
+{
+
+ function test_import_generic()
+ {
+ $csv = new rcube_csv2vcard;
+
+ // empty input
+ $csv->import('');
+ $this->assertSame(array(), $csv->export());
+ }
+
+ function test_import_tb_plain()
+ {
+ $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/tb_plain.csv');
+ $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/tb_plain.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);
+ }
+
+ function test_import_email()
+ {
+ $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/email.csv');
+ $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/email.vcf');
+
+ $csv = new rcube_csv2vcard;
+ $csv->import($csv_text);
+ $result = $csv->export();
+
+ $this->assertCount(4, $result);
+
+ $vcard = '';
+ foreach ($result as $vcf) {
+ $vcard .= $vcf->export(false) . "\n";
+ }
+
+ $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/Framework/Utils.php b/tests/Framework/Utils.php
index e58835956..ec61c5d4b 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -193,4 +193,17 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
$mod = rcube_utils::mod_css_styles("background:\\0075\\0072\\006c( javascript:alert(&#039;xss&#039;) )", 'rcmbody');
$this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks (2)");
}
+
+ /**
+ * Check rcube_utils::explode_quoted_string() compat. with explode()
+ */
+ function test_explode_quoted_string_compat()
+ {
+ $data = array('', 'a,b,c', 'a', ',', ',a');
+
+ foreach ($data as $text) {
+ $result = rcube_utils::explode_quoted_string(',', $text);
+ $this->assertSame(explode(',', $text), $result);
+ }
+ }
}