atoum / AtoumBundle

This bundle provides a simple integration of atoum into Symfony 2.
MIT License
45 stars 25 forks source link

Adds the ability to test Symfony commands #84

Closed mikaelrandy closed 9 years ago

mikaelrandy commented 9 years ago

With this commit, its become possible to easily test commands

Exemple :

<?php

namespace My\Bundle\FoobarBundle\Tests\Units\Command;

use atoum\AtoumBundle\Test\Units as AtoumBundle;
use mageekguy\atoum;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;

// Assuming that this command will display "Success" if succes, and returns a boolean
use My\Bundle\FoobarBundle\Tests\Units\Command\FoobarCommand as Base;

class FoobarCommand extends AtoumBundle\CommandTestCase
{
    public function testExecute()
    {
        $this
            ->given(
                $command = new Base()
            )
            ->if($commandTester = $this->createCommandTester($command))
            ->then
                ->boolean($commandTester->execute())
                    ->isTrue()
                ->string($commandTester->getDisplay())
                    ->contains("Success")
        ;
    }
}
jdlabails commented 9 years ago

:+1:

FlorianLB commented 9 years ago

I agree with @jubianchi about ContainerAwareCommand.

Otherwise :+1:

jubianchi commented 9 years ago

@mikaelrandy :+1:

If you could add your example in the readme, it would be awesome!

jubianchi commented 9 years ago

:+1:

mikaelrandy commented 9 years ago

There is something missing on this PR ? What is the next step ?

jubianchi commented 9 years ago

If everything is ok for everyone, I propose to merge and tag a release for the bundle.

I can handle it.

mikaelrandy commented 9 years ago

Great !

For information, i can't do anything on the bundle ;)

FlorianLB commented 9 years ago

I will do it. I will review all remaining PR and tag a new release.

jubianchi commented 9 years ago

👍🏻 @FlorianLB

FlorianLB commented 9 years ago

Is there a BC break here ?

Next version will be 1.2.0 or 2.0.0 ?

mikaelrandy commented 9 years ago

There is no regression in the interface, just some code moved to one level up in class hierarchy.