コード例 #1
0
 /**
  * Special override to set up the app with controllers that have a dynamic middleware. This is better suited to
  * testing Middleware so that the developer can pass in the middleware and subsequently perform tests on it
  *
  * @param array $env
  * @param array $middlewares
  */
 public function setUpApp($env = array(), $middlewares = array())
 {
     parent::setUpApp($env);
     $this->app->setModelLoaders(array(new \MABI\DirectoryModelLoader(__DIR__ . '/../TestApp/TestModelDir', $this->app, 'mabiTesting')));
     $dirControllerLoader = new \MABI\DirectoryControllerLoader(__DIR__ . '/../TestApp/TestControllerDir', $this->app, 'mabiTesting');
     foreach ($dirControllerLoader->getControllers() as $controller) {
         if (get_class($controller) == 'mabiTesting\\JustAController') {
             $this->controller = $controller;
             if (!empty($middlewares)) {
                 foreach ($middlewares as $middleware) {
                     $this->controller->addMiddleware($middleware);
                 }
                 $this->controller->addMiddleware(new \MABI\Middleware\AnonymousIdentifier());
             }
         }
         if (get_class($controller) == 'mabiTesting\\ModelBController') {
             $this->restController = $controller;
             if (!empty($middlewares)) {
                 foreach ($middlewares as $middleware) {
                     $this->restController->addMiddleware($middleware);
                 }
                 $this->restController->addMiddleware(new \MABI\Middleware\AnonymousIdentifier());
             }
         }
     }
     $this->app->setControllerLoaders(array($dirControllerLoader));
 }
コード例 #2
0
 public function setUpApp($env = array(), $withCache = false)
 {
     \Slim\Environment::mock($env);
     $this->app = new App();
     $this->dataConnectionMock = $this->getMock('\\MABI\\Testing\\MockDataConnection', array('findOneByField', 'query', 'insert', 'save', 'deleteByField', 'clearAll', 'getNewId', 'findAll', 'findAllByField'));
     $this->app->addDataConnection('default', $this->dataConnectionMock);
     if ($withCache) {
         $this->app->addCacheRepository('system', 'file', array('path' => 'TestApp/cache'));
     }
     $this->app->getErrorResponseDictionary()->overrideErrorResponses(new Errors());
 }
コード例 #3
0
 function testGetModelClasses()
 {
     $app = new App();
     $newExt = new Extension($app);
     $app->setModelLoaders(array(new DirectoryModelLoader('TestApp/TestModelDir', $app, 'mabiTesting')));
     $newExt->setModelLoaders(array(new DirectoryModelLoader('TestApp/TestExtensionDir/TestModelDir', $app, 'mabiTesting\\testExtension')));
     $app->addExtension($newExt);
     $outClasses = $app->getModelClasses();
     $this->assertContains('mabiTesting\\testExtension\\ModelC', $outClasses);
     $this->assertContains('mabiTesting\\FullModel', $outClasses);
     $this->assertContains('mabiTesting\\ModelA', $outClasses);
     $this->assertContains('mabiTesting\\ModelB', $outClasses);
     $this->assertCount(4, $outClasses);
 }
コード例 #4
0
ファイル: AppTest.php プロジェクト: prolificinteractive/mabi
 function testClearSingleton()
 {
     $sing1App = \MABI\App::getSingletonApp();
     \MABI\App::clearSingletonApp();
     $sing2App = \MABI\App::getSingletonApp();
     $this->assertNotEquals($sing2App, $sing1App);
 }