2017 © Pedro Peláez
 

testwork-extension symfony-extension

extension that helps using your symfony application's services in your tests

image

funk-spec/symfony-extension

extension that helps using your symfony application's services in your tests

  • Tuesday, May 29, 2018
  • by florian.klein@free.fr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8,991 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

funk-spec/symfony-extension

 composer require --dev funk-spec/symfony-extension

What ?

A funk-spec extension that integrates your symfony application with your specs., (*1)

It will:, (*2)

  • resolve constructor arguments typehinted with ContainerInterface
  • wrap each example with a doctrine transaction and rollback afterwards

Why ?

For the same exact reason than the behat's one exists.
Both are relying on the TestWork framework.
Unfortunately, a lot of duplication exists between both, but no real tentative has been done yet to abstract away the few differences., (*3)

How ?

In your funk.yml:, (*4)

default:
    autoload:
        tests: '%paths.base%'

    suites:
        default: ~

    extensions:
        FunkSpec\Extension\Symfony\Extension:
            kernel:
                class: App\Symfony\Kernel # or AppKernel (must be autoloadable)
                env: test

Now your spec classes can have the container injected:, (*5)

<?php

namespace tests\Doctrine\Repository;

use Symfony\Component\DependencyInjection\ContainerInterface;

final class Products implements \Funk\Spec
{
    public function __construct(ContainerInterface $container)
    {
        $this->products = $container->get('products'); // this is a repository
    }

    function it_works()
    {
        $this->products->find('77c4bb2e-2c18-4164-a899-7f969dec5c9d')->getId();
    }
}

automatic transaction wrapping and rollback

Every example is ran in a transaction and rollbacked after each execution, except if you explicitely disable it:, (*6)

default:
    extensions:
        FunkSpec\Extension\Symfony\Extension:
            doctrine:
                rollback: false

This depends on the presence of a doctrine service in the application Kernel, insanceof ManagerRegistry., (*7)

The Versions

29/05 2018

dev-master

9999999-dev

extension that helps using your symfony application's services in your tests

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2018

0.1.2

0.1.2.0

extension that helps using your symfony application's services in your tests

  Sources   Download

MIT

The Requires

 

The Development Requires

27/11 2017

0.1.1

0.1.1.0

extension that helps using your symfony application's services in your tests

  Sources   Download

MIT

The Requires

 

The Development Requires

29/09 2016

0.1.0

0.1.0.0

extension that helps using your symfony application's services in your tests

  Sources   Download

MIT