*/ namespace Mmoreram\GearmanBundle\Tests\Command; use PHPUnit_Framework_TestCase; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; use Mmoreram\GearmanBundle\Command\GearmanCacheClearCommand; use Mmoreram\GearmanBundle\Service\GearmanCacheWrapper; /** * Class GearmanCacheClearCommandTest */ class GearmanCacheClearCommandTest extends PHPUnit_Framework_TestCase { /** * @var GearmanCacheClearCommand * * Command */ protected $command; /** * @var InputInterface * * Input */ protected $input; /** * @var OutputInterface * * Output */ protected $output; /** * @var GearmanCacheWrapper * * Gearman Cache Wrapper */ protected $gearmanCacheWrapper; /** * @var KernelInterface * * Kernel */ protected $kernel; /** * Set up method */ public function setUp() { $this->command = $this ->getMockBuilder('Mmoreram\GearmanBundle\Command\GearmanCacheClearCommand') ->setMethods(null) ->getMock(); $this->input = $this ->getMockBuilder('Symfony\Component\Console\Input\InputInterface') ->disableOriginalConstructor() ->setMethods(array()) ->getMock(); $this->output = $this ->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') ->disableOriginalConstructor() ->setMethods(array()) ->getMock(); $this->kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface') ->disableOriginalConstructor() ->setMethods(array()) ->getMock(); $this->gearmanCacheWrapper = $this ->getMockBuilder('Mmoreram\GearmanBundle\Service\GearmanCacheWrapper') ->disableOriginalConstructor() ->setMethods(array( 'clear', )) ->getMock(); $this ->gearmanCacheWrapper ->expects($this->once()) ->method('clear'); $this ->kernel ->expects($this->any()) ->method('getEnvironment') ->will($this->returnValue('dev')); $this ->command ->setGearmanCacheWrapper($this->gearmanCacheWrapper) ->setKernel($this->kernel); } /** * Test run quietness */ public function testRunQuiet() { $this ->input ->expects($this->any()) ->method('getOption') ->will($this->returnValueMap(array( array('quiet', true) ))); $this ->output ->expects($this->never()) ->method('writeln'); $this ->command ->run( $this->input, $this->output ); } /** * Test run without quietness */ public function testRunNonQuiet() { $this ->input ->expects($this->any()) ->method('getOption') ->will($this->returnValueMap(array( array('quiet', false) ))); $this ->output ->expects($this->any()) ->method('writeln'); $this ->command ->run( $this->input, $this->output ); } }