cerbero90 /
octane-testbench
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Cerbero\OctaneTestbench\Concerns; |
||||
| 4 | |||||
| 5 | use Cerbero\OctaneTestbench\ResponseTestCase; |
||||
| 6 | use Cerbero\OctaneTestbench\Stubs\ApplicationFactoryStub; |
||||
| 7 | use Cerbero\OctaneTestbench\Stubs\ClientStub; |
||||
| 8 | use Cerbero\OctaneTestbench\Stubs\WorkerStub; |
||||
| 9 | use Illuminate\Http\Request; |
||||
| 10 | use Laravel\Octane\Contracts\Client; |
||||
| 11 | use Symfony\Component\HttpFoundation\Request as SymfonyRequest; |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * The trait to make HTTP requests. |
||||
| 15 | * |
||||
| 16 | */ |
||||
| 17 | trait MakesHttpRequests |
||||
| 18 | { |
||||
| 19 | /** |
||||
| 20 | * Call the given URI via Laravel Octane. |
||||
| 21 | * |
||||
| 22 | * @param string $method |
||||
| 23 | * @param string $uri |
||||
| 24 | * @param array $parameters |
||||
| 25 | * @param array $cookies |
||||
| 26 | * @param array $files |
||||
| 27 | * @param array $server |
||||
| 28 | * @param string|null $content |
||||
| 29 | * @return ResponseTestCase |
||||
| 30 | */ |
||||
| 31 | 13 | public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null) |
|||
| 32 | { |
||||
| 33 | 13 | $request = SymfonyRequest::create( |
|||
| 34 | 13 | $this->prepareUrlForRequest($uri), |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 35 | $method, |
||||
| 36 | $parameters, |
||||
| 37 | $cookies, |
||||
| 38 | 13 | array_merge($files, $this->extractFilesFromDataArray($parameters)), |
|||
|
0 ignored issues
–
show
It seems like
extractFilesFromDataArray() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 39 | 13 | array_replace($this->serverVariables, $server), |
|||
| 40 | $content, |
||||
| 41 | ); |
||||
| 42 | |||||
| 43 | 13 | return $this->sendToOctane(Request::createFromBase($request)); |
|||
| 44 | } |
||||
| 45 | |||||
| 46 | /** |
||||
| 47 | * Send a request to Laravel Octane. |
||||
| 48 | * |
||||
| 49 | * @param Request $request |
||||
| 50 | * @return ResponseTestCase |
||||
| 51 | */ |
||||
| 52 | 13 | public function sendToOctane(Request $request): ResponseTestCase |
|||
| 53 | { |
||||
| 54 | 13 | $factory = new ApplicationFactoryStub($this->app); |
|||
| 55 | 13 | $client = new ClientStub($this); |
|||
|
0 ignored issues
–
show
$this of type Cerbero\OctaneTestbench\Concerns\MakesHttpRequests is incompatible with the type PHPUnit\Framework\TestCase expected by parameter $testCase of Cerbero\OctaneTestbench\...ientStub::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 56 | 13 | $worker = new WorkerStub($factory, $client); |
|||
| 57 | |||||
| 58 | 13 | $this->app->instance(Client::class, $client); |
|||
| 59 | |||||
| 60 | 13 | $worker->boot(); |
|||
| 61 | |||||
| 62 | 13 | return $worker->runRequest($request); |
|||
| 63 | } |
||||
| 64 | } |
||||
| 65 |