Overview

Packages

  • Horde
    • Icalendar
      • UnitTests
  • Ingo
    • UnitTests
  • None

Classes

  • Ingo_MaildropTest
  • Ingo_ProcmailTest
  • Ingo_ScriptTest
  • Ingo_SieveTest
  • Ingo_TestBase
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Test cases for Ingo_Script_sieve:: class
  4:  *
  5:  * See the enclosed file LICENSE for license information (ASL).  If you
  6:  * did not receive this file, see http://www.horde.org/licenses/apache.
  7:  *
  8:  * @author     Jason M. Felice <jason.m.felice@gmail.com>
  9:  * @package    Ingo
 10:  * @subpackage UnitTests
 11:  */
 12: 
 13: require_once dirname(__FILE__) . '/TestBase.php';
 14: 
 15: class Ingo_MaildropTest extends Ingo_TestBase {
 16: 
 17:     function store($ob)
 18:     {
 19:         $GLOBALS['ingo_storage']->store($ob);
 20:     }
 21: 
 22:     function setUp()
 23:     {
 24:         $GLOBALS['ingo_storage'] = Ingo_Storage::factory(
 25:             'mock',
 26:             array('maxblacklist' => 3,
 27:                   'maxwhitelist' => 3));
 28:         $GLOBALS['ingo_script'] = Ingo_Script::factory(
 29:             'maildrop',
 30:             array('path_style' => 'mbox',
 31:                   'spam_compare' => 'string',
 32:                   'spam_header' => 'X-Spam-Level',
 33:                   'spam_char' => '*'));
 34:     }
 35: 
 36:     function testForwardKeep()
 37:     {
 38:         $forward = new Ingo_Storage_Forward();
 39:         $forward->setForwardAddresses('joefabetes@example.com');
 40:         $forward->setForwardKeep(true);
 41: 
 42:         $this->store($forward);
 43:         $this->assertScript('if( \
 44: /^From:\s*.*/:h \
 45: )
 46: exception {
 47: cc "! joefabetes@example.com"
 48: to "${DEFAULT}"
 49: }');
 50:     }
 51: 
 52:     function testForwardNoKeep()
 53:     {
 54:         $forward = new Ingo_Storage_Forward();
 55:         $forward->setForwardAddresses('joefabetes@example.com');
 56:         $forward->setForwardKeep(false);
 57: 
 58:         $this->store($forward);
 59:         $this->assertScript('if( \
 60: /^From:\s*.*/:h \
 61: )
 62: exception {
 63: cc "! joefabetes@example.com"
 64: exit
 65: }');
 66:     }
 67: 
 68:     function testBlacklistWithFolder()
 69:     {
 70:         $bl = new Ingo_Storage_Blacklist(3);
 71:         $bl->setBlacklist(array('spammer@example.com'));
 72:         $bl->setBlacklistFolder('Junk');
 73: 
 74:         $this->store($bl);
 75:         $this->assertScript('if( \
 76: /^From:\s*.*spammer@example\.com/:h \
 77: )
 78: exception {
 79: to Junk
 80: }');
 81:     }
 82: 
 83:     function testBlacklistMarker()
 84:     {
 85:         $bl = new Ingo_Storage_Blacklist(3);
 86:         $bl->setBlacklist(array('spammer@example.com'));
 87:         $bl->setBlacklistFolder(Ingo::BLACKLIST_MARKER);
 88: 
 89:         $this->store($bl);
 90:         $this->assertScript('if( \
 91: /^From:\s*.*spammer@example\.com/:h \
 92: )
 93: exception {
 94: to ++DELETE++
 95: }');
 96:     }
 97: 
 98:     function testBlacklistDiscard()
 99:     {
100:         $bl = new Ingo_Storage_Blacklist(3);
101:         $bl->setBlacklist(array('spammer@example.com'));
102:         $bl->setBlacklistFolder(null);
103: 
104:         $this->store($bl);
105:         $this->assertScript('if( \
106: /^From:\s*.*spammer@example\.com/:h \
107: )
108: exception {
109: exit
110: }');
111:     }
112: 
113:     function testWhitelist()
114:     {
115:         $wl = new Ingo_Storage_Whitelist(3);
116:         $wl->setWhitelist(array('spammer@example.com'));
117: 
118:         $this->store($wl);
119:         $this->assertScript('if( \
120: /^From:\s*.*spammer@example\.com/:h \
121: )
122: exception {
123: to "${DEFAULT}"
124: }');
125:     }
126: 
127: }
128: 
API documentation generated by ApiGen