summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mailfunc.php6
-rw-r--r--tests/src/apple.vcf49
-rw-r--r--tests/src/johndoe.vcf11
-rw-r--r--tests/vcards.php53
4 files changed, 116 insertions, 3 deletions
diff --git a/tests/mailfunc.php b/tests/mailfunc.php
index ae35c5d77..0e9363a0b 100644
--- a/tests/mailfunc.php
+++ b/tests/mailfunc.php
@@ -51,11 +51,11 @@ class rcube_test_mailfunc extends UnitTestCase
$this->assertPattern('#background="./program/blocked.gif"#', $html, "Replace external background image");
$this->assertNoPattern('/ex3.jpg/', $html, "No references to external images");
$this->assertNoPattern('/<meta [^>]+>/', $html, "No meta tags allowed");
- $this->assertNoPattern('/<style [^>]+>/', $html, "No style tags allowed");
+ //$this->assertNoPattern('/<style [^>]+>/', $html, "No style tags allowed");
$this->assertNoPattern('/<form [^>]+>/', $html, "No form tags allowed");
$this->assertPattern('/Subscription form/', $html, "Include <form> contents");
- $this->assertPattern('/<!-- input not allowed -->/', $html, "No input elements allowed");
- $this->assertPattern('/<!-- link not allowed -->/', $html, "No external links allowed");
+ $this->assertPattern('/<!-- input ignored -->/', $html, "No input elements allowed");
+ $this->assertPattern('/<!-- link ignored -->/', $html, "No external links allowed");
$this->assertPattern('/<a[^>]+ target="_blank">/', $html, "Set target to _blank");
$this->assertTrue($GLOBALS['REMOTE_OBJECTS'], "Remote object detected");
diff --git a/tests/src/apple.vcf b/tests/src/apple.vcf
new file mode 100644
index 000000000..856eaf328
--- /dev/null
+++ b/tests/src/apple.vcf
@@ -0,0 +1,49 @@
+BEGIN:VCARD
+VERSION:3.0
+N:;;;;
+FN:Apple Computer AG
+ORG:Apple Computer AG;
+item1.ADR;type=WORK;type=pref:;;Birgistrasse 4a;Wallisellen-Zürich;;8304;Switzerland
+item1.X-ABADR:ch
+item2.URL;type=pref:http\://www.apple.ch
+item2.X-ABLabel:_$!<HomePage>!$_
+PHOTO;BASE64:
+ /9j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ZSh
+ N2jNpqXSLSe/k+/R+p+w1eMe0FAHxz+2P8DLr4r+CIPEPhy2Nx4y8FJdXVnaxrmfWdGlAk1DSosK
+ WkuozEt5p8fHmTLNADuuQR24KuqU3GTtCpbXtLo32T2b9GcWNw7qwU4q84X06yi9Wl531XfXyPxK
+ ME4nNsYZRciUwG3MbicTh/LMJix5glD/ACGPbv3/AC4zxXtniFvUNJ1XSmjXVNM1DTWmUvCuoWVz
+ ZtKgxloxcRxmRRkZZcgZGTzSTT2afo7hqtz6w/ZB+BV78UPHtl4n1eykHgfwdewajfXE0bCDVtVt
+ mE+n6PAzAJOBOkdxqAUssdsnlSDNwoPLi66pU3FP95NNJdk95P06d35XOvCUHWqJtfu4NOT7vdR8
+ 7vfsvVH7gV4R7oUAFAHKReA/A8Gsy+IofBnhSHxBO7ST67F4d0iPWZnb7zy6mlmL2R2/iZ5yT3NX
+ 7Spbl9pPl/l55W+69iPZUubm9nDmvfm5I81+97XuX9a8MeGvEtsLLxF4e0PX7MMGFprWk2Gq2wZe
+ jCC+t54tw7HZkdqUZzg7wlKL7xk4v700OUIT0lCMl2lFS/NMuaXpOlaHZQ6Zoumafo+nW4It9P0u
+ yttPsoATkiG1tI4oIgTyQkagnmk5Sk7ybk+7bb+96jjGMVaMVFdopJfcjQpDP//Z
+X-ABShowAs:COMPANY
+X-ABUID:2E4CB084-4767-4C85-BBCA-805B1DCB1C8E\:ABPerson
+END:VCARD
diff --git a/tests/src/johndoe.vcf b/tests/src/johndoe.vcf
new file mode 100644
index 000000000..67b649df3
--- /dev/null
+++ b/tests/src/johndoe.vcf
@@ -0,0 +1,11 @@
+BEGIN:VCARD
+VERSION:2.1
+N;CHARSET=windows-1252:Doë;John;;;
+FN;CHARSET=windows-1252:John Doë
+ORG:roundcube.net;
+EMAIL;INTERNET;WORK:inbox@roundcube.net
+EMAIL;INTERNET;HOME;TYPE=pref:roundcube@gmail.com
+TEL;WORK:+123456789
+ADR;WORK:;;The street;Hometown;;5555;Cayman Islands
+NOTE:The notes...
+END:VCARD
diff --git a/tests/vcards.php b/tests/vcards.php
new file mode 100644
index 000000000..72c687484
--- /dev/null
+++ b/tests/vcards.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Unit tests for class rcube_vcard
+ *
+ * @package Tests
+ */
+class rcube_test_vcards extends UnitTestCase
+{
+
+ function __construct()
+ {
+ $this->UnitTestCase('Vcard encoding/decoding tests');
+ }
+
+ function _srcpath($fn)
+ {
+ return realpath(dirname(__FILE__) . '/src/' . $fn);
+ }
+
+ function test_parse_one()
+ {
+ $vcard = new rcube_vcard(file_get_contents($this->_srcpath('apple.vcf')));
+
+ $this->assertEqual(true, $vcard->business, "Identify as business record");
+ $this->assertEqual("Apple Computer AG", $vcard->displayname, "FN => displayname");
+ $this->assertEqual("", $vcard->firstname, "No person name set");
+ }
+
+ function test_parse_two()
+ {
+ $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
+
+ $this->assertEqual(false, $vcard->business, "Identify as private record");
+ $this->assertEqual("John Doë", $vcard->displayname, "Decode according to charset attribute");
+ $this->assertEqual("roundcube.net", $vcard->organization, "Test organization field");
+ $this->assertEqual(2, count($vcard->email), "List two e-mail addresses");
+ $this->assertEqual("roundcube@gmail.com", $vcard->email[0], "Use PREF e-mail as primary");
+ }
+
+ function test_import()
+ {
+ $input = file_get_contents($this->_srcpath('apple.vcf'));
+ $input .= file_get_contents($this->_srcpath('johndoe.vcf'));
+
+ $vcards = rcube_vcard::import($input);
+
+ $this->assertEqual(2, count($vcards), "Detected 2 vcards");
+ $this->assertEqual("Apple Computer AG", $vcards[0]->displayname, "FN => displayname");
+ $this->assertEqual("John Doë", $vcards[1]->displayname, "Displayname with correct charset");
+ }
+
+}