misc_pterodactyl-panel/tests/Traits/Http/MocksMiddlewareClosure.php

26 lines
706 B
PHP
Raw Normal View History

2017-11-02 01:45:43 +00:00
<?php
namespace Pterodactyl\Tests\Traits\Http;
2017-11-02 01:45:43 +00:00
use Closure;
use Illuminate\Http\Request;
trait MocksMiddlewareClosure
{
/**
* Provide a closure to be used when validating that the response from the middleware
* is the same request object we passed into it.
*/
2022-12-15 00:06:28 +00:00
protected function getClosureAssertions(): \Closure
2017-11-02 01:45:43 +00:00
{
if (is_null($this->request)) {
2022-11-29 17:53:59 +00:00
throw new \BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
2017-11-02 01:45:43 +00:00
}
return function ($response) {
$this->assertInstanceOf(Request::class, $response);
$this->assertSame($this->request, $response);
};
}
}