map() public method

Maps a callback to a framework method.
public map ( string $name, callback $callback )
$name string Method name
$callback callback Callback function
Beispiel #1
0
 function testMapOverridesRegister()
 {
     $this->app->register('reg5', 'User');
     $user = $this->app->reg5();
     $this->assertTrue(is_object($user));
     $this->app->map('reg5', function () {
         return 123;
     });
     $user = $this->app->reg5();
     $this->assertEquals(123, $user);
 }
Beispiel #2
0
 function testFilterChaining()
 {
     $this->app->map('bye', function ($name) {
         return "Bye, {$name}!";
     });
     $this->app->before('bye', function (&$params, &$output) {
         $params[0] = 'Bob';
     });
     $this->app->before('bye', function (&$params, &$output) {
         $params[0] = 'Fred';
         return false;
     });
     $this->app->before('bye', function (&$params, &$output) {
         $params[0] = 'Ted';
     });
     $result = $this->app->bye('Joe');
     $this->assertEquals('Bye, Fred!', $result);
 }
 function testStaticClassMethodMapping()
 {
     $this->app->map('map4', array('Hello', 'sayBye'));
     $result = $this->app->map4();
     $this->assertEquals('goodbye', $result);
 }