Exemplo n.º 1
0
 /**
  * UnsupportedMiddlewareException
  */
 public function UnsupportedMiddlewareThrowsException(UnitTester $I)
 {
     $app = new Application([new \stdClass()]);
     $request = new ServerRequest();
     try {
         $app->run($request);
         $I->fail('Expected UnsupportedMiddlewareException was not thrown');
     } catch (\Exception $e) {
         $I->assertEquals(UnsupportedMiddlewareException::class, get_class($e));
     }
 }
Exemplo n.º 2
0
 /**
  * @dataProvider provideRouterData
  * @testdox      A known URL creates a DisplayPageCommand with the related ID
  */
 public function testKnownUrlCreatesDisplayPageCommand($id, $url)
 {
     $test = $this;
     $app = new Application([new RouterMiddleware($this->container), function (ServerRequestInterface $request, ResponseInterface $response, callable $next) use($test, $id) {
         $attributes = $request->getAttributes();
         $command = $attributes['command'];
         $test->assertInstanceOf(DisplayPageCommand::class, $command);
         $test->assertEquals($id, $command->id);
         return $next($request, $response);
     }]);
     $server = ['REQUEST_URI' => $url];
     $app->run(ServerRequestFactory::fromGlobals($server));
 }
Exemplo n.º 3
0
 public function RendererAddsTheEventDecorator(UnitTester $I)
 {
     $container = new Container();
     $container->set('ConfigDirectory', JPATH_ROOT);
     $container->registerServiceProvider(new StorageServiceProvider(), 'repository');
     $container->registerServiceProvider(new EventDispatcherServiceProvider(), 'dispatcher');
     $container->registerServiceProvider(new ExtensionFactoryServiceProvider(), 'extension_factory');
     $app = new Application([new RendererMiddleware(new Dispatcher(), $container), function (ServerRequestInterface $request, ResponseInterface $response, callable $next) use($I) {
         $body = $response->getBody();
         $I->assertEquals(EventDecorator::class, get_class($body));
         return $next($request, $response);
     }]);
     $app->run(new ServerRequest());
 }
Exemplo n.º 4
0
<?php

/**
 * Part of the Joomla CMS
 *
 * @copyright  Copyright (C) 2015 - 2016 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
use Joomla\Http\Application;
use Joomla\Http\Middleware\CommandBusMiddleware;
use Joomla\Http\Middleware\RendererMiddleware;
use Joomla\Http\Middleware\ResponseSenderMiddleware;
use Joomla\Http\Middleware\RouterMiddleware as DefaultRouterMiddleware;
use Joomla\J3Compatibility\Http\Middleware\RouterMiddleware as LegacyRouterMiddleware;
use Joomla\PageBuilder\RouterMiddleware as PageBuilderRouterMiddleware;
ini_set('date.timezone', 'UTC');
require_once 'libraries/vendor/autoload.php';
require_once 'init.php';
$container = initContainer();
$app = new Application([new ResponseSenderMiddleware(), new RendererMiddleware($container->get('dispatcher'), $container), new PageBuilderRouterMiddleware($container), new DefaultRouterMiddleware(), new LegacyRouterMiddleware(), new CommandBusMiddleware($container->get('command_bus'))]);
$response = $app->run($container->get('Request'));