diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php index ddbfd912c2ae..0175caf2b42f 100644 --- a/src/Illuminate/View/Compilers/BladeCompiler.php +++ b/src/Illuminate/View/Compilers/BladeCompiler.php @@ -118,7 +118,8 @@ public function compile($path = null) } if (! is_null($this->cachePath)) { - $contents = $this->compileString($this->files->get($this->getPath())); + $contents = "getPath()} */?>\n"; + $contents .= $this->compileString($this->files->get($this->getPath())); $this->files->put($this->getCompiledPath($this->getPath()), $contents); } diff --git a/tests/Integration/Mail/RenderingMailWithLocaleTest.php b/tests/Integration/Mail/RenderingMailWithLocaleTest.php index e6697a7edcb7..3e03084778f5 100644 --- a/tests/Integration/Mail/RenderingMailWithLocaleTest.php +++ b/tests/Integration/Mail/RenderingMailWithLocaleTest.php @@ -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() @@ -47,7 +47,7 @@ public function testMailableRendersInAppSelectedLocale() $mail = new RenderedTestMail; - $this->assertEquals('nombre'.PHP_EOL, $mail->render()); + $this->assertStringContainsString("nombre\n", $mail->render()); } } diff --git a/tests/View/ViewBladeCompilerTest.php b/tests/View/ViewBladeCompilerTest.php index 1894daf3c898..495b936433c6 100644 --- a/tests/View/ViewBladeCompilerTest.php +++ b/tests/View/ViewBladeCompilerTest.php @@ -49,7 +49,7 @@ 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', "\nHello World"); $compiler->compile('foo'); } @@ -57,7 +57,7 @@ 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', "\nHello World"); $compiler->compile('foo'); $this->assertEquals('foo', $compiler->getPath()); } @@ -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', "\nHello World"); // set path before compilation $compiler->setPath('foo'); // trigger compilation with null $path @@ -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', "\nHello World"); + $compiler->compile('foo'); + } + protected function getFiles() { return m::mock(Filesystem::class);