Skip to content

Commit 3429b61

Browse files
marcusmooretaylorotwell
authored andcommitted
add assertViewIs() to TestResponse (#19291)
1 parent 88ecd38 commit 3429b61

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Illuminate/Foundation/Testing/TestResponse.php

+15
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,21 @@ public function json()
405405
return $this->decodeResponseJson();
406406
}
407407

408+
/**
409+
* Assert that the response view equals the given value.
410+
*
411+
* @param string $value
412+
* @return $this
413+
*/
414+
public function assertViewIs($value)
415+
{
416+
$this->ensureResponseHasView();
417+
418+
PHPUnit::assertEquals($value, $this->original->getName());
419+
420+
return $this;
421+
}
422+
408423
/**
409424
* Assert that the response view has a given piece of bound data.
410425
*

tests/Foundation/FoundationTestResponseTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212

1313
class FoundationTestResponseTest extends TestCase
1414
{
15+
public function testAssertViewIs()
16+
{
17+
$baseResponse = tap(new Response, function ($response) {
18+
$response->setContent(\Mockery::mock(View::class, [
19+
'render' => 'hello world',
20+
'getData' => ['foo' => 'bar'],
21+
'getName' => 'dir.my-view',
22+
]));
23+
});
24+
25+
$response = TestResponse::fromBaseResponse($baseResponse);
26+
27+
$response->assertViewIs('dir.my-view');
28+
}
29+
1530
public function testAssertViewHas()
1631
{
1732
$baseResponse = tap(new Response, function ($response) {

0 commit comments

Comments
 (0)