method() public method

public method ( $data )
Ejemplo n.º 1
0
 public function testMethodFiltering()
 {
     $test = new MockMethodFiltering();
     $result = $test->method(array('Starting test'));
     $expected = array('Starting test', 'Starting outer method call', 'Inside method implementation', 'Ending outer method call');
     $this->assertEqual($expected, $result);
     $test->applyFilter('method', function ($self, $params, $chain) {
         $params['data'][] = 'Starting filter';
         $result = $chain->next($self, $params, $chain);
         $result[] = 'Ending filter';
         return $result;
     });
     $result = $test->method(array('Starting test'));
     $expected = array('Starting test', 'Starting outer method call', 'Starting filter', 'Inside method implementation', 'Ending filter', 'Ending outer method call');
     $this->assertEqual($expected, $result);
     $test->applyFilter('method', function ($self, $params, $chain) {
         $params['data'][] = 'Starting inner filter';
         $result = $chain->next($self, $params, $chain);
         $result[] = 'Ending inner filter';
         return $result;
     });
     $result = $test->method(array('Starting test'));
     $expected = array('Starting test', 'Starting outer method call', 'Starting filter', 'Starting inner filter', 'Inside method implementation', 'Ending inner filter', 'Ending filter', 'Ending outer method call');
     $this->assertEqual($expected, $result);
 }