generated from chevere/package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Chevere. | ||
* | ||
* (c) Rodolfo Berrios <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chevere\Tests\Attributes; | ||
|
||
use Chevere\Http\Attributes\Response; | ||
use Chevere\Http\Header; | ||
use Chevere\Http\Status; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class ResponseTests extends TestCase | ||
{ | ||
public function testConstructEmpty(): void | ||
{ | ||
$request = new Response(); | ||
$status = new Status(200); | ||
$this->assertCount(0, $request->headers); | ||
$this->assertEquals($status, $request->status); | ||
$this->assertCount(1, $request); | ||
$this->assertEquals( | ||
[ | ||
'status' => $status, | ||
], | ||
$request->toArray() | ||
); | ||
} | ||
|
||
public function testConstruct(): void | ||
{ | ||
$status = new Status(400); | ||
$headerDisposition = new Header('Content-Disposition', 'attachment'); | ||
$response = new Response($status, $headerDisposition); | ||
$this->assertCount(2, $response); | ||
$this->assertEquals($status, $response->status); | ||
$this->assertEquals( | ||
[ | ||
'status' => $status, | ||
'Content-Disposition' => $headerDisposition, | ||
], | ||
$response->toArray() | ||
); | ||
} | ||
} |