So in my application I've some routes that need special treatment which is why I have something like this:
Route::prefix('external')->group(function () {
Route::any(Request::path(), 'ExternalController@handle');
});
Basically every route which is /api/external*
goes into that part.
Somehow, when I run my feature tests, Request::path()
or request()->path()
(doesn't matter) is always /
I also tried $_SERVER
but this isnt even defined at this point.
My Test looks something like this:
public function testExternal()
{
$response = $this
->put($this->externalUrl . '/' . $some['id'], [
'data' => []
]);
// ...
}
So I've read some articles here on stackoverflow and what I already tried was this:
$response = $this
->withServerVariables(['REQUEST_URI' => $this->externalUrl . '/' . $some['id']])
->put($this->externalUrl . '/' . $some['id'], [
'data' => []
]);
and also this:
Request::shouldReceive('path')
->once()
->andReturn($this->externalUrl . '/' . $some['id']);
but this doesn't work at all, I just get errors like this:
Received Mockery_2_Illuminate_Http_Request::setUserResolver(), but no expectations were specified
And even tho I try to set an expectation for this, it just doesn't work.
So what I'm looking for is to either Mock $_SERVER
or Request::path
or to somehow figure out, why Request::path
is always just /
.
Thanks in advance.