Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/tests/Traits/Http/MocksMiddlewareClosure.php
7461 views
1
<?php
2
3
namespace Pterodactyl\Tests\Traits\Http;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
8
trait MocksMiddlewareClosure
9
{
10
/**
11
* Provide a closure to be used when validating that the response from the middleware
12
* is the same request object we passed into it.
13
*/
14
protected function getClosureAssertions(): \Closure
15
{
16
if (is_null($this->request)) {
17
throw new \BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
18
}
19
20
return function ($response) {
21
$this->assertInstanceOf(Request::class, $response);
22
$this->assertSame($this->request, $response);
23
};
24
}
25
}
26
27