1. Go to this page and download the library: Download dejwcake/testing-kit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dejwcake / testing-kit example snippets
use DejwCake\TestingKit\Functional\WebTestCase;
use DejwCake\TestingKit\Attributes\Context;
final class InstructionsControllerTest extends WebTestCase
{
#[Context(user: 'customer')]
public function testCustomerCanDownloadInstruction(): void
{
$response = $this->get(route('web/instructions/show', ['legoSet' => 5]));
$response->assertOk();
$this->assertDownload($response, 'dummy.pdf');
}
}
use DejwCake\TestingKit\Functional\ApiTestCase;
use DejwCake\TestingKit\Attributes\Context;
final class PostsControllerTest extends ApiTestCase
{
#[Context(user: 'customer')]
public function testCustomerCanListPosts(): void
{
$response = $this->getJson(route('api/posts/index'));
$response->assertOk();
$this->assertValidOpenApiResponseForRoute('GET', 'api/posts/index', $response);
}
}