/** * test controller execution */ public function testExecute() { // create an instance $controller = CCController::create('CCUnit::Test'); // did it work? $this->assertTrue($controller->execute() instanceof CCResponse); // check the reuslt $this->assertEquals("Hello World", $controller->execute()->body); // check the reuslt $this->assertEquals("Test Action", $controller->execute('detail')->body); // check the reuslt $this->assertEquals("Test Param", $controller->execute('param', array('Param'))->body); // check the reuslt $this->assertEquals("Test Echo", $controller->execute('print')->body); // check the reuslt $this->assertEquals("Test Return", $controller->execute('return')->body); // turn on wake event $controller->wake_has_response = true; // now wake should respond $this->assertEquals("Hello Wake", $controller->execute()->body); // another one $this->assertEquals("Hello Wake", $controller->execute('param', array('Param'))->body); }
/** * Check and complete a route * * @param CCRoute $route * @param mixed $raw_route * @return false|CCRoute */ protected static function configure($route, $raw_route) { // deal with emptiness if (is_null($raw_route)) { return false; } // this might be a controller if (is_string($raw_route)) { // are there overwrite parameters? if (strpos($raw_route, '?') !== false) { $route->params = explode(',', CCStr::suffix($raw_route, '?')); $raw_route = CCStr::cut($raw_route, '?'); } // is there a overwrite action? if (strpos($raw_route, '@') !== false) { $route->action = CCStr::suffix($raw_route, '@'); $raw_route = CCStr::cut($raw_route, '@'); } // try creating an controller instance $controller = CCController::create($raw_route); // set the callback on controller execute $route->callback = array($controller, 'execute'); } elseif (is_callable($raw_route)) { $route->callback = $raw_route; } return $route; }