コード例 #1
0
 public function testFilterOrder()
 {
     $filter = new FilterChain();
     $filter->addFilter(new LowerCase())->addFilter(new StripUpperCase());
     $value = 'AbC';
     $valueExpected = 'abc';
     $this->assertEquals($valueExpected, $filter->filter($value));
 }
コード例 #2
0
 /**
  * Tests MvcLite\FilterChain::addFilter().
  *
  * @dataProvider provideAddFilter
  */
 public function testAddFilter($filter)
 {
     $sut = new FilterChain();
     $result = $sut->addFilter($filter);
     $this->assertSame($result, $sut);
 }
コード例 #3
0
ファイル: test.php プロジェクト: lnmpzkang/DesignPattern
<?php

require_once './Filter.php';
require_once './HTMLFilter.php';
require_once './LengthFilter.php';
require_once './FilterChain.php';
require_once './MsgProcessor.php';
$msg = "<p>hello, i am tom.how are you?</p>";
$filter_chain = new FilterChain();
$filter_chain->addFilter(new HTMLFilter())->addFilter(new LengthFilter());
$msg_processor = new MsgProcessor($msg, $filter_chain);
echo $msg_processor->process() . "\n";