Skip to content

Instantly share code, notes, and snippets.

@arnolanglade
Last active February 8, 2018 14:26
Show Gist options
  • Save arnolanglade/4ca0bedbcf41356a112a to your computer and use it in GitHub Desktop.
Save arnolanglade/4ca0bedbcf41356a112a to your computer and use it in GitHub Desktop.
PhpSpec Symfony command template
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CommandSpec extends ObjectBehavior
{
function it_has_a_name()
{
$this->getName()->shouldReturn('name:command');
}
function it_is_a_container_aware_command()
{
$this->shouldHaveType('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand');
}
function it_do_something(
ContainerInterface $container,
InputInterface $input,
OutputInterface $output
) {
// With options
$input->bind(Argument::any())->shouldBeCalled();
$input->isInteractive()->shouldBeCalled();
$input->validate()->shouldBeCalled();
$this->setContainer($container);
$this->run($input, $output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment