Skip to content

Commit

Permalink
Make Response macroable
Browse files Browse the repository at this point in the history
  • Loading branch information
binotaliu committed Jan 8, 2021
1 parent f802df2 commit 8b9a8d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Response as ResponseFactory;
use Illuminate\Support\Traits\Macroable;

class Response implements Responsable
{
use Macroable;

protected $component;
protected $props;
protected $rootView;
Expand Down
10 changes: 10 additions & 0 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

class ResponseTest extends TestCase
{
public function test_can_macro()
{
$response = new Response('User/Edit', []);
$response->macro('foo', function () {
return 'bar';
});

$this->assertEquals('bar', $response->foo());
}

public function test_server_response()
{
$request = Request::create('/user/123', 'GET');
Expand Down

0 comments on commit 8b9a8d0

Please sign in to comment.