123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- /**
- * Gearman Bundle for Symfony2
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * Feel free to edit as you please, and have fun.
- *
- * @author Marc Morera <yuhu@mmoreram.com>
- */
- 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
- );
- }
- }
|