-
Notifications
You must be signed in to change notification settings - Fork 0
ch08_testing
Daniel Samson edited this page Mar 7, 2025
·
3 revisions
Here is an example of how to test an action:
<?php
use PHPUnit\Framework\TestCase;
class RouterTest extends TestCase
{
public function test_action()
{
$_GET['url'] = 'baz';
router(function () {
route(method(GET), '/baz', function() {
json_out(['data' => 'foo']);
})
});
$this->expectOutputString('{"data":"foo"}');
$this->assertEquals(500, http_response_code());
}
}