PHPackages                             nebkam/fluent-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. [Testing &amp; Quality](/categories/testing)
4. /
5. nebkam/fluent-test

ActiveLibrary[Testing &amp; Quality](/categories/testing)

nebkam/fluent-test
==================

A few helpers to ease functional API testing in Symfony

4.2.1(5mo ago)1030.3k↓50%2[1 issues](https://github.com/nebkam/fluent-test/issues)MITPHPPHP ^7.2 || ^8.0CI passing

Since Mar 19Pushed 5mo ago3 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (17)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/3236f25faf635c4e9b95ebf3dfc39a21c6e156b7bcf8edb7cea3fa06a53bd0fd/68747470733a2f2f706f7365722e707567782e6f72672f6e65626b616d2f666c75656e742d746573742f76)](//packagist.org/packages/nebkam/fluent-test)

Fluent Test Helper
==================

[](#fluent-test-helper)

Few classes to make your Symfony tests more readable

### Symfony 5 &amp; 6

[](#symfony-5--6)

`composer require --dev nebkam/fluent-test`

### Symfony 3 &amp; 4

[](#symfony-3--4)

`composer require --dev nebkam/fluent-test:"^2.0"`

`RequestBuilder`
----------------

[](#requestbuilder)

Since `Symfony\Bundle\FrameworkBundle\KernelBrowser::request` has 7 optional parameters, arbitrary ordered, this class follows a [builder pattern](https://en.wikipedia.org/wiki/Builder_pattern) to construct the request using semantic methods.

### Usage

[](#usage)

```
// Before
$response = $client->request($method, $uri, $parameters, $files, $server, $content);

// After
$response = RequestBuilder::create($client)
  ->setMethod($method)
  ->setUri($uri)
  ->setParameters($parameters)
  ->setFiles($files)
  ->setContent($content)
  ->getResponse();
```

### What about $server parameter?

[](#what-about-server-parameter)

There's no `RequestBuilder::setServer` method, since it seemed to general to be semantic. Instead, you can use more specific methods (Thanks, @KristijanKanalas):

- `setHeader`
- `setHttpHeader`
- `setCredentials`

(if you think of some other uses of server variables, feel free to write a semantic method for it in a PR)

#### setHeader

[](#setheader)

```
// Before
$response = $client->request($method, $uri, $parameters, $files, [
  'CONTENT_TYPE' => $value
  ], $content);

// After
$response = RequestBuilder::create($client)
  ->setHeader('CONTENT_TYPE', $value)
  ...
```

#### setHttpHeader

[](#sethttpheader)

```
// Before
$response = $client->request($method, $uri, $parameters, $files, [
  'HTTP_X-Custom-Header' => $value
  ], $content);

// After
$response = RequestBuilder::create($client)
  ->setHttpHeader('X-Custom-Header', $value)
  ...
```

#### setCredentials

[](#setcredentials)

```
// Before
$response = $client->request($method, $uri, $parameters, $files, [
  'PHP_AUTH_USER' => $username,
  'PHP_AUTH_PW' => $password
  ], $content);

//After
$response = RequestBuilder::create($client)
  ->setCredentials($username, $password)
  ...
```

### `setJsonContent`

[](#setjsoncontent)

Send a JSON encoded payload with the request

```
// Before
$response = $client->request($method, $uri, $parameters, $files, $server, json_encode($content));

// After
$response = RequestBuilder::create($client)
  ->setJsonContent($content)
  ...
```

### Dynamic URIs

[](#dynamic-uris)

`setUri` accepts either a plain `string` or [sprintf](https://www.php.net/manual/en/function.sprintf.php) -compatible parameters (format and values)

```
// This works
$response = RequestBuilder::create($client)
  ->setUri('/users/'. $email .'/details')
  ...

// This is more readable
$response = RequestBuilder::create($client)
  ->setUri('/users/%s/details', $email)
  ...
```

`ResponseWrapper`
-----------------

[](#responsewrapper)

A [decorator](https://en.wikipedia.org/wiki/Decorator_pattern) for `Symfony\Component\HttpFoundation\Response` that wraps the response and provides few semantic *issers* to make asserts more readable

### Usage

[](#usage-1)

```
// Before
$client->request($method, $uri, $parameters, $files, $server, $content);
$response = $client->getResponse();
$this->assertEquals(200,$response->getStatusCode())

// After
$response = RequestBuilder::create($client)
  ...
  ->getResponse();
$this->assertTrue($response->isOk());
```

### List of *issers*

[](#list-of-issers)

- `isBadRequest`
- `isCreated`
- `isEmpty`
- `isForbidden`
- `isNotFound`
- `isOk`
- `isUnauthorized`
- `isUnprocessable`

### `getJsonContent`

[](#getjsoncontent)

Get a JSON decoded body from the response

```
// Before
$response = $client->request($method, $uri, $parameters, $files, $server, $content);
$data = json_decode($client->getResponse());

// After
$data = RequestBuilder::create($client)
  ...
  ->getResponse()
  ->getJsonContent();
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance68

Regular maintenance activity

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% of commits — single point of failure

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 ~187 days

Recently: every ~513 days

Total

16

Last Release

170d ago

Major Versions

1.0.1 → 2.0.02018-06-27

2.0.3 → 3.0.02019-12-28

3.0.0 → 4.0.02020-04-15

v2.x-dev → 4.0.22020-04-15

PHP version history (3 changes)1.0.0PHP ^7.0

4.0.0PHP ^7.2

4.1PHP ^7.2 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![nebkam](https://avatars.githubusercontent.com/u/1735290?v=4)](https://github.com/nebkam "nebkam (19 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (7 commits)")[![silvesterk](https://avatars.githubusercontent.com/u/12173921?v=4)](https://github.com/silvesterk "silvesterk (3 commits)")[![zidar-bot](https://avatars.githubusercontent.com/u/85165793?v=4)](https://github.com/zidar-bot "zidar-bot (3 commits)")

---

Tags

fluent-interfacephpsymfonytesting

### Embed Badge

![Health badge](/badges/nebkam-fluent-test/health.svg)

```
[![Health](https://phpackages.com/badges/nebkam-fluent-test/health.svg)](https://phpackages.com/packages/nebkam-fluent-test)
```

###  Alternatives

[liip/functional-test-bundle

This bundles provides additional functional test-cases for Symfony applications

65010.8M86](/packages/liip-functional-test-bundle)[lchrusciel/api-test-case

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

4115.5M63](/packages/lchrusciel-api-test-case)[shopsys/http-smoke-testing

HTTP smoke test case for testing all configured routes in your Symfony project

68258.7k1](/packages/shopsys-http-smoke-testing)[liorchamla/symfony-test-helpers

Provides cool tools to make testing over symfony smoothie and great !

222.2k](/packages/liorchamla-symfony-test-helpers)

PHPackages © 2026

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