PHP code example of waffle-commons / testing
1. Go to this page and download the library: Download waffle-commons/testing 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/ */
waffle-commons / testing example snippets
use App\Factory\AppKernelFactory;
use Psr\Clock\ClockInterface;
use Waffle\Commons\Contracts\Constant\Constant;
use Waffle\Commons\Contracts\Container\ContainerInterface;
use Waffle\Commons\Contracts\Core\KernelInterface;
use Waffle\Commons\Testing\Clock\FrozenClock;
use Waffle\Commons\Testing\PHPUnit\WaffleTestCase;
final class OrderApiTest extends WaffleTestCase
{
protected function createKernel(): KernelInterface
{
return AppKernelFactory::create(Constant::ENV_TEST);
}
public function testShowsAnOrder(): void
{
$clock = new FrozenClock('2026-10-09T09:00:00+00:00');
$client = $this->createClient(static function (ContainerInterface $container) use ($clock): void {
$container->set(ClockInterface::class, $clock);
});
$response = $client->request('GET', '/orders/42');
self::assertStatus(200, $response);
self::assertJsonBody(['id' => 42, 'status' => 'shipped'], $response);
}
}