Exemplo n.º 1
0
 /**
  * Test whether this filter chain contains given callback
  *
  * @param  callable $callback
  * @return bool
  */
 public function containsCallback(callable $callback)
 {
     // Normalize the callback
     $pc = new ProgrammableCallback($callback);
     $callback = $pc->getCallback();
     foreach ($this->items as $filter) {
         if ($callback === $filter->getCallback()) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 protected function getProgrammableCallback()
 {
     $args = func_get_args();
     $programmableCallback = new ProgrammableCallback(array_shift($args));
     foreach ($args as $value) {
         $programmableCallback->addParameterByValue($value);
     }
     return $programmableCallback;
 }
 /**
  * @testdox executeFilter() passes NULL to the callback if a variable is missing
  */
 public function testExecuteFilterMissingVar()
 {
     $filter = new ProgrammableCallback(function () {
         return func_get_args();
     });
     $filter->addParameterByValue('foo');
     $filter->addParameterByName('foo');
     $filter->addParameterByValue(42);
     $this->assertSame(['foo', null, 42], FilterProcessingDummy::__executeFilter($filter->asConfig(), ['logger' => new Logger()]));
 }
 /**
  * @testdox asConfig() preserves NULL values and empty arrays in the callback's parameters
  */
 public function testAsConfigPreserve()
 {
     $pc = new ProgrammableCallback(function () {
     });
     $pc->addParameterByValue(null);
     $pc->addParameterByValue([]);
     $config = $pc->asConfig();
     $this->assertSame([null, []], $config['params']);
 }