[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_cache/tests/cases/ -> lmbFullPageCacheFilterTest.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/filter_chain/src/lmbInterceptingFilter.interface.php');
  10  lmb_require('limb/filter_chain/src/lmbFilterChain.class.php');
  11  lmb_require('limb/web_cache/src/lmbFullPageCacheUser.class.php');
  12  lmb_require('limb/web_cache/src/filter/lmbFullPageCacheFilter.class.php');
  13  lmb_require('limb/net/src/lmbHttpRequest.class.php');
  14  lmb_require('limb/config/src/lmbFakeIni.class.php');
  15  
  16  Mock :: generate('lmbInterceptingFilter', 'MockInterceptingFilter');
  17  
  18  class lmbFullPageCacheFilterTest extends UnitTestCase
  19  {
  20    protected $fc;
  21    protected $filter2;
  22    protected $toolkit;
  23    protected $user;
  24    protected $cache_dir;
  25  
  26    function setUp()
  27    {
  28      $this->cache_dir = LIMB_VAR_DIR . '/fpcache/';
  29      lmbFs :: rm($this->cache_dir);
  30      $this->filter2 = new MockInterceptingFilter();
  31      $this->user = new lmbFullPageCacheUser();
  32      $this->toolkit = lmbToolkit :: save();
  33    }
  34  
  35    function tearDown()
  36    {
  37      lmbToolkit :: restore();
  38    }
  39  
  40    function testRunOkFullCircle()
  41    {
  42      $filter = new lmbFullPageCacheFilter('cache.ini', $this->cache_dir, $this->user);
  43  
  44      $fc = new lmbFilterChain();
  45      $fc->registerFilter($filter);
  46      $fc->registerFilter($this->filter2);
  47  
  48      $rules = '
  49       [rull-all-to-all]
  50       path_regex = ~^.*$~
  51       policy = allow
  52      ';
  53      $this->toolkit->setConf('cache.ini', new lmbFakeIni($rules));
  54  
  55      $this->filter2->expectOnce('run');
  56  
  57      $response = $this->toolkit->getResponse();
  58      $response->start();
  59      $response->write('some_content'); // I don't want to create a stub for filter2

  60                                        // to write something to response. I'd like to it here.

  61  
  62      $this->toolkit->setRequest(new lmbHttpRequest('/any_path'));
  63  
  64      $fc->process();
  65  
  66      $response->reset();
  67      $response->start();
  68  
  69      $fc->process();
  70      $this->assertEqual($response->getResponseString(), 'some_content');
  71    }
  72  }
  73  
  74  ?>


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