PHPackages                             php-solution/sf-functional-test - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. php-solution/sf-functional-test

ActiveLibrary

php-solution/sf-functional-test
===============================

Extra functionality for work with Symfony functional tests

v6.0.5(6mo ago)576.4k—8.1%10[1 issues](https://github.com/php-solution/sf-functional-test/issues)2MITPHPPHP &gt;=8.1CI failing

Since Apr 5Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/php-solution/sf-functional-test)[ Packagist](https://packagist.org/packages/php-solution/sf-functional-test)[ RSS](/packages/php-solution-sf-functional-test/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (74)Used By (2)

Symfony Functional Test
=======================

[](#symfony-functional-test)

Install
-------

[](#install)

```
$ composer require php-solution/sf-functional-test
```

Load environment variables from files
-------------------------------------

[](#load-environment-variables-from-files)

Add to your phpunit.xml extension and configure paths (comma separated relative file paths from your phpunit.xml configuration file):

```

```

Load Doctrine fixtures before test cases
----------------------------------------

[](#load-doctrine-fixtures-before-test-cases)

Add to your phpunit.xml extension:

```

```

Run Doctrine migrations before test cases
-----------------------------------------

[](#run-doctrine-migrations-before-test-cases)

Add to your phpunit.xml extension:

```

```

Or simply:

```

```

Run sf command with parameters
------------------------------

[](#run-sf-command-with-parameters)

Add to your phpunit.xml extension:

```

```

Run native command with parameters
----------------------------------

[](#run-native-command-with-parameters)

Add to your phpunit.xml extension:

```

```

Using Test case additional functionallity PhpSolution\\FunctionalTest\\TestCase\\AppTestCase
--------------------------------------------------------------------------------------------

[](#using-test-case-additional-functionallity-phpsolutionfunctionaltesttestcaseapptestcase)

### Using Authorization:

[](#using-authorization)

1. Add to your config\_test.yml:

```
security:
    firewalls:
        your_secured_category:
            http_basic: ~
```

2. Use on TestCase

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

### Use profiler for testing

[](#use-profiler-for-testing)

1. Add to your framework.yml:

```
when@test:
  framework:
    profiler:
      collect: false
```

2. Add ProfilerTrait to your TestCase

```
use PhpSolution\FunctionalTest\TestCase\ProfilerTrait;
```

3. Use the following methods to run request with profiler:

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

By default, the following collectors are enabled: 'db', 'http\_client', 'cache', 'memory' but you can always disable or enable new collectors by passing them in the `withRequestProfiler` method:

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

4. Use profiler to get collectors:

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

### Work with Doctrine (ORM, ODM)

[](#work-with-doctrine-orm-odm)

1. Add EntityTrait or DocumentTrait to your TestCase

```
$this->getDoctrine()
```

3. Find Entity helper method:

```
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 = [])
```

4. Refresh Entity:

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

#### Assert doctrine queries using request profiler

[](#assert-doctrine-queries-using-request-profiler)

1. Make sure you have set up the profiler as described above.
2. Add ProfilerTrait and EntityProfilerTrait to your TestCase:

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

2. Assert queries using profiler:

```
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);
```

### Test emails

[](#test-emails)

1. Add config

```
swiftmailer:
    disable_delivery: true
    spool:
        type: file
        path: '%kernel.project_dir%/var/spool'
    delivery_addresses: ~
```

2. Add SpoolTrait and find methods

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

Example of correct project structure:
-------------------------------------

[](#example-of-correct-project-structure)

See correct project structure and configs for functional tests on [link](/examples/project-structure/)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance63

Regular maintenance activity

Popularity38

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~57 days

Total

73

Last Release

193d ago

Major Versions

v0.1.1 → v1.12017-06-14

v1.2.3 → 4.3.92017-06-26

v1.3 → v4.0.02017-12-14

v4.x-dev → v5.0.02020-10-29

v5.0.7 → v6.0.02024-02-06

PHP version history (5 changes)v0.1PHP ^7.0

v1.1PHP ^7.1

v5.0.0PHP ^7.4

v5.0.5PHP &gt;=7.4

v6.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/49381ba2a061a148b9a6f7b5e80663f17d44f15047bbc5f1f38d13429de60487?d=identicon)[olesav](/maintainers/olesav)

![](https://www.gravatar.com/avatar/e9411518d35cb6c5d45aa45fc7d412b423872397c216ce256ee2e3caf4baa81b?d=identicon)[kalinick](/maintainers/kalinick)

---

Top Contributors

[![kalinick](https://avatars.githubusercontent.com/u/1422388?v=4)](https://github.com/kalinick "kalinick (5 commits)")[![panayotovyura](https://avatars.githubusercontent.com/u/8473688?v=4)](https://github.com/panayotovyura "panayotovyura (5 commits)")[![igdr](https://avatars.githubusercontent.com/u/4249152?v=4)](https://github.com/igdr "igdr (4 commits)")[![antonchernik](https://avatars.githubusercontent.com/u/12397460?v=4)](https://github.com/antonchernik "antonchernik (2 commits)")[![fedorenko22116](https://avatars.githubusercontent.com/u/22433371?v=4)](https://github.com/fedorenko22116 "fedorenko22116 (2 commits)")[![e-moe](https://avatars.githubusercontent.com/u/963424?v=4)](https://github.com/e-moe "e-moe (2 commits)")[![ypft](https://avatars.githubusercontent.com/u/157708858?v=4)](https://github.com/ypft "ypft (1 commits)")[![atrigub](https://avatars.githubusercontent.com/u/389271?v=4)](https://github.com/atrigub "atrigub (1 commits)")[![iborysenko](https://avatars.githubusercontent.com/u/17834238?v=4)](https://github.com/iborysenko "iborysenko (1 commits)")

### Embed Badge

![Health badge](/badges/php-solution-sf-functional-test/health.svg)

```
[![Health](https://phpackages.com/badges/php-solution-sf-functional-test/health.svg)](https://phpackages.com/packages/php-solution-sf-functional-test)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4115.5M63](/packages/lchrusciel-api-test-case)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
