PHP code example of codetetic / pest-plugin-symfony

1. Go to this page and download the library: Download codetetic/pest-plugin-symfony 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/ */

    

codetetic / pest-plugin-symfony example snippets


// Pest.php

uses(Pest\Symfony\WebTestCase::class)->in('Application');
Pest\Symfony\Web\extend(expect());

uses(Pest\Symfony\KernelTestCase::class)->in('Integration');
Pest\Symfony\Kernel\extend(expect());



use function Pest\Symfony\Web\createClient;
use function Pest\Symfony\Web\getRequest;
use function Pest\Symfony\Web\getResponse;

it('can get a 200 response from /example', function (): void {
    createClient()->request('GET', '/example');

    expect(getResponse())->toHaveIsSuccessful();
    expect(getRequest()->getMethod())->toBe('GET');
    expect(getResponse()->getContent())->toMatchSnapshot();
});



use function Pest\Symfony\Kernel\getContainer;

it('can get and use service', function (): void {
    expect(
        getContainer()
            ->get(App\Service\ExampleService::class)
            ->string('string')
    )->toBe('string');
});