PHPackages                             preflow/testing - 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. preflow/testing

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

preflow/testing
===============

Preflow testing — test utilities for components, routes, data

v0.13.1(1mo ago)0291MITPHPPHP &gt;=8.4

Since Apr 10Pushed 1mo agoCompare

[ Source](https://github.com/getpreflow/testing)[ Packagist](https://packagist.org/packages/preflow/testing)[ RSS](/packages/preflow-testing/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (10)Versions (32)Used By (1)

Preflow Testing
===============

[](#preflow-testing)

Test utilities for Preflow applications — components, routes, and data layers.

Installation
------------

[](#installation)

```
composer require preflow/testing --dev
```

What it does
------------

[](#what-it-does)

- PHPUnit base cases for components, routes, and data
- Fluent HTTP response assertions wrapping PSR-7 responses
- In-memory SQLite and temporary JSON storage for isolated data tests
- Minimal `TestApplication` bootstrap (container, renderer, token service)

ComponentTestCase
-----------------

[](#componenttestcase)

Extend to test Preflow components. `TestApplication` is wired up automatically in `setUp()`.

```
use Preflow\Testing\ComponentTestCase;

final class ExampleCardTest extends ComponentTestCase
{
    public function test_renders_title(): void
    {
        $html = $this->renderComponent(ExampleCard::class, [
            'title' => 'Hello',
        ]);

        $this->assertStringContainsString('Hello', $html);
    }

    public function test_initial_state(): void
    {
        $card = $this->createComponent(ExampleCard::class, ['title' => 'Hi']);
        $card->resolveState();

        $this->assertSame('Hi', $card->title);
    }
}
```

RouteTestCase + TestResponse
----------------------------

[](#routetestcase--testresponse)

Wrap any PSR-7 `ResponseInterface` for fluent assertions.

```
use Preflow\Testing\RouteTestCase;

final class HealthTest extends RouteTestCase
{
    public function test_health_endpoint(): void
    {
        $psrResponse = $this->app->handle($request); // your PSR-7 response

        $this->createTestResponse($psrResponse)
            ->assertOk()
            ->assertJson()
            ->assertSee('"status":"ok"');
    }
}
```

### TestResponse assertions

[](#testresponse-assertions)

MethodDescription`assertOk()`Status 200`assertStatus(int $status)`Exact status code`assertSee(string $text)`Body contains text`assertNotSee(string $text)`Body does not contain text`assertRedirect(string $uri)`3xx + matching Location header`assertHeader(string $name, string $value)`Exact header value`assertHeaderContains(string $name, string $sub)`Header contains substring`assertJson()`Content-Type contains "json" + valid JSON body`assertForbidden()`Status 403`assertNotFound()`Status 404`assertUnauthorized()`Status 401All assertion methods return `$this` for chaining.

DataTestCase
------------

[](#datatestcase)

Provides an in-memory SQLite connection and a temporary JSON directory, both torn down after each test.

```
use Preflow\Testing\DataTestCase;
use Preflow\Data\Migration\Table;

final class PostRepositoryTest extends DataTestCase
{
    protected function setUp(): void
    {
        parent::setUp();

        $this->createTable('posts', function (Table $table) {
            $table->uuid('uuid')->primary();
            $table->string('title');
            $table->timestamps();
        });
    }

    public function test_save_and_find(): void
    {
        $driver = $this->getSqliteDriver();
        // use $driver or $this->dataManager() for ORM operations

        $pdo = $this->getPdo();
        $pdo->exec("INSERT INTO posts (uuid, title) VALUES ('1', 'Hello')");

        $row = $pdo->query("SELECT * FROM posts WHERE uuid = '1'")->fetch();
        $this->assertSame('Hello', $row['title']);
    }
}
```

### DataTestCase methods

[](#datatestcase-methods)

MethodReturns`getSqliteDriver()``SqliteDriver` (in-memory SQLite)`getJsonDriver()``JsonFileDriver` (temp directory)`dataManager()``DataManager` with both drivers registered`createTable(string $name, callable $cb)`Creates table via Schema builder`getPdo()`Raw `\PDO` instance

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance88

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

31

Last Release

59d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d8b54efbc79683c32645e3fa8d3590037fa003963a16e0ed989104c6f4a2723?d=identicon)[smyr](/maintainers/smyr)

---

Top Contributors

[![smeyerme](https://avatars.githubusercontent.com/u/1925560?v=4)](https://github.com/smeyerme "smeyerme (8 commits)")

### Embed Badge

![Health badge](/badges/preflow-testing/health.svg)

```
[![Health](https://phpackages.com/badges/preflow-testing/health.svg)](https://phpackages.com/packages/preflow-testing)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.3k](/packages/orchestra-testbench)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.0M321](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30300.1k6](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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