Skip to content

Instantly share code, notes, and snippets.

@dlondero
Created January 18, 2013 14:47
Show Gist options
  • Save dlondero/4565028 to your computer and use it in GitHub Desktop.
Save dlondero/4565028 to your computer and use it in GitHub Desktop.
<?php
namespace Acme\DemoBundle\Tests\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Acme\DemoBundle\Command\EmailCommand;
class EmailCommandTest extends WebTestCase
{
public function testExecute()
{
$client = self::createClient();
$application = new Application($client->getKernel());
$application->add(new EmailCommand());
$command = $application->find('demo:email');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
$this->assertRegExp('/Email sent/', $commandTester->getDisplay());
$container = $client->getKernel()->getContainer();
$profiler = $container->get('profiler');
$mailerCollector = $profiler->get('swiftmailer');
var_dump($mailerCollector->getMessages());
$mailerLogger = $container->get('swiftmailer.plugin.messagelogger');
var_dump($mailerLogger->getMessages());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment