mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
More middleware tests
This commit is contained in:
31
tests/Traits/Http/MocksMiddlewareClosure.php
Normal file
31
tests/Traits/Http/MocksMiddlewareClosure.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Traits\Http;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use BadFunctionCallException;
|
||||
|
||||
trait MocksMiddlewareClosure
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Provide a closure to be used when validating that the response from the middleware
|
||||
* is the same request object we passed into it.
|
||||
*/
|
||||
protected function getClosureAssertions(): Closure
|
||||
{
|
||||
if (is_null($this->request)) {
|
||||
throw new BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
|
||||
}
|
||||
|
||||
return function ($response) {
|
||||
$this->assertInstanceOf(Request::class, $response);
|
||||
$this->assertSame($this->request, $response);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user