File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
src/Illuminate/View/Compilers Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 22
33namespace Illuminate \View \Compilers ;
44
5+ use InvalidArgumentException ;
56use Illuminate \Filesystem \Filesystem ;
67
78abstract class Compiler
@@ -26,9 +27,15 @@ abstract class Compiler
2627 * @param \Illuminate\Filesystem\Filesystem $files
2728 * @param string $cachePath
2829 * @return void
30+ *
31+ * @throws \InvalidArgumentException
2932 */
3033 public function __construct (Filesystem $ files , $ cachePath )
3134 {
35+ if (! $ cachePath ) {
36+ throw new InvalidArgumentException ('Please provide a valid cache path. ' );
37+ }
38+
3239 $ this ->files = $ files ;
3340 $ this ->cachePath = $ cachePath ;
3441 }
@@ -57,7 +64,7 @@ public function isExpired($path)
5764 // If the compiled file doesn't exist we will indicate that the view is expired
5865 // so that it can be re-compiled. Else, we will verify the last modification
5966 // of the views is less than the modification times of the compiled views.
60- if (! $ this ->cachePath || ! $ this -> files ->exists ($ compiled )) {
67+ if (! $ this ->files ->exists ($ compiled )) {
6168 return true ;
6269 }
6370
Original file line number Diff line number Diff line change @@ -17,11 +17,12 @@ public function testIsExpiredReturnsTrueIfCompiledFileDoesntExist()
1717 $ this ->assertTrue ($ compiler ->isExpired ('foo ' ));
1818 }
1919
20- public function testIsExpiredReturnsTrueIfCachePathIsNull ()
20+ /**
21+ * @expectedException \InvalidArgumentException
22+ */
23+ public function testCannotConstructWithBadCachePath ()
2124 {
22- $ compiler = new BladeCompiler ($ files = $ this ->getFiles (), null );
23- $ files ->shouldReceive ('exists ' )->never ();
24- $ this ->assertTrue ($ compiler ->isExpired ('foo ' ));
25+ new BladeCompiler ($ this ->getFiles (), null );
2526 }
2627
2728 public function testIsExpiredReturnsTrueWhenModificationTimesWarrant ()
@@ -75,14 +76,6 @@ public function testCompileWithPathSetBefore()
7576 $ this ->assertEquals ('foo ' , $ compiler ->getPath ());
7677 }
7778
78- public function testCompileDoesntStoreFilesWhenCachePathIsNull ()
79- {
80- $ compiler = new BladeCompiler ($ files = $ this ->getFiles (), null );
81- $ files ->shouldReceive ('get ' )->never ();
82- $ files ->shouldReceive ('put ' )->never ();
83- $ compiler ->compile ('foo ' );
84- }
85-
8679 public function testEchosAreCompiled ()
8780 {
8881 $ compiler = new BladeCompiler ($ this ->getFiles (), __DIR__ );
You can’t perform that action at this time.
0 commit comments