Skip to content

Commit 8f05da5

Browse files
committed
ADDED TEST: exception thrown if PSR implemenation not found.
1 parent 5f6d05c commit 8f05da5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Tests/BridgeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace TheWebSolver\Codegarage\Lib;
1111

12+
use LogicException;
1213
use MiddlewareAdapter;
1314
use PHPUnit\Framework\TestCase;
1415
use TheWebSolver\Codegarage\Lib\PipelineBridge;
@@ -63,5 +64,15 @@ public function process(
6364
};
6465

6566
$this->assertSame( expected: 350, actual: $handler->handle( $request )->getStatusCode() );
67+
68+
PipelineBridge::resetMiddlewareAdapter();
69+
70+
// Must always throw exception if core PSR-15 implementation not used.
71+
if ( ! interface_exists( '\\Psr\\Http\\Server\\MiddlewareInterface' ) ) {
72+
$this->expectException( LogicException::class );
73+
$this->expectExceptionMessage( 'Cannot find implementation of PSR15 HTTP Server Middleware.' );
74+
75+
PipelineBridge::toMiddleware( middleware: '' );
76+
}
6677
}
6778
}

0 commit comments

Comments
 (0)