@@ -17,13 +17,16 @@ public function tearDown()
1717 public function testClearWithNoStoreArgument ()
1818 {
1919 $ command = new ClearCommandTestStub (
20- $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' )
20+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
21+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
2122 );
2223
2324 $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
2425
2526 $ app = new Application ;
27+ $ app ['path.storage ' ] = __DIR__ ;
2628 $ command ->setLaravel ($ app );
29+ $ files ->shouldReceive ('files ' )->andReturn ([]);
2730
2831 $ cacheManager ->shouldReceive ('store ' )->once ()->with (null )->andReturn ($ cacheRepository );
2932 $ cacheRepository ->shouldReceive ('flush ' )->once ();
@@ -34,13 +37,16 @@ public function testClearWithNoStoreArgument()
3437 public function testClearWithStoreArgument ()
3538 {
3639 $ command = new ClearCommandTestStub (
37- $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' )
40+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
41+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
3842 );
3943
4044 $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
4145
4246 $ app = new Application ;
47+ $ app ['path.storage ' ] = __DIR__ ;
4348 $ command ->setLaravel ($ app );
49+ $ files ->shouldReceive ('files ' )->andReturn ([]);
4450
4551 $ cacheManager ->shouldReceive ('store ' )->once ()->with ('foo ' )->andReturn ($ cacheRepository );
4652 $ cacheRepository ->shouldReceive ('flush ' )->once ();
@@ -55,13 +61,16 @@ public function testClearWithStoreArgument()
5561 public function testClearWithInvalidStoreArgument ()
5662 {
5763 $ command = new ClearCommandTestStub (
58- $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' )
64+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
65+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
5966 );
6067
6168 $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
6269
6370 $ app = new Application ;
71+ $ app ['path.storage ' ] = __DIR__ ;
6472 $ command ->setLaravel ($ app );
73+ $ files ->shouldReceive ('files ' )->andReturn ([]);
6574
6675 $ cacheManager ->shouldReceive ('store ' )->once ()->with ('bar ' )->andThrow ('InvalidArgumentException ' );
6776 $ cacheRepository ->shouldReceive ('flush ' )->never ();
@@ -72,13 +81,16 @@ public function testClearWithInvalidStoreArgument()
7281 public function testClearWithTagsOption ()
7382 {
7483 $ command = new ClearCommandTestStub (
75- $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' )
84+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
85+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
7686 );
7787
7888 $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
7989
8090 $ app = new Application ;
91+ $ app ['path.storage ' ] = __DIR__ ;
8192 $ command ->setLaravel ($ app );
93+ $ files ->shouldReceive ('files ' )->andReturn ([]);
8294
8395 $ cacheManager ->shouldReceive ('store ' )->once ()->with (null )->andReturn ($ cacheRepository );
8496 $ cacheRepository ->shouldReceive ('tags ' )->once ()->with (['foo ' , 'bar ' ])->andReturn ($ cacheRepository );
@@ -90,13 +102,16 @@ public function testClearWithTagsOption()
90102 public function testClearWithStoreArgumentAndTagsOption ()
91103 {
92104 $ command = new ClearCommandTestStub (
93- $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' )
105+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
106+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
94107 );
95108
96109 $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
97110
98111 $ app = new Application ;
112+ $ app ['path.storage ' ] = __DIR__ ;
99113 $ command ->setLaravel ($ app );
114+ $ files ->shouldReceive ('files ' )->andReturn ([]);
100115
101116 $ cacheManager ->shouldReceive ('store ' )->once ()->with ('redis ' )->andReturn ($ cacheRepository );
102117 $ cacheRepository ->shouldReceive ('tags ' )->once ()->with (['foo ' ])->andReturn ($ cacheRepository );
@@ -105,6 +120,27 @@ public function testClearWithStoreArgumentAndTagsOption()
105120 $ this ->runCommand ($ command , ['store ' => 'redis ' , '--tags ' => 'foo ' ]);
106121 }
107122
123+ public function testClearWillClearsRealTimeFacades ()
124+ {
125+ $ command = new ClearCommandTestStub (
126+ $ cacheManager = m::mock ('Illuminate\Cache\CacheManager ' ),
127+ $ files = m::mock ('Illuminate\Filesystem\Filesystem ' )
128+ );
129+
130+ $ cacheRepository = m::mock ('Illuminate\Contracts\Cache\Repository ' );
131+
132+ $ app = new Application ;
133+ $ app ['path.storage ' ] = __DIR__ ;
134+ $ command ->setLaravel ($ app );
135+ $ cacheManager ->shouldReceive ('store ' )->once ()->with (null )->andReturn ($ cacheRepository );
136+ $ cacheRepository ->shouldReceive ('flush ' )->once ();
137+
138+ $ files ->shouldReceive ('files ' )->andReturn (['/facade-XXXX.php ' ]);
139+ $ files ->shouldReceive ('delete ' )->with ('/facade-XXXX.php ' )->once ();
140+
141+ $ this ->runCommand ($ command );
142+ }
143+
108144 protected function runCommand ($ command , $ input = [])
109145 {
110146 return $ command ->run (new \Symfony \Component \Console \Input \ArrayInput ($ input ), new \Symfony \Component \Console \Output \NullOutput );
0 commit comments