PHP code example of php-solution / sf-functional-test

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

    

php-solution / sf-functional-test example snippets


$client = $this->getAuthorizedClient('user_login', 'password');

use PhpSolution\FunctionalTest\TestCase\ProfilerTrait;

[$response, $profiler] = self::withRequestProfiler(static function () {
    return self::createSystemAuthorizedTester()
        ->setExpectedStatusCode(Response::HTTP_OK)
        ->sendGet('/some/awesome/endpoint', ['foo' => 'bar']);
});

[$response, $profiler] = self::withRequestProfiler(static function () {
    return self::createSystemAuthorizedTester()
        ->setExpectedStatusCode(Response::HTTP_OK)
        ->sendGet('/some/awesome/endpoint', ['foo' => 'bar']);
}, ['db', 'http_client']);

self::getCollector($profiler, 'http_client');

$this->getDoctrine()

protected function findEntity(string $entityClass, string $orderBy = 'id', array $findBy = [])
protected function findDocument(string $documentClass, array $criteria = [])
protected function findDocuments(string $documentClass, array $criteria = [], array $orderBy = [])

protected function refreshEntity($entity) 
protected function refreshDocument($document)

use PhpSolution\FunctionalTest\TestCase\ProfilerTrait;
use PhpSolution\FunctionalTest\TestCase\EntityProfilerTrait;

self::getDoctrineCollector($profiler)->getQueries(); // returns array of executed queries
self::assertDoctrineQueriesCount(8, $profiler);
self::assertDoctrineQueriesCountLessThanOrEqual(3, $profiler);
self::assertDoctrineSelectQueriesCount(2, $profiler);
self::assertDoctrineSelectQueriesCountLessThanOrEqual(2, $profiler);
self::assertDoctrineUpdateQueriesCount(1, $profiler);
self::assertDoctrineUpdateQueriesCountLessThanOrEqual(1, $profiler);
self::assertDoctrineInsertQueriesCount(1, $profiler);
self::assertDoctrineInsertQueriesCountLessThanOrEqual(1, $profiler);
self::assertDoctrineDeleteQueriesCount(1, $profiler);
self::assertDoctrineDeleteQueriesCountLessThanOrEqual(1, $profiler);

public function purgeSpool()
public function getSpooledEmails()
public function getEmailContent($file)
protected function getSpoolDir()