/** set up */
 public function setUp()
 {
     $this->createDatabase();
     Registry::put($configurator = new MockConfigurator(), '__configurator');
     Registry::put(new Logger($configurator), '__logger');
     ActiveRecord::close_connection();
 }
 /**
  * Framework entry point
  *
  * @return void.
  */
 public function dispatch()
 {
     include_once 'action/controller/http/HTTPResponse.php';
     include_once 'action/controller/http/HTTPRequest.php';
     $request = new HTTPRequest();
     $response = new HTTPResponse();
     try {
         $configurator = $this->manager->getConfigurator();
         Registry::put($configurator, '__configurator');
         Registry::put($logger = new Logger($configurator), '__logger');
         $ap = $configurator->getApplicationPath();
         // application path
         $an = $configurator->getApplicationName();
         // application name
         $logger->debug('[Medick] >> version: ' . Medick::getVersion() . ' ready for ' . $an);
         $logger->debug('[Medick] >> Application path ' . $ap);
         $routes_path = $ap . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . $an . '.routes.php';
         include_once $routes_path;
         // load routes
         $logger->debug('[Medick] >> Config File: ' . str_replace($ap, '${' . $an . '}', $configurator->getConfigFile()));
         $logger->debug('[Medick] >> Routes loaded from: ' . str_replace($ap, '${' . $an . '}', $routes_path));
         ActionControllerRouting::recognize($request)->process($request, $response)->dump();
     } catch (Exception $ex) {
         ActionController::process_with_exception($request, $response, $ex)->dump();
         $logger->warn($ex->getMessage());
     }
 }
 /** set up */
 public function setUp()
 {
     Registry::put($configurator = new MockConfigurator(), '__configurator');
     Registry::put(new Logger($configurator), '__logger');
     ActiveRecord::close_connection();
     $author = new Author();
     $author->name = 'Andrei Cristescu';
     $author->email = 'andrei@foocompany.com';
     $id = $author->save();
     $book = new Book();
     $book->author_id = $id;
     $book->title = 'The End is NEAR!';
     $book->save();
 }
Example #4
0
 /** set up this test case, we insert 3 fileds in DB table */
 public function setUp()
 {
     Registry::put($configurator = new MockConfigurator(), '__configurator');
     Registry::put(new Logger($configurator), '__logger');
     ActiveRecord::close_connection();
     $author = new Author();
     $author->name = "Andrei Cristescu";
     $author->email = "andrei.cristescu@foo-factory.info";
     $this->authors[] = $author;
     $author->insert();
     $author = new Author();
     $author->name = "Cristescu";
     $this->authors[] = $author;
     $author->insert();
     $author = new Author();
     $author->name = "Andrei";
     $this->authors[] = $author;
     $author->insert();
 }
Example #5
0
 /**
  * Creates a Controller Instance
  * 
  * @throws RoutingException
  * @return ActionControllerBase
  */
 public function createControllerInstance(Request $request)
 {
     if (!$this->isLoaded) {
         $this->load($request);
     }
     try {
         // Registry::get('__logger')->debug('[Medick] >> found ' . $this->toString());
         return Registry::put(new Injector(), '__injector')->inject('controller', $request->getParameter('controller'));
     } catch (FileNotFoundException $fnfEx) {
         throw new RoutingException('Cannot create a controller instance, ' . $fnfEx->getMessage());
     }
 }