示例#1
0
 public function testCorrectInjection()
 {
     $app = new App($this->container);
     $request = (new Request())->withUri(new Uri('/load'))->withMethod('GET');
     $response = new Response();
     $response = $app->run($request, $response);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('eureka', $response->getBody()->__toString());
 }
示例#2
0
文件: DiTest.php 项目: gianarb/penny
 public function testInjectionHttpFlow()
 {
     $this->container->set('troyan', 'call me');
     $app = new App($this->container);
     $request = (new ServerRequest())->withUri(new Uri('/'))->withMethod('GET');
     $response = new Response();
     $response = $app->run($request, $response);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('call me', $response->getBody()->__toString());
 }
示例#3
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();
 }
示例#4
0
<?php

use Penny\App;
use Zend\Diactoros\Response\SapiEmitter;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
$app = new App();
$emitter = new SapiEmitter();
$emitter->emit($app->run());
示例#5
0
文件: AppTest.php 项目: gianarb/penny
 public function testRouteInfoNotInstanceOfRouteInfoInterface()
 {
     $container = $this->prophesize(ContainerInterface::class);
     $request = (new ServerRequest())->withUri(new Uri('/'))->withMethod('GET');
     $response = new Response();
     $dispatcher = function () use($request) {
         return 'callback';
     };
     $httpFlowEvent = $this->prophesize(EventInterface::class);
     $eventManager = $this->prophesize(EventManagerInterface::class);
     $container->has('router')->willReturn(true);
     $container->get('http_flow_event')->willReturn($httpFlowEvent);
     $container->get('dispatcher')->willReturn($dispatcher);
     $container->get('event_manager')->willReturn($eventManager);
     $app = new App($container->reveal());
     $response = $app->run($request, $response);
 }
示例#6
0
<?php

use Penny\App;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
$app = new App();
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$response = new \Symfony\Component\HttpFoundation\Response();
$app->run($request, $response)->send();