Skip to content

Commit c804ba4

Browse files
Add tests
1 parent bb0f780 commit c804ba4

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

tests/Cache/ClearCommandTest.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function tearDown()
1111
m::close();
1212
}
1313

14-
public function testClearWithNoStoreOption()
14+
public function testClearWithNoStoreArgument()
1515
{
1616
$command = new ClearCommandTestStub(
1717
$cacheManager = m::mock('Illuminate\Cache\CacheManager')
@@ -28,7 +28,7 @@ public function testClearWithNoStoreOption()
2828
$this->runCommand($command);
2929
}
3030

31-
public function testClearWithStoreOption()
31+
public function testClearWithStoreArgument()
3232
{
3333
$command = new ClearCommandTestStub(
3434
$cacheManager = m::mock('Illuminate\Cache\CacheManager')
@@ -48,7 +48,7 @@ public function testClearWithStoreOption()
4848
/**
4949
* @expectedException InvalidArgumentException
5050
*/
51-
public function testClearWithInvalidStoreOption()
51+
public function testClearWithInvalidStoreArgument()
5252
{
5353
$command = new ClearCommandTestStub(
5454
$cacheManager = m::mock('Illuminate\Cache\CacheManager')
@@ -65,6 +65,42 @@ public function testClearWithInvalidStoreOption()
6565
$this->runCommand($command, ['store' => 'bar']);
6666
}
6767

68+
public function testClearWithTagsOption()
69+
{
70+
$command = new ClearCommandTestStub(
71+
$cacheManager = m::mock('Illuminate\Cache\CacheManager')
72+
);
73+
74+
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
75+
76+
$app = new Application();
77+
$command->setLaravel($app);
78+
79+
$cacheManager->shouldReceive('store')->once()->with(null)->andReturn($cacheRepository);
80+
$cacheRepository->shouldReceive('tags')->once()->with(['foo', 'bar'])->andReturn($cacheRepository);
81+
$cacheRepository->shouldReceive('flush')->once();
82+
83+
$this->runCommand($command, ['--tags' => 'foo,bar']);
84+
}
85+
86+
public function testClearWithStoreArgumentAndTagsOption()
87+
{
88+
$command = new ClearCommandTestStub(
89+
$cacheManager = m::mock('Illuminate\Cache\CacheManager')
90+
);
91+
92+
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
93+
94+
$app = new Application();
95+
$command->setLaravel($app);
96+
97+
$cacheManager->shouldReceive('store')->once()->with('redis')->andReturn($cacheRepository);
98+
$cacheRepository->shouldReceive('tags')->once()->with(['foo'])->andReturn($cacheRepository);
99+
$cacheRepository->shouldReceive('flush')->once();
100+
101+
$this->runCommand($command, ['store' => 'redis', '--tags' => 'foo']);
102+
}
103+
68104
protected function runCommand($command, $input = [])
69105
{
70106
return $command->run(new Symfony\Component\Console\Input\ArrayInput($input), new Symfony\Component\Console\Output\NullOutput);

0 commit comments

Comments
 (0)