diff --git a/tests/Cache/ClearCommandTest.php b/tests/Cache/ClearCommandTest.php index 29b074447aa6..004ce94ff83b 100644 --- a/tests/Cache/ClearCommandTest.php +++ b/tests/Cache/ClearCommandTest.php @@ -11,7 +11,7 @@ public function tearDown() m::close(); } - public function testClearWithNoStoreOption() + public function testClearWithNoStoreArgument() { $command = new ClearCommandTestStub( $cacheManager = m::mock('Illuminate\Cache\CacheManager') @@ -28,7 +28,7 @@ public function testClearWithNoStoreOption() $this->runCommand($command); } - public function testClearWithStoreOption() + public function testClearWithStoreArgument() { $command = new ClearCommandTestStub( $cacheManager = m::mock('Illuminate\Cache\CacheManager') @@ -48,7 +48,7 @@ public function testClearWithStoreOption() /** * @expectedException InvalidArgumentException */ - public function testClearWithInvalidStoreOption() + public function testClearWithInvalidStoreArgument() { $command = new ClearCommandTestStub( $cacheManager = m::mock('Illuminate\Cache\CacheManager') @@ -65,6 +65,42 @@ public function testClearWithInvalidStoreOption() $this->runCommand($command, ['store' => 'bar']); } + public function testClearWithTagsOption() + { + $command = new ClearCommandTestStub( + $cacheManager = m::mock('Illuminate\Cache\CacheManager') + ); + + $cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository'); + + $app = new Application(); + $command->setLaravel($app); + + $cacheManager->shouldReceive('store')->once()->with(null)->andReturn($cacheRepository); + $cacheRepository->shouldReceive('tags')->once()->with(['foo', 'bar'])->andReturn($cacheRepository); + $cacheRepository->shouldReceive('flush')->once(); + + $this->runCommand($command, ['--tags' => 'foo,bar']); + } + + public function testClearWithStoreArgumentAndTagsOption() + { + $command = new ClearCommandTestStub( + $cacheManager = m::mock('Illuminate\Cache\CacheManager') + ); + + $cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository'); + + $app = new Application(); + $command->setLaravel($app); + + $cacheManager->shouldReceive('store')->once()->with('redis')->andReturn($cacheRepository); + $cacheRepository->shouldReceive('tags')->once()->with(['foo'])->andReturn($cacheRepository); + $cacheRepository->shouldReceive('flush')->once(); + + $this->runCommand($command, ['store' => 'redis', '--tags' => 'foo']); + } + protected function runCommand($command, $input = []) { return $command->run(new Symfony\Component\Console\Input\ArrayInput($input), new Symfony\Component\Console\Output\NullOutput);