@@ -18,7 +18,7 @@ protected function tearDown(): void
18
18
public function testIsExpiredReturnsTrueIfCompiledFileDoesntExist ()
19
19
{
20
20
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
21
- $ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' )->andReturn (false );
21
+ $ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' )->andReturn (false );
22
22
$ this ->assertTrue ($ compiler ->isExpired ('foo ' ));
23
23
}
24
24
@@ -33,24 +33,24 @@ public function testCannotConstructWithBadCachePath()
33
33
public function testIsExpiredReturnsTrueWhenModificationTimesWarrant ()
34
34
{
35
35
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
36
- $ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' )->andReturn (true );
36
+ $ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' )->andReturn (true );
37
37
$ files ->shouldReceive ('lastModified ' )->once ()->with ('foo ' )->andReturn (100 );
38
- $ files ->shouldReceive ('lastModified ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' )->andReturn (0 );
38
+ $ files ->shouldReceive ('lastModified ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' )->andReturn (0 );
39
39
$ this ->assertTrue ($ compiler ->isExpired ('foo ' ));
40
40
}
41
41
42
42
public function testCompilePathIsProperlyCreated ()
43
43
{
44
44
$ compiler = new BladeCompiler ($ this ->getFiles (), __DIR__ );
45
- $ this ->assertEquals (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , $ compiler ->getCompiledPath ('foo ' ));
45
+ $ this ->assertEquals (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , $ compiler ->getCompiledPath ('foo ' ));
46
46
}
47
47
48
48
public function testCompileCompilesFileAndReturnsContents ()
49
49
{
50
50
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
51
51
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
52
52
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
53
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
53
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
54
54
$ compiler ->compile ('foo ' );
55
55
}
56
56
@@ -60,7 +60,7 @@ public function testCompileCompilesFileAndReturnsContentsCreatingDirectory()
60
60
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
61
61
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (false );
62
62
$ files ->shouldReceive ('makeDirectory ' )->once ()->with (__DIR__ , 0777 , true , true );
63
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
63
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
64
64
$ compiler ->compile ('foo ' );
65
65
}
66
66
@@ -69,7 +69,7 @@ public function testCompileCompilesAndGetThePath()
69
69
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
70
70
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
71
71
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
72
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
72
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
73
73
$ compiler ->compile ('foo ' );
74
74
$ this ->assertSame ('foo ' , $ compiler ->getPath ());
75
75
}
@@ -86,7 +86,7 @@ public function testCompileWithPathSetBefore()
86
86
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
87
87
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
88
88
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
89
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
89
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
90
90
// set path before compilation
91
91
$ compiler ->setPath ('foo ' );
92
92
// trigger compilation with $path
@@ -117,7 +117,7 @@ public function testIncludePathToTemplate($content, $compiled)
117
117
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
118
118
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ($ content );
119
119
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
120
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('foo ' ).'.php ' , $ compiled );
120
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2foo ' ).'.php ' , $ compiled );
121
121
122
122
$ compiler ->compile ('foo ' );
123
123
}
@@ -172,11 +172,21 @@ public function testDontIncludeEmptyPath()
172
172
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
173
173
$ files ->shouldReceive ('get ' )->once ()->with ('' )->andReturn ('Hello World ' );
174
174
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
175
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('' ).'.php ' , 'Hello World ' );
175
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2 ' ).'.php ' , 'Hello World ' );
176
176
$ compiler ->setPath ('' );
177
177
$ compiler ->compile ();
178
178
}
179
179
180
+ public function testDontIncludeNullPath ()
181
+ {
182
+ $ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
183
+ $ files ->shouldReceive ('get ' )->once ()->with (null )->andReturn ('Hello World ' );
184
+ $ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
185
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .sha1 ('v2 ' ).'.php ' , 'Hello World ' );
186
+ $ compiler ->setPath (null );
187
+ $ compiler ->compile ();
188
+ }
189
+
180
190
public function testShouldStartFromStrictTypesDeclaration ()
181
191
{
182
192
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
0 commit comments