Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/View/Compilers/BladeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public function compile($path = null)
}

if (! is_null($this->cachePath)) {
$contents = $this->compileString($this->files->get($this->getPath()));
$contents = "<?php/* {$this->getPath()} */?>\n";
$contents .= $this->compileString($this->files->get($this->getPath()));

$this->files->put($this->getCompiledPath($this->getPath()), $contents);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Mail/RenderingMailWithLocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public function testMailableRendersInDefaultLocale()
{
$mail = new RenderedTestMail;

$this->assertEquals('name'.PHP_EOL, $mail->render());
$this->assertStringContainsString("name\n", $mail->render());
}

public function testMailableRendersInSelectedLocale()
{
$mail = (new RenderedTestMail)->locale('es');

$this->assertEquals('nombre'.PHP_EOL, $mail->render());
$this->assertStringContainsString("nombre\n", $mail->render());
}

public function testMailableRendersInAppSelectedLocale()
Expand All @@ -47,7 +47,7 @@ public function testMailableRendersInAppSelectedLocale()

$mail = new RenderedTestMail;

$this->assertEquals('nombre'.PHP_EOL, $mail->render());
$this->assertStringContainsString("nombre\n", $mail->render());
}
}

Expand Down
14 changes: 11 additions & 3 deletions tests/View/ViewBladeCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public function testCompileCompilesFileAndReturnsContents()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "<?php/* foo */?>\nHello World");
$compiler->compile('foo');
}

public function testCompileCompilesAndGetThePath()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "<?php/* foo */?>\nHello World");
$compiler->compile('foo');
$this->assertEquals('foo', $compiler->getPath());
}
Expand All @@ -73,7 +73,7 @@ public function testCompileWithPathSetBefore()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "<?php/* foo */?>\nHello World");
// set path before compilation
$compiler->setPath('foo');
// trigger compilation with null $path
Expand All @@ -93,6 +93,14 @@ public function testRawTagsCanBeSetToLegacyValues()
}}'));
}

public function testIncludePathToTemplate()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
$files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "<?php/* foo */?>\nHello World");
$compiler->compile('foo');
}

protected function getFiles()
{
return m::mock(Filesystem::class);
Expand Down