Example #1
0
 /**
  * Get ServiceProvider object
  *
  * @return \Tlumx\ServiceProvider
  */
 public function getServiceProvider()
 {
     return $this->_app->getServiceProvider();
 }
Example #2
0
 /**
  * @runInSeparateProcess
  */
 public function testInvalidAddMiddlewaresWhenCall()
 {
     $_SERVER = array('REQUEST_METHOD' => 'GET', 'HTTP_HOST' => 'site.com', 'REQUEST_URI' => '/some-router');
     require __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'FooController.php';
     $app = new Application(['controllers' => ['foo' => 'Foo\\FooController']]);
     $app->getServiceProvider()->getRouter()->setRoute('index', ['GET'], '/some-router', ['controller' => 'foo', 'action' => 'about']);
     $app->getServiceProvider()->set('exception_handler', $this->getMyExceptionHandler());
     $app->add(function ($req, $res, $next) {
         $res->write('AM1Start');
         $res = $next($req, $res);
         $res->write('AM1End');
         return $res;
     });
     $app->add(function ($req, $res, $next) use($app) {
         $app->add(function ($req, $res, $next) {
             return $next($req, $res);
         });
         $res = $next($req, $res);
     });
     $app->run();
     $this->expectOutputString('Error: Middleware can’t be added');
 }