Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save St0iK/72398539de0809c5c64975ce4bede603 to your computer and use it in GitHub Desktop.
Save St0iK/72398539de0809c5c64975ce4bede603 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