@@ -66,7 +66,7 @@ public function testCompileCompilesFileAndReturnsContents()
66
66
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
67
67
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
68
68
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
69
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
69
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' );
70
70
$ compiler ->compile ('foo ' );
71
71
}
72
72
@@ -76,7 +76,7 @@ public function testCompileCompilesFileAndReturnsContentsCreatingDirectory()
76
76
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
77
77
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (false );
78
78
$ files ->shouldReceive ('makeDirectory ' )->once ()->with (__DIR__ , 0777 , true , true );
79
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
79
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' );
80
80
$ compiler ->compile ('foo ' );
81
81
}
82
82
@@ -85,7 +85,7 @@ public function testCompileCompilesAndGetThePath()
85
85
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
86
86
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
87
87
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
88
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
88
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' );
89
89
$ compiler ->compile ('foo ' );
90
90
$ this ->assertSame ('foo ' , $ compiler ->getPath ());
91
91
}
@@ -102,7 +102,7 @@ public function testCompileWithPathSetBefore()
102
102
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
103
103
$ files ->shouldReceive ('get ' )->once ()->with ('foo ' )->andReturn ('Hello World ' );
104
104
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
105
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' );
105
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2foo ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' );
106
106
// set path before compilation
107
107
$ compiler ->setPath ('foo ' );
108
108
// trigger compilation with $path
@@ -145,39 +145,39 @@ public static function appendViewPathDataProvider()
145
145
return [
146
146
'No PHP blocks ' => [
147
147
'Hello World ' ,
148
- 'Hello World<?php /**PATH foo ENDPATH**/ ?> ' ,
148
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' ,
149
149
],
150
150
'Single PHP block without closing ?> ' => [
151
151
'<?php echo $path ' ,
152
- '<?php echo $path ?><?php /**PATH foo ENDPATH**/ ?> ' ,
152
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?><?php echo $path ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
153
153
],
154
154
'Ending PHP block. ' => [
155
155
'Hello world<?php echo $path ?> ' ,
156
- 'Hello world<?php echo $path ?><?php /**PATH foo ENDPATH**/ ?> ' ,
156
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?php echo $path ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
157
157
],
158
158
'Ending PHP block without closing ?> ' => [
159
159
'Hello world<?php echo $path ' ,
160
- 'Hello world<?php echo $path ?><?php /**PATH foo ENDPATH**/ ?> ' ,
160
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?php echo $path ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
161
161
],
162
162
'PHP block between content. ' => [
163
163
'Hello world<?php echo $path ?>Hi There ' ,
164
- 'Hello world<?php echo $path ?>Hi There<?php /**PATH foo ENDPATH**/ ?> ' ,
164
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?php echo $path ?>Hi There<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' ,
165
165
],
166
166
'Multiple PHP blocks. ' => [
167
167
'Hello world<?php echo $path ?>Hi There<?php echo $path ?>Hello Again ' ,
168
- 'Hello world<?php echo $path ?>Hi There<?php echo $path ?>Hello Again<?php /**PATH foo ENDPATH**/ ?> ' ,
168
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?php echo $path ?>Hi There<?php echo $path ?>Hello Again<?php } ?> <?php /**PATH foo ENDPATH**/ ?> ' ,
169
169
],
170
170
'Multiple PHP blocks without closing ?> ' => [
171
171
'Hello world<?php echo $path ?>Hi There<?php echo $path ' ,
172
- 'Hello world<?php echo $path ?>Hi There<?php echo $path ?><?php /**PATH foo ENDPATH**/ ?> ' ,
172
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?php echo $path ?>Hi There<?php echo $path ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
173
173
],
174
174
'Short open echo tag ' => [
175
175
'Hello world<?= echo $path ' ,
176
- 'Hello world<?= echo $path ?><?php /**PATH foo ENDPATH**/ ?> ' ,
176
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello world<?= echo $path ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
177
177
],
178
178
'Echo XML declaration ' => [
179
179
'<?php echo \'<?xml version="1.0" encoding="UTF-8"?> \'; ' ,
180
- '<?php echo \'<?xml version="1.0" encoding="UTF-8"?> \'; ?><?php /**PATH foo ENDPATH**/ ?> ' ,
180
+ '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?><?php echo \'<?xml version="1.0" encoding="UTF-8"?> \'; ?><?php } ?><?php /**PATH foo ENDPATH**/ ?> ' ,
181
181
],
182
182
];
183
183
}
@@ -187,7 +187,7 @@ public function testDontIncludeEmptyPath()
187
187
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
188
188
$ files ->shouldReceive ('get ' )->once ()->with ('' )->andReturn ('Hello World ' );
189
189
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
190
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2 ' ).'.php ' , 'Hello World ' );
190
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2 ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> ' );
191
191
$ compiler ->setPath ('' );
192
192
$ compiler ->compile ();
193
193
}
@@ -197,7 +197,7 @@ public function testDontIncludeNullPath()
197
197
$ compiler = new BladeCompiler ($ files = $ this ->getFiles (), __DIR__ );
198
198
$ files ->shouldReceive ('get ' )->once ()->with (null )->andReturn ('Hello World ' );
199
199
$ files ->shouldReceive ('exists ' )->once ()->with (__DIR__ )->andReturn (true );
200
- $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2 ' ).'.php ' , 'Hello World ' );
200
+ $ files ->shouldReceive ('put ' )->once ()->with (__DIR__ .'/ ' .hash ('xxh128 ' , 'v2 ' ).'.php ' , '<?php return function ($__laravel_data) { extract($__laravel_data, EXTR_SKIP); ?> Hello World<?php } ?> ' );
201
201
$ compiler ->setPath (null );
202
202
$ compiler ->compile ();
203
203
}
0 commit comments