Skip to content

Commit

Permalink
Merge pull request #205 from binotaliu/macroable
Browse files Browse the repository at this point in the history
Make Response macroable
  • Loading branch information
reinink authored Jan 8, 2021
2 parents f802df2 + 8b9a8d0 commit 726b1e0
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 726b1e0

Please sign in to comment.