コード例 #1
0
ファイル: EventFlowTest.php プロジェクト: amir20202000/penny
 public function setUp()
 {
     $config = Loader::load();
     $config['router'] = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
         $r->addRoute('GET', '/', ['TestApp\\Controller\\IndexController', 'index']);
     });
     $this->app = new App(Container\PHPDiFactory::buildContainer($config));
 }
コード例 #2
0
 public function setUp()
 {
     $config = Loader::load();
     $config['router'] = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
         $r->addRoute('GET', '/', [get_class($this), 'index']);
     });
     $config['dispatcher'] = \Di\object('PennyTest\\Utils\\FastSymfonyDispatcher')->constructor(\Di\get('router'), \Di\get('di'));
     $this->app = new App(Container\PHPDiFactory::buildContainer($config));
 }
コード例 #3
0
ファイル: AppLoaderTest.php プロジェクト: amir20202000/penny
 public function setUp()
 {
     chdir(__DIR__ . '/app/');
     $config = Loader::load();
     $config['router'] = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
         $r->addRoute('GET', '/load', ['TestApp\\Controller\\IndexController', 'loadedParams'], ['name' => 'load']);
     });
     $this->container = Container\PHPDiFactory::buildContainer($config);
 }
コード例 #4
0
ファイル: App.php プロジェクト: gianarb/penny
 /**
  * Application initialization.
  *
  * @param ContainerInterface $container Dependency Injection container.
  *
  * @throws Exception If no router is defined.
  */
 public function __construct(ContainerInterface $container = null)
 {
     if ($container === null) {
         $container = Container\PHPDiFactory::buildContainer(Loader::load());
     }
     if ($container->has('router') === false) {
         throw new Exception('Define router config');
     }
     $this->container = $container;
 }
コード例 #5
0
 public function testDispatcherErrorCallsListenerIndex()
 {
     $dispatcherExceptionListener = $this->prophesize(WhoopsListener::class);
     $response = $this->prophesize(Response::class);
     $request = (new Request())->withUri(new Uri('/pnf'))->withMethod('GET');
     $container = Container\PHPDiFactory::buildContainer(Loader::load());
     $container->set(WhoopsListener::class, $dispatcherExceptionListener->reveal());
     $app = new App($container);
     $app->run($request, $response->reveal());
     $dispatcherExceptionListener->onError(Argument::any())->shouldHaveBeenCalled();
 }
コード例 #6
0
ファイル: AppTest.php プロジェクト: gianarb/penny
 public function testBootstrapEventTriggered()
 {
     $config = Loader::load();
     $config['router'] = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
         $r->addRoute('GET', '/', [IndexController::class, 'index']);
     });
     $this->app = new App(Container\PHPDiFactory::buildContainer($config));
     $this->app->getContainer()->get('event_manager')->attach('bootstrap', function () {
         echo 'bootstrap triggered';
     });
     ob_start();
     $this->app->run();
     $content = ob_get_clean();
     $this->assertEquals('bootstrap triggered', $content);
 }
コード例 #7
0
ファイル: AppTest.php プロジェクト: userlond/penny
 /**
  * @expectedException \RuntimeException
  */
 public function testDispatcherShouldBeCallable()
 {
     $request = (new Request())->withUri(new Uri('/'))->withMethod('POST');
     $response = new Response();
     $config = Loader::load();
     $config['router'] = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
         $r->addRoute('GET', '/', ['TestApp\\Controller\\IndexController', 'index']);
     });
     $config['dispatcher'] = new \StdClass();
     $app = new App(Container\PHPDiFactory::buildContainer($config));
     $app->run($request, $response);
 }
コード例 #8
0
ファイル: LoaderTest.php プロジェクト: amir20202000/penny
 public function testLoadsByCustomPath()
 {
     $config = Loader::load('./config/custom/{{*}}{{,*.local}}.php');
     $this->assertTrue($config['nine']);
 }