-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSlim3Test.php
More file actions
44 lines (35 loc) · 1.33 KB
/
Copy pathSlim3Test.php
File metadata and controls
44 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare (strict_types=1);
namespace PhpMiddlewareTest\PhpDebugBar;
use PhpMiddleware\PhpDebugBar\ConfigProvider;
use PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Slim\App;
use Slim\Http\Environment;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\StreamFactory;
final class Slim3Test extends AbstractMiddlewareRunnerTest
{
protected function dispatchApplication(array $server, array $pipe = []): ResponseInterface
{
$app = new App();
$container = $app->getContainer();
$container[ResponseFactoryInterface::class] = new ResponseFactory();
$container[StreamFactoryInterface::class] = new StreamFactory();
$container['environment'] = function() use ($server) {
return new Environment($server);
};
$config = ConfigProvider::getConfig();
foreach ($config['dependencies']['factories'] as $key => $factory) {
$container[$key] = new $factory();
}
$middleware = $container->get(PhpDebugBarMiddleware::class);
$app->add($middleware);
foreach ($pipe as $pattern => $middleware) {
$app->get($pattern, $middleware);
}
return $app->run(true);
}
}