public function run_handler($topic, array $args = array()) { if (is_object($topic)) { $component = $topic->component; } else { $component = $topic; $topic = $this->get_component_node($component); } $context = new midcom_core_context(null, $topic); $context->set_current(); $context->set_key(MIDCOM_CONTEXT_URI, midcom_connection::get_url('self') . $topic->name . '/' . implode('/', $args) . '/'); // Parser Init: Generate arguments and instantiate it. $context->parser = midcom::get('serviceloader')->load('midcom_core_service_urlparser'); $context->parser->parse($args); $handler = $context->get_handler($topic); $context->set_key(MIDCOM_CONTEXT_CONTENTTOPIC, $topic); $this->assertTrue(is_a($handler, 'midcom_baseclasses_components_interface'), $component . ' found no handler for ./' . implode('/', $args) . '/'); $result = $handler->handle(); $this->assertTrue($result !== false, $component . ' handle returned false on ./' . implode('/', $args) . '/'); $data =& $handler->_context_data[$context->id]['handler']->_handler['handler'][0]->_request_data; if (is_object($result) && $result instanceof midcom_response) { $data['__openpsa_testcase_response'] = $result; } $data['__openpsa_testcase_handler'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][0]; $data['__openpsa_testcase_handler_method'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][1]; // added to simulate http uri composition $_SERVER['REQUEST_URI'] = $context->get_key(MIDCOM_CONTEXT_URI); return $data; }