BladeInjectTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeInjectTest extends AbstractBladeTestCase
  4. {
  5. public function testDependenciesInjectedAsStringsAreCompiled()
  6. {
  7. $string = "Foo @inject('baz', 'SomeNamespace\SomeClass') bar";
  8. $expected = "Foo <?php \$baz = app('SomeNamespace\SomeClass'); ?> bar";
  9. $this->assertEquals($expected, $this->compiler->compileString($string));
  10. }
  11. public function testDependenciesInjectedAsStringsAreCompiledWhenInjectedWithDoubleQuotes()
  12. {
  13. $string = 'Foo @inject("baz", "SomeNamespace\SomeClass") bar';
  14. $expected = 'Foo <?php $baz = app("SomeNamespace\SomeClass"); ?> bar';
  15. $this->assertEquals($expected, $this->compiler->compileString($string));
  16. }
  17. public function testDependenciesAreCompiled()
  18. {
  19. $string = "Foo @inject('baz', SomeNamespace\SomeClass::class) bar";
  20. $expected = "Foo <?php \$baz = app(SomeNamespace\SomeClass::class); ?> bar";
  21. $this->assertEquals($expected, $this->compiler->compileString($string));
  22. }
  23. public function testDependenciesAreCompiledWithDoubleQuotes()
  24. {
  25. $string = 'Foo @inject("baz", SomeNamespace\SomeClass::class) bar';
  26. $expected = "Foo <?php \$baz = app(SomeNamespace\SomeClass::class); ?> bar";
  27. $this->assertEquals($expected, $this->compiler->compileString($string));
  28. }
  29. }