Vendor lock
This commit is contained in:
1
vendor/zeuxisoo/slim-whoops/.coveralls.yml
vendored
Normal file
1
vendor/zeuxisoo/slim-whoops/.coveralls.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
json_path: coveralls-upload.json
|
21
vendor/zeuxisoo/slim-whoops/.editorconfig
vendored
Normal file
21
vendor/zeuxisoo/slim-whoops/.editorconfig
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
4
vendor/zeuxisoo/slim-whoops/.gitignore
vendored
Normal file
4
vendor/zeuxisoo/slim-whoops/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/vendor
|
||||
/report
|
||||
|
||||
composer.phar
|
25
vendor/zeuxisoo/slim-whoops/.travis.yml
vendored
Normal file
25
vendor/zeuxisoo/slim-whoops/.travis.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
language: php
|
||||
|
||||
dist: trusty
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.1
|
||||
env: ANALYSIS='true'
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: nightly
|
||||
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
before_script:
|
||||
- composer require php-coveralls/php-coveralls:^2.1
|
||||
- composer install -n
|
||||
|
||||
script:
|
||||
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
|
||||
- vendor/bin/phpunit
|
||||
|
||||
after_success:
|
||||
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/php-coveralls --coverage_clover=clover.xml -v ; fi
|
31
vendor/zeuxisoo/slim-whoops/Makefile
vendored
Normal file
31
vendor/zeuxisoo/slim-whoops/Makefile
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
.PHONY: examples tests
|
||||
|
||||
all:
|
||||
@echo
|
||||
@echo "Command : Description"
|
||||
@echo "------------- : ---------------------"
|
||||
@echo "make composer : Download the composer tools"
|
||||
@echo "make install : Install the development vendors and assets by composer"
|
||||
@echo "make examples : Run the examples"
|
||||
@echo "make tests : Run the test cases"
|
||||
@echo "make coverage : Get the test coverage"
|
||||
@echo "make clean : Clean the files"
|
||||
@echo
|
||||
|
||||
composer:
|
||||
@curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
install:
|
||||
@php composer.phar install
|
||||
|
||||
examples:
|
||||
@php -S localhost:8080 -t examples
|
||||
|
||||
tests:
|
||||
@php ./vendor/bin/phpunit
|
||||
|
||||
coverage:
|
||||
@php ./vendor/bin/phpunit --coverage-html ./report tests
|
||||
|
||||
clean:
|
||||
@rm -rf ./report
|
83
vendor/zeuxisoo/slim-whoops/README.md
vendored
Normal file
83
vendor/zeuxisoo/slim-whoops/README.md
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
# Slim whoops
|
||||
|
||||
PHP whoops error on slim framework
|
||||
|
||||
## Status
|
||||
|
||||
[](https://travis-ci.org/zeuxisoo/php-slim-whoops)
|
||||
[](https://coveralls.io/github/zeuxisoo/php-slim-whoops)
|
||||
[](https://packagist.org/packages/zeuxisoo/slim-whoops)
|
||||
[](https://github.com/zeuxisoo/php-slim-whoops/releases)
|
||||
|
||||
## Installation
|
||||
|
||||
Install the composer
|
||||
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
Edit `composer.json`
|
||||
|
||||
| Slim | Whoops | Version | Global Mode | PHP DI |
|
||||
| ---- | --------- | ------- | ----------- | ------ |
|
||||
| 1 | n/a | 0.1.* | no | no |
|
||||
| 2 | 1.* | 0.3.* | no | no |
|
||||
| 3 | <= 1.* | 0.4.* | no | no |
|
||||
| 3 | >= 2.* | 0.5.* | no | no |
|
||||
| 3 | >= 2.* | 0.6.* | yes | yes |
|
||||
| 4 | >= 2.* | 0.7.* | no | no |
|
||||
|
||||
For `Slim framework 4`, The `composer.json` will looks like
|
||||
|
||||
{
|
||||
"require": {
|
||||
"zeuxisoo/slim-whoops": "0.7.*"
|
||||
}
|
||||
}
|
||||
|
||||
Now, `install` or `update` the dependencies
|
||||
|
||||
php composer.phar install
|
||||
|
||||
## Basic Usage
|
||||
|
||||
Add to middleware with default settings
|
||||
|
||||
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware());
|
||||
|
||||
Or you can pass more settings to the `WhoopsMiddleware`
|
||||
|
||||
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
|
||||
'enable' => true,
|
||||
'editor' => 'sublime',
|
||||
'title' => 'Custom whoops page title',
|
||||
]));
|
||||
|
||||
## Custom Handler Usage
|
||||
|
||||
In this usage, you can make your own handler for whoops, like:
|
||||
|
||||
$simplyErrorHandler = function($exception, $inspector, $run) {
|
||||
$message = $exception->getMessage();
|
||||
$title = $inspector->getExceptionName();
|
||||
|
||||
echo "{$title} -> {$message}";
|
||||
exit;
|
||||
};
|
||||
|
||||
And then pass it to the `WhoopsMiddleware`:
|
||||
|
||||
new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([], [$simplyErrorHandler]);
|
||||
|
||||
## Important Note
|
||||
|
||||
Version `0.3.0` or above version
|
||||
|
||||
- The `whoops` library is installed by default base on the [Whoops Framework Integration Document][1]
|
||||
|
||||
Version `0.2.0`
|
||||
|
||||
- You must to install the `whoops` library manually.
|
||||
|
||||
|
||||
|
||||
[1]: https://github.com/filp/whoops/blob/master/docs/Framework%20Integration.md#contributing-an-integration-with-a-framework "Whoops Framework Integration Document"
|
32
vendor/zeuxisoo/slim-whoops/composer.json
vendored
Normal file
32
vendor/zeuxisoo/slim-whoops/composer.json
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "zeuxisoo/slim-whoops",
|
||||
"type": "library",
|
||||
"description": "PHP whoops error on slim framework",
|
||||
"keywords": ["error", "exception", "whoops", "slim"],
|
||||
"homepage": "https://github.com/zeuxisoo/php-slim-whoops/",
|
||||
"license": "BSD-2-Clause",
|
||||
"authors": [{
|
||||
"name": "Zeuxis Lo",
|
||||
"email": "seekstudio@gmail.com",
|
||||
"homepage": "http://www.not.im/",
|
||||
"role": "Developer"
|
||||
}],
|
||||
"require": {
|
||||
"php": "^7.1",
|
||||
"filp/whoops": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"slim/slim": "4.3.*",
|
||||
"slim/psr7": "0.6.*",
|
||||
"slim/http": "0.8",
|
||||
"slim/twig-view": "dev-master#472f2c1",
|
||||
"equip/dispatch": "^2.0",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Zeuxisoo\\Whoops\\Slim\\": "src/Zeuxisoo/Whoops/Slim",
|
||||
"Zeuxisoo\\Whoops\\Slim\\Tests\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
2451
vendor/zeuxisoo/slim-whoops/composer.lock
generated
vendored
Normal file
2451
vendor/zeuxisoo/slim-whoops/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
vendor/zeuxisoo/slim-whoops/examples/index.php
vendored
Normal file
31
vendor/zeuxisoo/slim-whoops/examples/index.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
use Zeuxisoo\Whoops\Slim\WhoopsMiddleware;
|
||||
|
||||
// Instance
|
||||
$app = AppFactory::create();
|
||||
|
||||
// Middleware
|
||||
$app->add(new WhoopsMiddleware());
|
||||
|
||||
// Route parser
|
||||
$routeParser = $app->getRouteCollector()->getRouteParser();
|
||||
|
||||
// Routes
|
||||
$app->get('/', function (Request $request, Response $response, $args) use ($routeParser) {
|
||||
$response->getBody()->write(file_get_contents('template/index.php'));
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->get('/url-path-not-exists', function(Request $request, Response $response, $args) use ($routeParser) {
|
||||
return $routeParser->urlFor('hello');
|
||||
});
|
||||
|
||||
// Run
|
||||
$app->run();
|
39
vendor/zeuxisoo/slim-whoops/examples/template/index.php
vendored
Normal file
39
vendor/zeuxisoo/slim-whoops/examples/template/index.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Slim Whoops Examples</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
</head>
|
||||
<style type="text/css">
|
||||
.part {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h3>Examples</h3>
|
||||
<hr>
|
||||
<div class="part">
|
||||
<h5>Usage</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30%">File / Path</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/url-path-not-exists">/url-path-not-exists</a>
|
||||
</td>
|
||||
<td>Basic middleware usage</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
36
vendor/zeuxisoo/slim-whoops/phpunit.xml.dist
vendored
Normal file
36
vendor/zeuxisoo/slim-whoops/phpunit.xml.dist
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.1/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutChangesToGlobalState="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
cacheResult="false"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Slim Whoops">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log
|
||||
type="coverage-html"
|
||||
target="./report"
|
||||
lowUpperBound="20"
|
||||
highLowerBound="50"
|
||||
/>
|
||||
</logging>
|
||||
</phpunit>
|
116
vendor/zeuxisoo/slim-whoops/src/Zeuxisoo/Whoops/Slim/WhoopsGuard.php
vendored
Normal file
116
vendor/zeuxisoo/slim-whoops/src/Zeuxisoo/Whoops/Slim/WhoopsGuard.php
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Zeuxisoo\Whoops\Slim;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\App as SlimApp;
|
||||
use Whoops\Run as WhoopsRun;
|
||||
use Whoops\Util\Misc;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Handler\JsonResponseHandler;
|
||||
|
||||
class WhoopsGuard {
|
||||
|
||||
protected $settings = [];
|
||||
protected $request = null;
|
||||
protected $handlers = [];
|
||||
|
||||
/**
|
||||
* Instance the whoops guard object
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct($settings = []) {
|
||||
$this->settings = array_merge([
|
||||
'enable' => true,
|
||||
'editor' => '',
|
||||
'title' => '',
|
||||
], $settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the server request object
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @return void
|
||||
*/
|
||||
public function setRequest(ServerRequestInterface $request): void {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the custom handlers for whoops
|
||||
*
|
||||
* @param array $handlers
|
||||
* @return void
|
||||
*/
|
||||
public function setHandlers(array $handlers): void {
|
||||
$this->handlers = $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the whoops guard object
|
||||
*
|
||||
* @return WhoopsRun|null
|
||||
*/
|
||||
public function install(): ?WhoopsRun {
|
||||
if ($this->settings['enable'] === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Enable PrettyPageHandler with editor options
|
||||
$prettyPageHandler = new PrettyPageHandler();
|
||||
|
||||
if (empty($this->settings['editor']) === false) {
|
||||
$prettyPageHandler->setEditor($this->settings['editor']);
|
||||
}
|
||||
|
||||
if (empty($this->settings['title']) === false) {
|
||||
$prettyPageHandler->setPageTitle($this->settings['title']);
|
||||
}
|
||||
|
||||
// Add more information to the PrettyPageHandler
|
||||
$contentCharset = '<none>';
|
||||
if (
|
||||
method_exists($this->request, 'getContentCharset') === true &&
|
||||
$this->request->getContentCharset() !== null
|
||||
) {
|
||||
$contentCharset = $this->request->getContentCharset();
|
||||
}
|
||||
|
||||
$prettyPageHandler->addDataTable('Slim Application', [
|
||||
'Version' => SlimApp::VERSION,
|
||||
'Accept Charset' => $this->request->getHeader('ACCEPT_CHARSET') ?: '<none>',
|
||||
'Content Charset' => $contentCharset,
|
||||
'HTTP Method' => $this->request->getMethod(),
|
||||
'Path' => $this->request->getUri()->getPath(),
|
||||
'Query String' => $this->request->getUri()->getQuery() ?: '<none>',
|
||||
'Base URL' => (string) $this->request->getUri(),
|
||||
'Scheme' => $this->request->getUri()->getScheme(),
|
||||
'Port' => $this->request->getUri()->getPort(),
|
||||
'Host' => $this->request->getUri()->getHost(),
|
||||
]);
|
||||
|
||||
// Set Whoops to default exception handler
|
||||
$whoops = new \Whoops\Run;
|
||||
$whoops->pushHandler($prettyPageHandler);
|
||||
|
||||
// Enable JsonResponseHandler when request is AJAX
|
||||
if (Misc::isAjaxRequest() === true){
|
||||
$whoops->pushHandler(new JsonResponseHandler());
|
||||
}
|
||||
|
||||
// Add each custom handler to whoops handler stack
|
||||
if (empty($this->handlers) === false) {
|
||||
foreach($this->handlers as $handler) {
|
||||
$whoops->pushHandler($handler);
|
||||
}
|
||||
}
|
||||
|
||||
$whoops->register();
|
||||
|
||||
return $whoops;
|
||||
}
|
||||
|
||||
}
|
43
vendor/zeuxisoo/slim-whoops/src/Zeuxisoo/Whoops/Slim/WhoopsMiddleware.php
vendored
Normal file
43
vendor/zeuxisoo/slim-whoops/src/Zeuxisoo/Whoops/Slim/WhoopsMiddleware.php
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Zeuxisoo\Whoops\Slim;
|
||||
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class WhoopsMiddleware implements MiddlewareInterface {
|
||||
|
||||
protected $settings = [];
|
||||
protected $handlers = [];
|
||||
|
||||
/**
|
||||
* Instance the whoops middleware object
|
||||
*
|
||||
* @param array $settings
|
||||
* @param array $handlers
|
||||
*/
|
||||
public function __construct(array $settings = [], array $handlers = []) {
|
||||
$this->settings = $settings;
|
||||
$this->handlers = $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the requests
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param RequestHandlerInterface $handler
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
|
||||
$whoopsGuard = new WhoopsGuard($this->settings);
|
||||
$whoopsGuard->setRequest($request);
|
||||
$whoopsGuard->setHandlers($this->handlers);
|
||||
$whoopsGuard->install();
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
}
|
10
vendor/zeuxisoo/slim-whoops/tests/TestCase.php
vendored
Normal file
10
vendor/zeuxisoo/slim-whoops/tests/TestCase.php
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Zeuxisoo\Whoops\Slim\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
|
||||
|
||||
abstract class TestCase extends PhpUnitTestCase {
|
||||
|
||||
}
|
86
vendor/zeuxisoo/slim-whoops/tests/WhoopsGuardTest.php
vendored
Normal file
86
vendor/zeuxisoo/slim-whoops/tests/WhoopsGuardTest.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Zeuxisoo\Whoops\Slim\Tests;
|
||||
|
||||
use Slim\Psr7\Factory\ServerRequestFactory;
|
||||
use Whoops\Run as WhoopsRun;
|
||||
use Zeuxisoo\Whoops\Slim\WhoopsGuard;
|
||||
|
||||
class WhoopsGuardTest extends TestCase {
|
||||
|
||||
public function testShouldReturnWhoops() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "http://example.com/");
|
||||
|
||||
$guard = new WhoopsGuard();
|
||||
$guard->setRequest($request);
|
||||
|
||||
$whoops = $guard->install();
|
||||
|
||||
$this->assertInstanceOf(WhoopsRun::class, $whoops);
|
||||
}
|
||||
|
||||
public function testShouldNotReturnWhoopsWhenDisabled() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "http://example.com/");
|
||||
|
||||
$guard = new WhoopsGuard([
|
||||
'enable' => false,
|
||||
]);
|
||||
$guard->setRequest($request);
|
||||
|
||||
$whoops = $guard->install();
|
||||
|
||||
$this->assertNull($whoops);
|
||||
}
|
||||
|
||||
public function testSetCustomHandlers() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "http://example.com/");
|
||||
|
||||
$guard = new WhoopsGuard();
|
||||
$guard->setRequest($request);
|
||||
$guard->setHandlers([
|
||||
function($exception, $inspector, $run) {
|
||||
$message = $exception->getMessage();
|
||||
$title = $inspector->getExceptionName();
|
||||
|
||||
echo "{$title} -> {$message}";
|
||||
exit;
|
||||
}
|
||||
]);
|
||||
|
||||
$whoops = $guard->install();
|
||||
|
||||
$this->assertInstanceOf(WhoopsRun::class, $whoops);
|
||||
|
||||
// Current handlers: prettyPageHandler, customHandler
|
||||
$this->assertEquals(2, count($whoops->getHandlers()));
|
||||
}
|
||||
|
||||
public function testSetEditor() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "http://example.com/");
|
||||
|
||||
$guard = new WhoopsGuard([ 'editor' => 'sublime', ]);
|
||||
$guard->setRequest($request);
|
||||
|
||||
$whoops = $guard->install();
|
||||
|
||||
$prettyPageHandler = $whoops->getHandlers()[0];
|
||||
|
||||
$this->assertEquals(
|
||||
$prettyPageHandler->getEditorHref('/foo/bar.php', 10),
|
||||
'subl://open?url=file://%2Ffoo%2Fbar.php&line=10'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPageTitle() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "http://example.com/");
|
||||
|
||||
$guard = new WhoopsGuard([ 'title' => 'Hello World', ]);
|
||||
$guard->setRequest($request);
|
||||
|
||||
$whoops = $guard->install();
|
||||
|
||||
$prettyPageHandler = $whoops->getHandlers()[0];
|
||||
|
||||
$this->assertEquals($prettyPageHandler->getPagetitle(), 'Hello World');
|
||||
}
|
||||
|
||||
}
|
34
vendor/zeuxisoo/slim-whoops/tests/WhoopsMiddlewareTest.php
vendored
Normal file
34
vendor/zeuxisoo/slim-whoops/tests/WhoopsMiddlewareTest.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Zeuxisoo\Whoops\Slim\Tests;
|
||||
|
||||
use Psr\http\Message\RequestInterface;
|
||||
use Slim\Psr7\Factory\ServerRequestFactory;
|
||||
use Slim\Psr7\Factory\ResponseFactory;
|
||||
use Equip\Dispatch\MiddlewareCollection;
|
||||
use Zeuxisoo\Whoops\Slim\WhoopsMiddleware;
|
||||
|
||||
class WhoopsMiddlewareTest extends TestCase {
|
||||
|
||||
public function testInstall() {
|
||||
$request = (new ServerRequestFactory)->createServerRequest("GET", "https://example.com/");
|
||||
|
||||
$default = function(RequestInterface $request) {
|
||||
$response = (new ResponseFactory)->createResponse();
|
||||
$response->getBody()->write("Success");
|
||||
|
||||
return $response;
|
||||
};
|
||||
|
||||
$collection = new MiddlewareCollection([
|
||||
new WhoopsMiddleware()
|
||||
]);
|
||||
|
||||
$response = $collection->dispatch($request, $default);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals("Success", $response->getBody());
|
||||
}
|
||||
|
||||
}
|
4
vendor/zeuxisoo/slim-whoops/tests/bootstrap.php
vendored
Normal file
4
vendor/zeuxisoo/slim-whoops/tests/bootstrap.php
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(dirname(__FILE__)).'/vendor/autoload.php';
|
Reference in New Issue
Block a user