11
11
use Symfony \Component \Finder \Finder ;
12
12
use Symfony \Component \Finder \SplFileInfo ;
13
13
14
+ use function Orchestra \Testbench \artisan ;
15
+ use function Orchestra \Testbench \phpunit_version_compare ;
16
+
14
17
class BladeTest extends TestCase
15
18
{
19
+ /** {@inheritdoc} */
20
+ #[\Override]
21
+ protected function tearDown (): void
22
+ {
23
+ artisan ($ this , 'view:clear ' );
24
+
25
+ parent ::tearDown ();
26
+ }
27
+
16
28
public function test_rendering_blade_string ()
17
29
{
18
30
$ this ->assertSame ('Hello Taylor ' , Blade::render ('Hello {{ $name }} ' , ['name ' => 'Taylor ' ]));
@@ -33,8 +45,8 @@ public function test_rendering_blade_long_maxpathlen_string_with_exact_length()
33
45
// The PHP_MAXPATHLEN restriction is only active, if
34
46
// open_basedir is set and active. Otherwise, the check
35
47
// for the PHP_MAXPATHLEN is not active.
36
- if (ini_get ('open_basedir ' ) === '' ) {
37
- $ openBaseDir = windows_os () ? explode ('\\' , __DIR__ )[0 ].'\\' . ' ; ' .sys_get_temp_dir () : ' / ' ;
48
+ if (ini_get ('open_basedir ' ) === '' && phpunit_version_compare ( ' 12.1.0 ' , ' < ' ) ) {
49
+ $ openBaseDir = explode (DIRECTORY_SEPARATOR , __DIR__ )[0 ].DIRECTORY_SEPARATOR . PATH_SEPARATOR .sys_get_temp_dir ();
38
50
$ iniSet = ini_set (
39
51
'open_basedir ' ,
40
52
$ openBaseDir
@@ -197,19 +209,17 @@ public function test_bound_name_attribute_can_be_used_if_using_short_slot_names_
197
209
198
210
public function testViewCacheCommandHandlesConfiguredBladeExtensions ()
199
211
{
200
- $ this ->artisan ('view:clear ' );
201
-
202
212
View::addExtension ('sh ' , 'blade ' );
203
213
$ this ->artisan ('view:cache ' );
204
214
205
215
$ compiledFiles = Finder::create ()->in (Config::get ('view.compiled ' ))->files ();
206
216
$ found = collect ($ compiledFiles )
207
217
->contains (fn (SplFileInfo $ file ) => str_contains ($ file ->getContents (), 'echo "<?php echo e($scriptMessage); ?>" > output.log ' ));
208
218
$ this ->assertTrue ($ found );
209
-
210
- $ this ->artisan ('view:clear ' );
211
219
}
212
220
221
+ /** {@inheritdoc} */
222
+ #[\Override]
213
223
protected function defineEnvironment ($ app )
214
224
{
215
225
$ app ['config ' ]->set ('view.paths ' , [__DIR__ .'/templates ' ]);
0 commit comments