function testRunOkFullCircle() { $filter = new lmbFullPageCacheFilter('cache.ini', $this->cache_dir, $this->user); $fc = new lmbFilterChain(); $fc->registerFilter($filter); $fc->registerFilter($this->filter2); $rules = ' [rull-all-to-all] path_regex = ~^.*$~ policy = allow '; $this->toolkit->setConf('cache.ini', new lmbFakeIni($rules)); $this->filter2->expectOnce('run'); $response = $this->toolkit->getResponse(); $response->start(); $response->write('some_content'); // I don't want to create a stub for filter2 // to write something to response. I'd like to it here. $this->toolkit->setRequest(new lmbHttpRequest('/any_path')); $fc->process(); $response->reset(); $response->start(); $fc->process(); $this->assertEqual($response->getResponseString(), 'some_content'); }
function testRollBackOnException() { $stub = new FilterWorkingWithDbStub(); $stub->sql = "INSERT INTO test_db_table (title) VALUES ('hey')"; $stub->exception = new Exception('foo'); $this->assertEqual($this->db->count('test_db_table'), 0); $chain = new lmbFilterChain(); $chain->registerFilter(new lmbAutoDbTransactionFilter()); $chain->registerFilter($stub); try { $chain->process(); $this->assertTrue(false); } catch (Exception $e) { } $this->assertEqual($this->db->count('test_db_table'), 0); $this->assertIdentical($this->conn, $this->toolkit->getDefaultDbConnection()); }
function testFilterChainAsAFilter() { $f1 = new OutputFilter1(); $f2 = new OutputFilter2(); $fc = new lmbFilterChain(); $fc1 = new lmbFilterChain(); $fc1->registerFilter($f1); $fc2 = new lmbFilterChain(); $fc2->registerFilter($f2); $fc->registerFilter($fc1); $fc->registerFilter($fc2); ob_start(); $fc->process(); $str = ob_get_contents(); ob_end_clean(); $this->assertEqual($str, '<filter1></filter1><filter2></filter2>'); }
function process() { $this->_registerFilters(); parent::process(); }