Core MVC, HTTP client, Session, Cookie, Config, HTTPException — 111 PHPUnit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use System\Classes\Response;
|
|
|
|
class ResponseTest extends TestCase
|
|
{
|
|
public function testDefaultValues(): void
|
|
{
|
|
$r = new Response();
|
|
$this->assertSame('', $r->body());
|
|
$this->assertSame(200, $r->status());
|
|
}
|
|
|
|
public function testConstructorStatus(): void
|
|
{
|
|
$r = new Response(404);
|
|
$this->assertSame(404, $r->status());
|
|
}
|
|
|
|
public function testBodySetterReturnsThis(): void
|
|
{
|
|
$r = new Response();
|
|
$same = $r->body('hello');
|
|
$this->assertSame($r, $same);
|
|
$this->assertSame('hello', $r->body());
|
|
}
|
|
|
|
public function testStatusSetterReturnsThis(): void
|
|
{
|
|
$r = new Response();
|
|
$same = $r->status(301);
|
|
$this->assertSame($r, $same);
|
|
$this->assertSame(301, $r->status());
|
|
}
|
|
|
|
public function testBodyOverwrite(): void
|
|
{
|
|
$r = (new Response())->body('first');
|
|
$r->body('second');
|
|
$this->assertSame('second', $r->body());
|
|
}
|
|
|
|
public function testBodyEmpty(): void
|
|
{
|
|
$r = (new Response())->body('content');
|
|
$r->body('');
|
|
$this->assertSame('', $r->body());
|
|
}
|
|
|
|
public function testFluentChain(): void
|
|
{
|
|
$r = new Response();
|
|
$body = $r->status(201)->body('created')->body();
|
|
$this->assertSame('created', $body);
|
|
$this->assertSame(201, $r->status());
|
|
}
|
|
}
|