示例#1
0
 /**
  * @test
  * @covers Plum\Plum\Filter\CallbackFilter::__construct()
  * @covers Plum\Plum\Filter\CallbackFilter::filter()
  */
 public function filterShouldCallCallback()
 {
     $filter = new CallbackFilter(function ($item) {
         return true;
     });
     $this->assertTrue($filter->filter('foobar'));
 }
示例#2
0
 public function testCallback()
 {
     $called = false;
     $callback = function () use(&$called) {
         $called = true;
         return 'bar';
     };
     $filter = new CallbackFilter($callback);
     $result = $filter->filter('foo');
     $this->assertTrue($called);
     $this->assertEquals('bar', $result);
 }
 public function testCallbackFilter()
 {
     //simple test
     $postApply = ' and my applying';
     $filter = CallbackFilter::create(function ($value) use($postApply) {
         return $value . $postApply;
     });
     $this->assertEquals('one another value and my applying', $filter->apply('one another value'));
 }