tienvx / pact-provider-bundle
Pact Provider Bundle
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.1
- symfony/config: ^5.4|^6.4|7.0
- symfony/dependency-injection: ^5.4|^6.4|7.0
- symfony/http-kernel: ^5.4|^6.4|7.0
Requires (Dev)
- phpunit/phpunit: ^10.1
- symfony/framework-bundle: ^5.4|^6.4|7.0
- symfony/test-pack: ^1.0
Conflicts
README
This Symfony Bundle allow testing Symfony project with Pact PHP. It support:
- Verify sending messages
- Set up provider state
- Tear down provider state
Installation
composer require tienvx/pact-provider-bundle
Documentation
Register State Handler
namespace App\StateHandler; use Tienvx\Bundle\PactProviderBundle\Attribute\AsStateHandler; use Tienvx\Bundle\PactProviderBundle\Model\StateValues; use Tienvx\Bundle\PactProviderBundle\StateHandler\SetUpInterface; use Tienvx\Bundle\PactProviderBundle\StateHandler\TearDownInterface; #[AsStateHandler(state: 'A user with id dcd79453-7346-4423-ae6e-127c60d8dd20 exists')] class UserHandler implements SetUpInterface, TearDownInterface { public function setUp(array $params): ?StateValues { return new StateValues([ 'id' => 123, ]); } public function tearDown(array $params): void { } }
Register Message Dispatcher
namespace App\MessageDispatcher; use Tienvx\Bundle\PactProviderBundle\Attribute\AsMessageDispatcher; use Tienvx\Bundle\PactProviderBundle\Model\Message; use Tienvx\Bundle\PactProviderBundle\MessageDispatcher\DispatcherInterface; #[AsMessageDispatcher(description: 'User created message')] class UserDispatcher implements DispatcherInterface { public function dispatch(): ?Message { } }