Created
April 17, 2025 21:38
-
-
Save osbre/7f7074e499b3c429e98246d8dfa688fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Illuminate\Tests\View\Blade; | |
class BladeUseTest extends AbstractBladeTestCase | |
{ | |
public function testUseStatementsAreCompiled() | |
{ | |
$expected = "Foo <?php use \SomeNamespace\SomeClass as Foo; ?> bar"; | |
$string = "Foo @use('SomeNamespace\SomeClass', 'Foo') bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
$string = "Foo @use(SomeNamespace\SomeClass, Foo) bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
} | |
public function testUseStatementsWithoutAsAreCompiled() | |
{ | |
$expected = "Foo <?php use \SomeNamespace\SomeClass; ?> bar"; | |
$string = "Foo @use('SomeNamespace\SomeClass') bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
$string = "Foo @use(SomeNamespace\SomeClass) bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
} | |
public function testUseStatementsWithBackslashAtBeginningAreCompiled() | |
{ | |
$expected = "Foo <?php use \SomeNamespace\SomeClass; ?> bar"; | |
$string = "Foo @use('\SomeNamespace\SomeClass') bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
$string = "Foo @use(\SomeNamespace\SomeClass) bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
} | |
public function testUseStatementsWithBackslashAtBeginningAndAliasedAreCompiled() | |
{ | |
$expected = "Foo <?php use \SomeNamespace\SomeClass as Foo; ?> bar"; | |
$string = "Foo @use('\SomeNamespace\SomeClass', 'Foo') bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
$string = "Foo @use(\SomeNamespace\SomeClass, Foo) bar"; | |
$this->assertEquals($expected, $this->compiler->compileString($string)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment