PHPackages                             there4/slim-test-helpers - 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. there4/slim-test-helpers

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

there4/slim-test-helpers
========================

Integration testing helpers for the Slim Framework

v2.1.3(8y ago)61255.9k↓30.3%28[2 issues](https://github.com/there4/slim-test-helpers/issues)[1 PRs](https://github.com/there4/slim-test-helpers/pulls)2MITPHP

Since Nov 1Pushed 2y ago11 watchersCompare

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

READMEChangelog (10)Dependencies (6)Versions (13)Used By (2)

Slim Test Helpers [![Build Status](https://camo.githubusercontent.com/8949ca9189cce3b6aee8cbc2154cc6b9c5a947a3c9161c19a5f598c4901ab2b9/68747470733a2f2f7472617669732d63692e6f72672f7468657265342f736c696d2d746573742d68656c706572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/there4/slim-test-helpers) [![Code Climate](https://camo.githubusercontent.com/8c7680adc70dae9e840c4e9706bf48a6f8e3e44c68da79bd4ce75df55269a7c6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7468657265342f736c696d2d746573742d68656c706572732f6261646765732f6770612e737667)](https://codeclimate.com/github/there4/slim-test-helpers) [![Test Coverage](https://camo.githubusercontent.com/699bd26afed3daaabbbe3f69edad4debd426bbc57f03d5f9a70cfc0dcd09ef86/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7468657265342f736c696d2d746573742d68656c706572732f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/there4/slim-test-helpers/coverage)
=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#slim-test-helpers---)

> Integration testing helpers for the Slim Framework 3

For a full example, please see the companion repo at [there4/slim-unit-testing-example](https://github.com/there4/slim-unit-testing-example).

Example
-------

[](#example)

Here's a test for a very simple endpoint that returns the version from the application config. We're asserting that Slim responded with a `200` and that the version matches what we expect.

```
class VersionTest extends LocalWebTestCase
{
    public function testVersion()
    {
        $this->client->get('/version');
        $this->assertEquals(200, $this->client->response->getStatusCode());
        $this->assertEquals($this->app->config('version'), $this->client->response->getBody());
    }
}
```

Here is an example on how to pass data to a POST endpoint in a test case and retrieve it later in the endpoint. We are passing encoded JSON data in the body of the request. The data is retrieved in the endpoint using `$app->request->getBody()`.

```
// test file
class UserTest extends LocalWebTestCase
{
    public function testVersion()
    {
        ......
        $data = array("user" => 1);
        $data = json_encode($data);
        $this->client->post('/user', $data);
        ......
    }
}

// endpoint file
.....
$app->post('/user', function() use ($app) {
    .....
    $data = $app->request->getBody();
    $data = json_decode($data, true);
    ......
});
```

### Example with DbUnit

[](#example-with-dbunit)

If you wish to use Database fixture, use class `WebDbTestCase`. *Caution*: Make sure the names you use for you fixture models won't conflict with your actual DB tables.

```
class LocalDbWebTestCase extends \There4\Slim\Test\WebDbTestCase
{
    /**
     * You must implement this method
     * @return PHPUnit_Extensions_Database_DataSet_IDataSet
     */
    public function getDataSet()
    {
        return $this->createFlatXMLDataSet(
            dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixture.xml'
        );
    }
}
```

Setup
-----

[](#setup)

You'll need a bootstrap file for phpunit that can instantiate your Slim application. You can see \[an example boostrap\] in [the sample app](https://github.com/there4/slim-unit-testing-example).

You'll implement your own `getSlimInstance()` method that returns an instance of your app [by extending](https://github.com/there4/slim-test-helpers/blob/master/src/There4/Slim/Test/WebTestCase.php) the `WebTestCase` helper.

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 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 ~106 days

Total

11

Last Release

3145d ago

Major Versions

v0.9.6 → v2.12016-08-02

v0.9.7 → v2.1.22017-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/06719ba09ce20c0774f7b29346b41890f497cb06252f3b8b701fd0df32abd082?d=identicon)[craig-davis](/maintainers/craig-davis)

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

---

Top Contributors

[![craig-davis](https://avatars.githubusercontent.com/u/9907304?v=4)](https://github.com/craig-davis "craig-davis (31 commits)")[![guillermoandrae](https://avatars.githubusercontent.com/u/133861?v=4)](https://github.com/guillermoandrae "guillermoandrae (16 commits)")[![felixmaier1989](https://avatars.githubusercontent.com/u/10077436?v=4)](https://github.com/felixmaier1989 "felixmaier1989 (8 commits)")[![danmichaelo](https://avatars.githubusercontent.com/u/434495?v=4)](https://github.com/danmichaelo "danmichaelo (6 commits)")[![adbre](https://avatars.githubusercontent.com/u/1292956?v=4)](https://github.com/adbre "adbre (4 commits)")[![maxleaver](https://avatars.githubusercontent.com/u/2152576?v=4)](https://github.com/maxleaver "maxleaver (4 commits)")[![justinph](https://avatars.githubusercontent.com/u/634842?v=4)](https://github.com/justinph "justinph (3 commits)")[![khrizt](https://avatars.githubusercontent.com/u/725227?v=4)](https://github.com/khrizt "khrizt (3 commits)")[![manhtai](https://avatars.githubusercontent.com/u/8898656?v=4)](https://github.com/manhtai "manhtai (1 commits)")[![jagandecapri](https://avatars.githubusercontent.com/u/5851344?v=4)](https://github.com/jagandecapri "jagandecapri (1 commits)")[![olerass](https://avatars.githubusercontent.com/u/1476509?v=4)](https://github.com/olerass "olerass (1 commits)")[![Starli0n](https://avatars.githubusercontent.com/u/3925813?v=4)](https://github.com/Starli0n "Starli0n (1 commits)")

---

Tags

slim

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/there4-slim-test-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/there4-slim-test-helpers/health.svg)](https://phpackages.com/packages/there4-slim-test-helpers)
```

###  Alternatives

[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[docler-labs/codeception-slim-module

Codeception Module for Slim framework.

13178.0k1](/packages/docler-labs-codeception-slim-module)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)[herloct/codeception-slim-module

Codeception Module for Slim 3 Microframework.

26130.9k5](/packages/herloct-codeception-slim-module)[selective/test-traits

A collection of PHPUnit test traits

13322.3k5](/packages/selective-test-traits)

PHPackages © 2026

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