summaryrefslogtreecommitdiff
path: root/tests/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Framework')
-rw-r--r--tests/Framework/Browser.php19
-rw-r--r--tests/Framework/CacheShared.php20
-rw-r--r--tests/Framework/Contacts.php20
-rw-r--r--tests/Framework/DB.php20
-rw-r--r--tests/Framework/Html.php57
-rw-r--r--tests/Framework/ImapCache.php20
-rw-r--r--tests/Framework/LdapGeneric.php20
-rw-r--r--tests/Framework/Mime.php5
-rw-r--r--tests/Framework/ResultIndex.php47
-rw-r--r--tests/Framework/ResultThread.php2
-rw-r--r--tests/Framework/SpellcheckAtd.php21
-rw-r--r--tests/Framework/SpellcheckEnchant.php21
-rw-r--r--tests/Framework/SpellcheckGoogie.php21
-rw-r--r--tests/Framework/SpellcheckPspell.php21
-rw-r--r--tests/Framework/Utils.php28
-rw-r--r--tests/Framework/Washtml.php14
16 files changed, 353 insertions, 3 deletions
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php
index a042572a8..6afd2144c 100644
--- a/tests/Framework/Browser.php
+++ b/tests/Framework/Browser.php
@@ -210,6 +210,25 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'canPNGALPHA' => true, //canPNGALPHA
'canIMGDATA' => false, //canIMGDATA
),
+
+ 'Opera 15' => array(
+ 'useragent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36 OPR/15.0.1147.24',
+ 'version' => '15.0', //Version
+ 'isWin' => true, //isWindows
+ 'isLinux' => false,
+ 'isMac' => false, //isMac
+ 'isUnix' => false, //isUnix
+ 'isOpera' => true, //isOpera
+ 'isChrome' => false, //isChrome
+ 'isIE' => false, //isIE
+ 'isNS' => false, //isNS
+ 'isSafari' => false, //isSafari
+ 'isMZ' => false, //isMZ
+ 'lang' => '', //lang
+ 'hasDOM' => true, //hasDOM
+ 'canPNGALPHA' => true, //canPNGALPHA
+ 'canIMGDATA' => true, //canIMGDATA
+ ),
);
}
diff --git a/tests/Framework/CacheShared.php b/tests/Framework/CacheShared.php
new file mode 100644
index 000000000..9ddcafc7f
--- /dev/null
+++ b/tests/Framework/CacheShared.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_cache_shared class
+ *
+ * @package Tests
+ */
+class Framework_CacheShared extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_cache_shared('db');
+
+ $this->assertInstanceOf('rcube_cache_shared', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Contacts.php b/tests/Framework/Contacts.php
new file mode 100644
index 000000000..0167ea366
--- /dev/null
+++ b/tests/Framework/Contacts.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_contacts class
+ *
+ * @package Tests
+ */
+class Framework_Contacts extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_contacts(null, null);
+
+ $this->assertInstanceOf('rcube_contacts', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/DB.php b/tests/Framework/DB.php
new file mode 100644
index 000000000..b7a063841
--- /dev/null
+++ b/tests/Framework/DB.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_db class
+ *
+ * @package Tests
+ */
+class Framework_DB extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_db('test');
+
+ $this->assertInstanceOf('rcube_db', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Html.php b/tests/Framework/Html.php
index 60284deef..d9466e601 100644
--- a/tests/Framework/Html.php
+++ b/tests/Framework/Html.php
@@ -19,6 +19,63 @@ class Framework_Html extends PHPUnit_Framework_TestCase
}
/**
+ * Data for test_attrib_string()
+ */
+ function data_attrib_string()
+ {
+ return array(
+ array(
+ array(), null, '',
+ ),
+ array(
+ array('test' => 'test'), null, ' test="test"',
+ ),
+ array(
+ array('test' => 'test'), array('test'), ' test="test"',
+ ),
+ array(
+ array('test' => 'test'), array('other'), '',
+ ),
+ array(
+ array('checked' => true), null, ' checked="checked"',
+ ),
+ array(
+ array('checked' => ''), null, '',
+ ),
+ array(
+ array('onclick' => ''), null, '',
+ ),
+ array(
+ array('size' => 5), null, ' size="5"',
+ ),
+ array(
+ array('size' => 'test'), null, '',
+ ),
+ array(
+ array('data-test' => 'test'), null, ' data-test="test"',
+ ),
+ array(
+ array('data-test' => 'test'), array('other'), '',
+ ),
+ array(
+ array('data-test' => 'test'), array('data-test'), ' data-test="test"',
+ ),
+ array(
+ array('data-test' => 'test'), array('data-*'), ' data-test="test"',
+ ),
+ );
+ }
+
+ /**
+ * Test for attrib_string()
+ * @dataProvider data_attrib_string
+ */
+ function test_attrib_string($arg1, $arg2, $result)
+ {
+ $this->assertEquals(html::attrib_string($arg1, $arg2), $result);
+ }
+
+ /**
* Data for test_quote()
*/
function data_quote()
diff --git a/tests/Framework/ImapCache.php b/tests/Framework/ImapCache.php
new file mode 100644
index 000000000..83612c549
--- /dev/null
+++ b/tests/Framework/ImapCache.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_imap_cache class
+ *
+ * @package Tests
+ */
+class Framework_ImapCache extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_imap_cache(null, null, null, null);
+
+ $this->assertInstanceOf('rcube_imap_cache', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/LdapGeneric.php b/tests/Framework/LdapGeneric.php
new file mode 100644
index 000000000..8cb1a2ce5
--- /dev/null
+++ b/tests/Framework/LdapGeneric.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_ldap_generic class
+ *
+ * @package Tests
+ */
+class Framework_LdapGeneric extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_ldap_generic(array());
+
+ $this->assertInstanceOf('rcube_ldap_generic', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php
index 1450b4f90..d47eba896 100644
--- a/tests/Framework/Mime.php
+++ b/tests/Framework/Mime.php
@@ -41,6 +41,9 @@ class Framework_Mime extends PHPUnit_Framework_TestCase
21 => '"test test"@domain.tld',
// invalid (#1489092)
22 => '"John Doe @ SomeBusinessName" <MAILER-DAEMON>',
+ 23 => '=?UTF-8?B?IlRlc3QsVGVzdCI=?= <test@domain.tld>',
+ // invalid, but we do our best to parse correctly
+ 24 => '"email@test.com" <>',
);
$results = array(
@@ -68,6 +71,8 @@ class Framework_Mime extends PHPUnit_Framework_TestCase
21 => array(1, '', '"test test"@domain.tld'),
// invalid (#1489092)
22 => array(1, 'John Doe @ SomeBusinessName', 'MAILER-DAEMON'),
+ 23 => array(1, 'Test,Test', 'test@domain.tld'),
+ 24 => array(1, '', 'email@test.com'),
);
foreach ($headers as $idx => $header) {
diff --git a/tests/Framework/ResultIndex.php b/tests/Framework/ResultIndex.php
index efbba6da7..da1cc628f 100644
--- a/tests/Framework/ResultIndex.php
+++ b/tests/Framework/ResultIndex.php
@@ -17,4 +17,51 @@ class Framework_ResultIndex extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('rcube_result_index', $object, "Class constructor");
}
+
+ /**
+ * thread parser test
+ */
+ function test_parse()
+ {
+ $text = "* SORT 2001 2002 2035 2036 2037 2038 2044 2046 2043 2045 2226 2225 2224 2223";
+ $object = new rcube_result_index('INBOX', $text);
+
+ $this->assertSame(false, $object->is_empty(), "Object is empty");
+ $this->assertSame(false, $object->is_error(), "Object is error");
+ $this->assertSame(2226, $object->max(), "Max message UID");
+ $this->assertSame(2001, $object->min(), "Min message UID");
+ $this->assertSame(14, $object->count_messages(), "Messages count");
+ $this->assertSame(14, $object->count(), "Messages count");
+ $this->assertSame(1, $object->exists(2002, true), "Message exists");
+ $this->assertSame(true, $object->exists(2002), "Message exists (bool)");
+ $this->assertSame(2001, $object->get_element('FIRST'), "Get first element");
+ $this->assertSame(2223, $object->get_element('LAST'), "Get last element");
+ $this->assertSame(2035, (int) $object->get_element(2), "Get specified element");
+ $this->assertSame("2001:2002,2035:2038,2043:2046,2223:2226", $object->get_compressed(), "Get compressed index");
+ $this->assertSame('INBOX', $object->get_parameters('MAILBOX'), "Get parameter");
+
+ $clone = clone $object;
+ $clone->filter(array(2035, 2002));
+
+ $this->assertSame(2, $clone->count(), "Messages count (filtered)");
+ $this->assertSame(2002, $clone->get_element('FIRST'), "Get first element (filtered)");
+
+ $clone = clone $object;
+ $clone->revert();
+
+ $this->assertSame(14, $clone->count(), "Messages count (reverted)");
+ $this->assertSame(12, $clone->exists(2002, true), "Message exists (reverted)");
+ $this->assertSame(true, $clone->exists(2002), "Message exists (bool) (reverted)");
+ $this->assertSame(2223, $clone->get_element('FIRST'), "Get first element (reverted)");
+ $this->assertSame(2001, $clone->get_element('LAST'), "Get last element (reverted)");
+ $this->assertSame(2225, (int) $clone->get_element(2), "Get specified element (reverted)");
+
+ $clone = clone $object;
+ $clone->slice(2, 3);
+
+ $this->assertSame(3, $clone->count(), "Messages count (sliced)");
+ $this->assertSame(2035, $clone->get_element('FIRST'), "Get first element (sliced)");
+ $this->assertSame(2037, $clone->get_element('LAST'), "Get last element (sliced)");
+ }
+
}
diff --git a/tests/Framework/ResultThread.php b/tests/Framework/ResultThread.php
index 8f5c5092f..55fca4c6a 100644
--- a/tests/Framework/ResultThread.php
+++ b/tests/Framework/ResultThread.php
@@ -55,7 +55,5 @@ class Framework_ResultThread extends PHPUnit_Framework_TestCase
$object->filter(array(784));
$this->assertSame(118, $object->count_messages(), "Messages filter");
$this->assertSame(1, $object->count(), "Messages filter (count)");
-
-//echo $object->get_compressed();
}
}
diff --git a/tests/Framework/SpellcheckAtd.php b/tests/Framework/SpellcheckAtd.php
new file mode 100644
index 000000000..cc828240f
--- /dev/null
+++ b/tests/Framework/SpellcheckAtd.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_atd class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckAtd extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_atd(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_atd', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckEnchant.php b/tests/Framework/SpellcheckEnchant.php
new file mode 100644
index 000000000..85393e76c
--- /dev/null
+++ b/tests/Framework/SpellcheckEnchant.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_enchant class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckEnchant extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_enchant(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_enchant', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckGoogie.php b/tests/Framework/SpellcheckGoogie.php
new file mode 100644
index 000000000..dc7d70dcc
--- /dev/null
+++ b/tests/Framework/SpellcheckGoogie.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_googie class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckGoogie extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_googie(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_googie', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckPspell.php b/tests/Framework/SpellcheckPspell.php
new file mode 100644
index 000000000..bd622b206
--- /dev/null
+++ b/tests/Framework/SpellcheckPspell.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_pspell class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckPspell extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_pspell(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_pspell', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index 1f1e57b0e..082aaea3b 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -320,7 +320,7 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
}
/**
- * rcube:utils::normalize _string()
+ * rcube:utils::normalize_string()
*/
function test_normalize_string()
{
@@ -334,4 +334,30 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
$this->assertSame($output, $result);
}
}
+
+ /**
+ * rcube:utils::is_absolute_path()
+ */
+ function test_is_absolute_path()
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ $test = array(
+ '' => false,
+ "C:\\" => true,
+ 'some/path' => false,
+ );
+ }
+ else {
+ $test = array(
+ '' => false,
+ '/path' => true,
+ 'some/path' => false,
+ );
+ }
+
+ foreach ($test as $input => $output) {
+ $result = rcube_utils::is_absolute_path($input);
+ $this->assertSame($output, $result);
+ }
+ }
}
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index 7485d4383..08cf147c8 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -124,4 +124,18 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
}
}
+ /**
+ * Test color style handling (#1489697)
+ */
+ function test_color_style()
+ {
+ $html = "<p style=\"font-size: 10px; color: rgb(241, 245, 218)\">a</p>";
+
+ $washer = new rcube_washtml;
+ $washed = $washer->wash($html);
+
+ $this->assertRegExp('|color: rgb\(241, 245, 218\)|', $washed, "Color style (#1489697)");
+ $this->assertRegExp('|font-size: 10px|', $washed, "Font-size style");
+ }
+
}