PHP code example of speicher210 / functional-test-bundle

1. Go to this page and download the library: Download speicher210/functional-test-bundle 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/ */

    

speicher210 / functional-test-bundle example snippets



// config/bundles.php

return [
    // ...
    Speicher210\FunctionalTestBundle\Speicher210FunctionalTestBundle::class => ['dev' => true, 'test' => true],
    // ...
];



declare(strict_types=1);

'/vendor/speicher210/functional-test-bundle/src/Test/bootstrap.php';

// $kernel variable will contain the current Kernel instance




declare(strict_types=1);

use Speicher210\FunctionalTestBundle\Test\RestControllerWebTestCase;
use Symfony\Component\HttpFoundation\Request;

final class MyUserEndpointTest extends RestControllerWebTestCase
{
    public function testReturn404IfUserIsNotFound() : void
    {
        $this->assertRestRequestReturns404('/api/user/1', Request::METHOD_GET);
    }

    public function testReturns200AndUserData() : void
    {
        $this->assertRestGetPath('/api/user/1');
    }
}


// Fixtures/testReturns200AndUserData.php

return [
    \App\Tests\Fixtures\Loader\LoadOneUser::class
];



$this->mockContainerService('my_service_id', $myServiceMock);



$this->getContainerService('my_service_id');