-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on Laravel's response factory as this is not bound …
…in Lumen. Provide our own response factory, increases indirection but allows us to make this change with minimal changes to tests.
- Loading branch information
Max Brokman
committed
Jul 13, 2016
1 parent
97bacaf
commit c930597
Showing
4 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
|
||
namespace Vice\LaravelFractal; | ||
|
||
|
||
use Illuminate\Http\Response; | ||
|
||
class ResponseFactory | ||
{ | ||
public function make($content = '', $status = 200, array $headers = []) | ||
{ | ||
return new Response($content, $status, $headers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
|
||
namespace tests\Vice\LaravelFractal; | ||
|
||
|
||
use Illuminate\Http\Response; | ||
use Vice\LaravelFractal\ResponseFactory; | ||
|
||
class ResponseFactoryTest extends TestCase | ||
{ | ||
public function testProducesAResponse() | ||
{ | ||
$factory = new ResponseFactory(); | ||
$response = $factory->make(['foo' => 'bar'], 200, ['header' => 'content']); | ||
|
||
$this->assertInstanceOf(Response::class, $response); | ||
$this->assertEquals(['foo' => 'bar'], $response->getOriginalContent()); | ||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertArrayHasKey('header', $response->headers->all()); | ||
$this->assertEquals('content', $response->headers->get('header')); | ||
} | ||
} |