Skip to content

Commit 5cc7545

Browse files
committed
Test case
1 parent 783fc9b commit 5cc7545

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/PhpDebugBarMiddleware.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Psr\Http\Message\ResponseInterface;
88
use Psr\Http\Message\ServerRequestInterface;
99
use Psr\Http\Message\UriInterface;
10+
use Slim\Http\Uri;
1011
use Zend\Diactoros\Response;
1112
use Zend\Diactoros\Response\HtmlResponse;
1213
use Zend\Diactoros\Response\Serializer;
@@ -109,7 +110,7 @@ private function getStaticFile(UriInterface $uri)
109110
private function extractPath(UriInterface $uri)
110111
{
111112
// Slim3 compatibility
112-
if (method_exists($uri, 'getBasePath')) {
113+
if ($uri instanceof Uri) {
113114
$basePath = $uri->getBasePath();
114115
if (!empty($basePath)) {
115116
return $basePath;

test/Slim3Test.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ public function testAppendJsIntoHtmlContent()
2828
public function testGetStatics()
2929
{
3030
$response = $this->dispatchApplication([
31+
'DOCUMENT_ROOT' => __DIR__,
32+
'REMOTE_ADDR' => '127.0.0.1',
33+
'REMOTE_PORT' => '40226',
34+
'SERVER_SOFTWARE' => 'PHP 7.0.8-3ubuntu3 Development Server',
35+
'SERVER_PROTOCOL' => 'HTTP/1.1',
36+
'SERVER_NAME' => '0.0.0.0',
37+
'SERVER_PORT' => '8080',
3138
'REQUEST_URI' => '/phpdebugbar/debugbar.js',
3239
'REQUEST_METHOD' => 'GET',
33-
'HTTP_ACCEPT' => 'text/html',
40+
'SCRIPT_NAME' => '/phpdebugbar/debugbar.js',
41+
'SCRIPT_FILENAME' => __FILE__,
42+
'PHP_SELF' => '/phpdebugbar/debugbar.js',
43+
'HTTP_HOST' => '0.0.0.0:8080',
44+
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
3445
]);
3546

3647
$contentType = $response->getHeaderLine('Content-type');

0 commit comments

Comments
 (0)