tappet / bundle
Requires
- php: >=8.1
- symfony/config: ^5.0
- symfony/dependency-injection: ^5.0
- symfony/http-kernel: ^5.0
- symfony/yaml: ^5.0
- tappet/tappet: ^0.1.1
Requires (Dev)
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.10
- phpstan/phpstan-mockery: ^1.1
- phpunit/phpunit: ^10.2
- symfony/browser-kit: ^5.4
- symfony/framework-bundle: ^5.0
This package is auto-updated.
Last update: 2026-07-12 23:13:44 UTC
README
[EXPERIMENTAL] - API is unstable and subject to change.
Integrates Tappet into a Symfony application. Exposes the fixture API endpoints that Tappet uses to load and tear down test data, so you do not need to implement them by hand.
Installation
composer require tappet/bundle
Setup
1. Register the bundle
Add the bundle to config/bundles.php, enabled only for the environment in which you run Tappet
(e.g. a dedicated cypress environment, or test):
<?php return [ // ... Tappet\Bundle\TappetBundle::class => ['cypress' => true], ];
2. Configure the bundle
Create config/packages/cypress/tappet.yaml (adjust the directory name to match your environment):
tappet: enabled: true api_key: '%env(TAPPET_API_KEY)%'
Set the same key in your .env.cypress (or pass it via the environment):
TAPPET_API_KEY=your-api-key
Use the same value for tappetApiKey in tappet.config.php and in your adapter config.
See the Tappet core README for details.
3. Write fixture loaders
For each fixture type, create a service that implements FixtureLoaderInterface. The bundle
auto-discovers these via Symfony's autoconfiguration; no manual tagging needed.
<?php declare(strict_types=1); namespace App\Tests\Tappet\Fixture\Loader; use App\Entity\User; use App\Repository\UserRepository; use App\Tests\Tappet\Fixture\UserFixture; use App\Tests\Tappet\Fixture\UserModel; use Tappet\Api\Fixture\Loader\FixtureLoaderInterface; use Tappet\Api\Fixture\Loader\LoaderPair; /** * @implements FixtureLoaderInterface<UserFixture, UserModel> */ class UserFixtureLoader implements FixtureLoaderInterface { public function __construct(private readonly UserRepository $userRepository) {} public function getLoaderPairs(): array { return [ UserFixture::class => new LoaderPair( loader: function (UserFixture $fixture): UserModel { $user = new User( firstName: $fixture->getFirstName(), lastName: $fixture->getLastName(), email: $fixture->getEmail(), ); $this->userRepository->save($user, flush: true); return new UserModel($user->getId()); }, unloader: function (UserFixture $fixture, UserModel $model): void { $user = $this->userRepository->find($model->getId()); if ($user !== null) { $this->userRepository->remove($user, flush: true); } }, ), ]; } }
The loader callable receives the fixture, creates the corresponding record, and returns a model.
The unloader callable receives both the fixture and the model and deletes the record.
Tappet calls the unloader automatically after each scenario completes, whether it passed or failed.
Fixture API endpoints
The bundle registers these routes automatically:
| Method | Path | Purpose |
|---|---|---|
POST |
/.well-known/tappet/fixture/{class} |
Create a single fixture |
POST |
/.well-known/tappet/fixtures |
Create multiple fixtures (in bulk) |
DELETE |
/.well-known/tappet/fixtures |
Delete all fixtures created in this scenario |
All requests are validated against the Authorization: Bearer <key> header using the configured
api_key. The api_key setting is required and may not be empty: requests that do not present the
correct key are rejected with a 403 response.
Fixture and model classes
Write fixture and model classes as described in the Tappet core README. It is suggested to keep them inside your test directory:
tests/
└── Tappet/
└── Fixture/
├── Loader/
│ └── UserFixtureLoader.php
├── UserFixture.php
└── UserModel.php