<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
geckoboom / whirlwind-application-testing example snippets
namespace Test;
use League\Container\Container;
use Whirlwind\App\Application\Application;
use WhirlwindApplicationTesting\RestTestCase;
use App\Models\User;
abstract class TestCase extends RestTestCase
{
protected function createApplication(): Application
{
$container = new Container();
// register service providers here
return new Application($container);
}
}
namespace Test;
class UsersTest extends TestCase
{
public function testGetById()
{
$this->addAuthorizationToken('secret')
->get('/users/1', ['X-Test-Header' => 'Test'])
->assertResponseIsSuccessful()
->assertResponseCodeIsOk()
->assertHeader('Content-Type', 'application/json')
->assertResponseContainsJsonFragment(['id' => 1]);
}
}