lithium\tests\mocks\core\MockMethodFiltering::method PHP Method

method() public method

public method ( $data )
    public function method($data)
    {
        $data[] = 'Starting outer method call';
        $result = $this->_filter(__METHOD__, compact('data'), function ($self, $params, $chain) {
            $params['data'][] = 'Inside method implementation';
            return $params['data'];
        });
        $result[] = 'Ending outer method call';
        return $result;
    }

Usage Example

Esempio 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);
 }
MockMethodFiltering