Skip to content

tienvx/pact-provider-bundle

Repository files navigation

Pact Provider Bundle Build Status Coverage Status Version PHP Version

This Symfony Bundle allow testing Symfony project with Pact PHP. It support:

  • Verify sending messages
  • Set up fixture
  • Tear down fixture

Installation

composer require tienvx/pact-provider-bundle

Documentation

Register State Handler

namespace App\StateHandler;

use Tienvx\Bundle\PactProviderBundle\Attribute\AsStateHandler;
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): void
    {
    }

    public function tearDown(array $params): void
    {
    }
}

For Symfony 4.4 only:

# config/services.yaml
services:
    App\StateHandler\UserHandler:
        tags:
            - { name: 'pact_provider.state_handler', state: 'A user with id dcd79453-7346-4423-ae6e-127c60d8dd20 exists' }

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
    {
    }
}

For Symfony 4.4 only:

# config/services.yaml
services:
    App\MessageDispatcher\UserDispatcher:
        tags:
            - { name: 'pact_provider.message_dispatcher', description: 'User created message' }

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages