8000 Remove mock request and use an instance. · laravel/framework@604dfa7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 604dfa7

Browse files
committed
Remove mock request and use an instance.
1 parent fcf92ae commit 604dfa7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/Foundation/FoundationExceptionsHandlerTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Exception;
77
use Mockery as m;
88
use RuntimeException;
9+
use Illuminate\Http\Request;
910
use Psr\Log\LoggerInterface;
1011
use PHPUnit\Framework\TestCase;
1112
use Illuminate\Routing\Redirector;
@@ -141,39 +142,40 @@ public function testValidateFileMethod()
141142
$argumentExpected = ['input' => 'My input value'];
142143
$argumentActual = null;
143144

144-
$this->container->singleton('redirect', function () use ($argumentExpected, &$argumentActual) {
145+
$this->container->singleton('redirect', function () use (&$argumentActual) {
145146
$redirector = m::mock(Redirector::class);
146147

147148
$redirector->shouldReceive('to')->once()
148149
->andReturn($responser = m::mock(RedirectResponse::class));
149150

150-
$responser->shouldReceive('withInput')->once()->with(m::on(function ($argument) use ($argumentExpected, &$argumentActual) {
151-
$argumentActual = $argument;
151+
$responser->shouldReceive('withInput')->once()->with(m::on(
152+
function ($argument) use (&$argumentActual) {
153+
$argumentActual = $argument;
152154

153-
return true;
154-
}))->andReturn($responser);
155+
return true;
156+
}))->andReturn($responser);
155157

156158
$responser->shouldReceive('withErrors')->once()
157159
->andReturn($responser);
158160

159161
return $redirector;
160162
});
161163

162-
$this->request->shouldReceive('expectsJson')->once()->andReturn(false);
163-
$this->request->shouldReceive('input')->once()->andReturn($argumentExpected);
164-
165164
$file = m::mock(UploadedFile::class);
166-
$file->shouldReceive('isValid')->zeroOrMoreTimes()->andReturn(false);
167-
$file->shouldReceive('getPathname')->zeroOrMoreTimes()->andReturn('photo.jpg');
168-
$file->shouldReceive('getClientOriginalName')->zeroOrMoreTimes()->andReturn('photo.jpg');
165+
$file->shouldReceive('getPathname')->andReturn('photo.jpg');
166+
$file->shouldReceive('getClientOriginalName')->andReturn('photo.jpg');
167+
$file->shouldReceive('getClientMimeType')->andReturn(null);
168+
$file->shouldReceive('getError')->andReturn(null);
169+
170+
$request = Request::create('/', 'POST', $argumentExpected, [], ['photo' => $file]);
169171

170172
$validator = m::mock(Validator::class);
171173
$validator->shouldReceive('errors')->andReturn(new MessageBag(['error' => 'My custom validation exception']));
172174

173175
$validationException = new ValidationException($validator);
174176
$validationException->redirectTo = '/';
175177

176-
$this->handler->render($this->request, $validationException);
178+
$this->handler->render($request, $validationException);
177179

178180
$this->assertEquals($argumentExpected, $argumentActual);
179181
}

0 commit comments

Comments
 (0)
0