--- /dev/null
+<?php
+/**
+ * Stub for the testing the IMP HTML Mime Viewer driver.
+ * Needed because we need to overwrite a protected method.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+
+/**
+ * Test the IMP HTML Mime Viewer driver.
+ * Needed because we need to overwrite a protected method.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+class Imp_Stub_Mime_Viewer_Html extends IMP_Mime_Viewer_Html
+{
+ public function runTest($html)
+ {
+ $this->_imptmp = array(
+ 'blockimg' => 'imgblock.png',
+ 'img' => true,
+ 'imgblock' => false,
+ 'inline' => true,
+ 'target' => '_blank'
+ );
+
+ $dom = new Horde_Domhtml($html);
+ $this->_node($dom->dom, $dom->dom);
+
+ return $dom->dom->saveXML($dom->dom->getElementsByTagName('body')->item(0)->firstChild);
+ }
+
+ protected function _node($doc, $node)
+ {
+ if ($node->hasChildNodes()) {
+ foreach ($node->childNodes as $child) {
+ $this->_nodeCallback($doc, $child);
+ $this->_node($doc, $child);
+ }
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the IMP HTML Mime Viewer driver.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+
+/**
+ * Test the IMP HTML Mime Viewer driver.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+class Imp_Unit_Mime_Viewer_HtmlTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ require_once dirname(__FILE__) . '/../../../Stub/HtmlViewer.php';
+ $GLOBALS['browser'] = $this->getMock('Horde_Browser');
+ }
+
+ // Test regex for converting links to open in a new window.
+ public function testOpenLinksInNewWindow()
+ {
+ $links = array(
+ 'foo' => '<p>foo</p>',
+ 'example@example.com' => '<p>example@example.com</p>',
+ 'foo <a href="#bar">Anchor</a>' => '<p>foo <a href="#bar" target="_blank">Anchor</a></p>',
+ 'foo <a href="http://www.example.com/">example</a>' => '<p>foo <a href="http://www.example.com/" target="_blank">example</a></p>',
+ 'foo <a target="foo" href="http://www.example.com/">example</a>' => '<p>foo <a target="foo" href="http://www.example.com/">example</a></p>',
+ 'foo <a href="http://www.example.com/" target="foo">example</a>' => '<p>foo <a href="http://www.example.com/" target="foo">example</a></p>',
+ 'foo <a mailto="example@example.com">Example Email</a>' => '<p>foo <a mailto="example@example.com">Example Email</a></p>',
+ '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/"></map>' => '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="_blank"/></map>',
+ '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="foo"></map>' => '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="foo"/></map>'
+ );
+
+ $v = new IMP_Stub_Mime_Viewer_Html(new Horde_Mime_Part(), array(
+ 'browser' => $this->getMock('Horde_Browser'),
+ 'charset' => 'UTF-8'
+ ));
+
+ foreach ($links as $key => $val) {
+ $this->assertEquals(
+ $val,
+ $v->runTest($key)
+ );
+ }
+ }
+
+ // Test regex for hiding images.
+ public function testHideImages()
+ {
+ $images = array(
+ '<img src="http://example.com/image.png">' => '<img src="imgblock.png" htmlimgblocked="http://example.com/image.png"/>',
+ '<img src="http://example.com/image.png" />' => '<img src="imgblock.png" htmlimgblocked="http://example.com/image.png"/>',
+ '<td background=http://example.com/image.png>' => '<td background="imgblock.png" htmlimgblocked="http://example.com/image.png"/>',
+ "<img src= http://example.com/image.png alt='Best flight deals' border=0>" => '<img src="imgblock.png" alt="Best flight deals" border="0" htmlimgblocked="http://example.com/image.png"/>',
+ '<foo style="background:url(http://example.com/image.png)">' => '<foo style="background:url(imgblock.png)" htmlimgblocked="http://example.com/image.png"/>',
+ '<foo style="background: transparent url(http://example.com/image.png) repeat">' => '<foo style="background: transparent url(imgblock.png) repeat" htmlimgblocked="http://example.com/image.png"/>',
+ '<foo style="background-image:url(http://example.com/image.png)">' => '<foo style="background-image:url(imgblock.png)" htmlimgblocked="http://example.com/image.png"/>',
+ '<foo style="background: transparent url(http://example.com/image.png) repeat">' => '<foo style="background: transparent url(imgblock.png) repeat" htmlimgblocked="http://example.com/image.png"/>'
+ );
+
+ $v = new IMP_Stub_Mime_Viewer_Html(new Horde_Mime_Part(), array(
+ 'browser' => $this->getMock('Horde_Browser'),
+ 'charset' => 'UTF-8'
+ ));
+
+ foreach ($images as $key => $val) {
+ $this->assertEquals(
+ $val,
+ $v->runTest($key)
+ );
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the Quota library.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test the Quota library.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Imp
+ * @package IMP
+ * @subpackage UnitTests
+ */
+class Imp_Unit_QuotaTest extends PHPUnit_Framework_TestCase
+{
+ public function testMaildir()
+ {
+ $quota = IMP_Quota::factory('Maildir', array(
+ 'path' => dirname(__FILE__) . '/../fixtures'
+ ));
+
+ $data = $quota->getQuota();
+
+ $this->assertEquals(
+ 1000000000,
+ $data['limit']
+ );
+
+ $this->assertEquals(
+ 550839239,
+ $data['usage']
+ );
+ }
+
+}
--- /dev/null
+1000000000S
+ 543336696 6335
+ 3163 1
+ 11524 1
+ 4030 1
+ 218569 1
+ 2393 1
+ 6594810 1
+ 8013 1
+ -13894 -4
+ 1501 1
+ 1687 1
+ 7495 1
+ 64581 1
+ 4918 1
+ 21673 1
+ 202775 1
+ 5133 1
+ 1863 1
+ 8003 1
+ 25389 1
+ 4034 1
+ 14878 1
+ -8003 -1
+ 2371 1
+ 1947 1
+ 1916 1
+ 1913 1
+ 2064 1
+ 2293 1
+ 203262 1
+ 63545 1
+ 35037 1
+ 1740 1
+ 1920 1
+++ /dev/null
-1000000000S
- 543336696 6335
- 3163 1
- 11524 1
- 4030 1
- 218569 1
- 2393 1
- 6594810 1
- 8013 1
- -13894 -4
- 1501 1
- 1687 1
- 7495 1
- 64581 1
- 4918 1
- 21673 1
- 202775 1
- 5133 1
- 1863 1
- 8003 1
- 25389 1
- 4034 1
- 14878 1
- -8003 -1
- 2371 1
- 1947 1
- 1916 1
- 1913 1
- 2064 1
- 2293 1
- 203262 1
- 63545 1
- 35037 1
- 1740 1
- 1920 1
+++ /dev/null
---TEST--
-IMP HTML MIME Viewer tests.
---FILE--
-<?php
-
-require_once dirname(__FILE__) . '/../Application.php';
-Horde_Registry::appInit('imp', array(
- 'authentication' => 'none',
- 'cli' => true
-));
-
-require_once dirname(__FILE__) . '/../Mime/Viewer/Html.php';
-class IMP_Html_Viewer_Test extends IMP_Horde_Mime_Viewer_Html
-{
- public function runTest($html)
- {
- $this->_imptmp = array(
- 'blockimg' => 'imgblock.png',
- 'img' => true,
- 'imgblock' => false,
- 'inline' => true,
- 'target' => '_blank'
- );
-
- $dom = new Horde_Domhtml($html);
- $this->_node($dom->dom, $dom->dom);
-
- return $dom->dom->saveXML($dom->dom->getElementsByTagName('body')->item(0)->firstChild) . "\n";
- }
-
- protected function _node($doc, $node)
- {
- if ($node->hasChildNodes()) {
- foreach ($node->childNodes as $child) {
- $this->_nodeCallback($doc, $child);
- $this->_node($doc, $child);
- }
- }
- }
-
-}
-
-$v = new IMP_Html_Viewer_Test(new Horde_Mime_Part());
-
-// Test regex for converting links to open in a new window.
-$links = array(
- 'foo',
- 'example@example.com',
- 'foo <a href="#bar">Anchor</a>',
- 'foo <a href="http://www.example.com/">example</a>',
- 'foo <a target="foo" href="http://www.example.com/">example</a>',
- 'foo <a href="http://www.example.com/" target="foo">example</a>',
- 'foo <a mailto="example@example.com">Example Email</a>',
- '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/"></map>',
- '<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="foo"></map>'
-);
-
-foreach ($links as $val) {
- echo $v->runTest($val);
-}
-
-echo "\n";
-
-// Test regex for hiding images.
-$images = array(
- '<img src="http://example.com/image.png">',
- '<img src="http://example.com/image.png" />',
- '<td background=http://example.com/image.png>',
- "<img src= http://example.com/image.png alt='Best flight deals' border=0>",
- '<foo style="background:url(http://example.com/image.png)">',
- '<foo style="background: transparent url(http://example.com/image.png) repeat">',
- '<foo style="background-image:url(http://example.com/image.png)">',
- '<foo style="background: transparent url(http://example.com/image.png) repeat">'
-);
-
-foreach ($images as $val) {
- echo $v->runTest($val);
-}
-
-?>
---EXPECT--
-<p>foo</p>
-<p>example@example.com</p>
-<p>foo <a href="#bar">Anchor</a></p>
-<p>foo <a href="http://www.example.com/" target="_blank">example</a></p>
-<p>foo <a target="foo" href="http://www.example.com/">example</a></p>
-<p>foo <a href="http://www.example.com/" target="foo">example</a></p>
-<p>foo <a mailto="example@example.com">Example Email</a></p>
-<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="_blank"/></map>
-<map name="Map"><area shape="rect" coords="32,-2,293,29" href="http://www.example.com/" target="foo"/></map>
-
-<img src="imgblock.png" htmlimgblocked="http://example.com/image.png"/>
-<img src="imgblock.png" htmlimgblocked="http://example.com/image.png"/>
-<td background="imgblock.png" htmlimgblocked="http://example.com/image.png"/>
-<img src="imgblock.png" alt="Best flight deals" border="0" htmlimgblocked="http://example.com/image.png"/>
-<foo style="background:url(imgblock.png)" htmlimgblocked="http://example.com/image.png"/>
-<foo style="background: transparent url(imgblock.png) repeat" htmlimgblocked="http://example.com/image.png"/>
-<foo style="background-image:url(imgblock.png)" htmlimgblocked="http://example.com/image.png"/>
-<foo style="background: transparent url(imgblock.png) repeat" htmlimgblocked="http://example.com/image.png"/>
+++ /dev/null
---TEST--
-IMP_Quota_maildir test.
---FILE--
-<?php
-
-require_once dirname(__FILE__) . '/../Application.php';
-Horde_Registry::appInit('imp', array(
- 'authentication' => 'none',
- 'cli' => true
-));
-
-$quota = IMP_Quota::factory('Maildir', array(
- 'path' => dirname(__FILE__) . '/fixtures'
-));
-
-var_export($quota->getQuota());
-
-?>
---EXPECT--
-array (
- 'limit' => 1000000000,
- 'usage' => 550839239,
-)