[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_spider/tests/cases/ -> lmbInnerUriNormalizerObserverTest.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/web_spider/src/lmbInnerUriNormalizerObserver.class.php');
  10  lmb_require('limb/web_spider/src/lmbUriContentReader.class.php');
  11  
  12  Mock :: generate('lmbUriContentReader', 'MockUriContentReader');
  13  
  14  class lmbInnerUriNormalizerObserverTest extends UnitTestCase
  15  {
  16    var $observer;
  17    var $reader;
  18  
  19    function setUp()
  20    {
  21      $this->reader = new MockUriContentReader($this);
  22    }
  23  
  24    function tearDown()
  25    {
  26      $this->reader->tally();
  27    }
  28  
  29    function testNotifyInnerUrl()
  30    {
  31      $observer = new lmbInnerUriNormalizerObserver(new lmbUri('http://test.com'));
  32      $this->reader->expectOnce('getUri');
  33      $this->reader->setReturnReference('getUri', $uri = new lmbUri('http://test.com/page.html'));
  34  
  35      $observer->notify($this->reader);
  36      $this->assertEqual($uri->toString(), '/page.html');
  37    }
  38  
  39    function testNotifyOtherProtocol()
  40    {
  41      $observer = new lmbInnerUriNormalizerObserver(new lmbUri('http://test.com'));
  42      $this->reader->expectOnce('getUri');
  43      $this->reader->setReturnReference('getUri', $uri = new lmbUri('ftp://test.com/page.html'));
  44  
  45      $observer->notify($this->reader);
  46      $this->assertEqual($uri->toString(), 'ftp://test.com/page.html');
  47    }
  48  
  49    function testNotifyOtherPort()
  50    {
  51      $observer = new lmbInnerUriNormalizerObserver(new lmbUri('http://test.com:22'));
  52      $this->reader->expectOnce('getUri');
  53      $this->reader->setReturnReference('getUri', $uri = new lmbUri('http://test.com/page.html'));
  54  
  55      $observer->notify($this->reader);
  56      $this->assertEqual($uri->toString(), 'http://test.com/page.html');
  57    }
  58  
  59    function testNotifyExternalUrl()
  60    {
  61      $observer = new lmbInnerUriNormalizerObserver(new lmbUri('http://test.com'));
  62      $this->reader->expectOnce('getUri');
  63      $this->reader->setReturnReference('getUri', $uri = new lmbUri('http://test2.com/page.html'));
  64  
  65      $observer->notify($this->reader);
  66      $this->assertEqual($uri->toString(), 'http://test2.com/page.html');
  67    }
  68  
  69  }
  70  
  71  ?>


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7