@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("
##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes(['type' => 'foo','limit' => '5','@click' => 'foo','wire:click' => 'changePlan(\''.e(\$plan).'\')','required' => true]); ?>\n".
-"@endcomponentClass @component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+"@endComponentClass##END-COMPONENT-CLASS####BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes([]); ?>\n".
-'@endcomponentClass
', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##
', trim($result));
}
public function testBasicComponentWithEmptyAttributesParsing()
{
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags(' @component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("
##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes(['type' => '','limit' => '','@click' => '','required' => true]); ?>\n".
-'@endcomponentClass
', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##
', trim($result));
}
public function testDataCamelCasing()
{
$result = $this->compiler(['profile' => TestProfileComponent::class])->compileTags('');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'foo:alert', [])
-withAttributes([]); ?> @endcomponentClass", trim($result));
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'foo:alert', [])
+withAttributes([]); ?> @endComponentClass##END-COMPONENT-CLASS##", trim($result));
}
public function testSelfClosingComponentsCanBeCompiled()
{
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('
');
- $this->assertSame(" @component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("
##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes([]); ?>\n".
-'@endcomponentClass
', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##
', trim($result));
}
public function testClassNamesCanBeGuessed()
@@ -139,18 +147,18 @@ public function testComponentsCanBeCompiledWithHyphenAttributes()
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes(['class' => 'bar','wire:model' => 'foo','x-on:click' => 'bar','@click' => 'baz']); ?>\n".
-'@endcomponentClass', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##', trim($result));
}
public function testSelfClosingComponentsCanBeCompiledWithDataAndAttributes()
{
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => 'foo'])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => 'foo'])
withAttributes(['class' => 'bar','wire:model' => 'foo']); ?>\n".
-'@endcomponentClass', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##', trim($result));
}
public function testComponentCanReceiveAttributeBag()
@@ -158,8 +166,8 @@ public function testComponentCanReceiveAttributeBag()
$this->mockViewFactory();
$result = $this->compiler(['profile' => TestProfileComponent::class])->compileTags('');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestProfileComponent', 'profile', [])
-withAttributes(['class' => 'bar','attributes' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(\$attributes),'wire:model' => 'foo']); ?> @endcomponentClass", trim($result));
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestProfileComponent', 'profile', [])
+withAttributes(['class' => 'bar','attributes' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(\$attributes),'wire:model' => 'foo']); ?> @endComponentClass##END-COMPONENT-CLASS##", trim($result));
}
public function testSelfClosingComponentCanReceiveAttributeBag()
@@ -168,35 +176,35 @@ public function testSelfClosingComponentCanReceiveAttributeBag()
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('merge([\'class\' => \'test\']) }} wire:model="foo" />
');
- $this->assertSame(" @component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => 'foo'])
+ $this->assertSame("
##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => 'foo'])
withAttributes(['class' => 'bar','attributes' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(\$attributes->merge(['class' => 'test'])),'wire:model' => 'foo']); ?>\n".
- '@endcomponentClass
', trim($result));
+ '@endComponentClass##END-COMPONENT-CLASS##
', trim($result));
}
public function testComponentsCanHaveAttachedWord()
{
$result = $this->compiler(['profile' => TestProfileComponent::class])->compileTags('Words');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestProfileComponent', 'profile', [])
-withAttributes([]); ?> @endcomponentClass Words", trim($result));
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestProfileComponent', 'profile', [])
+withAttributes([]); ?> @endComponentClass##END-COMPONENT-CLASS##Words", trim($result));
}
public function testSelfClosingComponentsCanHaveAttachedWord()
{
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('Words');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes([]); ?>\n".
-'@endcomponentClass Words', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##Words', trim($result));
}
public function testSelfClosingComponentsCanBeCompiledWithBoundData()
{
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => \$title])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', ['title' => \$title])
withAttributes(['class' => 'bar']); ?>\n".
-'@endcomponentClass', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##', trim($result));
}
public function testPairedComponentTags()
@@ -204,9 +212,9 @@ public function testPairedComponentTags()
$result = $this->compiler(['alert' => TestAlertComponent::class])->compileTags('
');
- $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestAlertComponent', 'alert', [])
withAttributes([]); ?>
- @endcomponentClass", trim($result));
+ @endComponentClass##END-COMPONENT-CLASS##", trim($result));
}
public function testClasslessComponents()
@@ -220,9 +228,9 @@ public function testClasslessComponents()
$result = $this->compiler()->compileTags('');
- $this->assertSame("@component('Illuminate\View\AnonymousComponent', 'anonymous-component', ['view' => 'components.anonymous-component','data' => ['name' => 'Taylor','age' => 31,'wire:model' => 'foo']])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\View\AnonymousComponent', 'anonymous-component', ['view' => 'components.anonymous-component','data' => ['name' => 'Taylor','age' => 31,'wire:model' => 'foo']])
withAttributes(['name' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute('Taylor'),'age' => 31,'wire:model' => 'foo']); ?>\n".
-'@endcomponentClass', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##', trim($result));
}
public function testPackagesClasslessComponents()
@@ -236,9 +244,9 @@ public function testPackagesClasslessComponents()
$result = $this->compiler()->compileTags('');
- $this->assertSame("@component('Illuminate\View\AnonymousComponent', 'package::anonymous-component', ['view' => 'package::components.anonymous-component','data' => ['name' => 'Taylor','age' => 31,'wire:model' => 'foo']])
+ $this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\View\AnonymousComponent', 'package::anonymous-component', ['view' => 'package::components.anonymous-component','data' => ['name' => 'Taylor','age' => 31,'wire:model' => 'foo']])
withAttributes(['name' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute('Taylor'),'age' => 31,'wire:model' => 'foo']); ?>\n".
-'@endcomponentClass', trim($result));
+'@endComponentClass##END-COMPONENT-CLASS##', trim($result));
}
public function testAttributeSanitization()
diff --git a/tests/View/Blade/BladeInjectTest.php b/tests/View/Blade/BladeInjectTest.php
new file mode 100644
index 000000000000..07ffd19f0e3f
--- /dev/null
+++ b/tests/View/Blade/BladeInjectTest.php
@@ -0,0 +1,34 @@
+ bar";
+ $this->assertEquals($expected, $this->compiler->compileString($string));
+ }
+
+ public function testDependenciesInjectedAsStringsAreCompiledWhenInjectedWithDoubleQuotes()
+ {
+ $string = 'Foo @inject("baz", "SomeNamespace\SomeClass") bar';
+ $expected = 'Foo bar';
+ $this->assertEquals($expected, $this->compiler->compileString($string));
+ }
+
+ public function testDependenciesAreCompiled()
+ {
+ $string = "Foo @inject('baz', SomeNamespace\SomeClass::class) bar";
+ $expected = "Foo bar";
+ $this->assertEquals($expected, $this->compiler->compileString($string));
+ }
+
+ public function testDependenciesAreCompiledWithDoubleQuotes()
+ {
+ $string = 'Foo @inject("baz", SomeNamespace\SomeClass::class) bar';
+ $expected = "Foo bar";
+ $this->assertEquals($expected, $this->compiler->compileString($string));
+ }
+}
diff --git a/tests/View/ComponentTest.php b/tests/View/ComponentTest.php
index 124d954d454e..8049c7aa5bc5 100644
--- a/tests/View/ComponentTest.php
+++ b/tests/View/ComponentTest.php
@@ -19,7 +19,7 @@ class ComponentTest extends TestCase
protected $viewFactory;
protected $config;
- public function setUp(): void
+ protected function setUp(): void
{
$this->config = m::mock(Config::class);
diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php
index c91e74589e24..4fab0a42d37e 100644
--- a/tests/View/ViewComponentAttributeBagTest.php
+++ b/tests/View/ViewComponentAttributeBagTest.php
@@ -27,6 +27,9 @@ public function testAttributeRetrieval()
$this->assertSame('font-bold', $bag->get('class'));
$this->assertSame('bar', $bag->get('foo', 'bar'));
$this->assertSame('font-bold', $bag['class']);
+ $this->assertSame('class="mt-4 font-bold" name="test"', (string) $bag->class('mt-4'));
+ $this->assertSame('class="mt-4 font-bold" name="test"', (string) $bag->class(['mt-4']));
+ $this->assertSame('class="mt-4 ml-2 font-bold" name="test"', (string) $bag->class(['mt-4', 'ml-2' => true, 'mr-2' => false]));
$bag = new ComponentAttributeBag([]);
diff --git a/tests/View/ViewFactoryTest.php b/tests/View/ViewFactoryTest.php
index 52061422074e..ab003c3b9f9d 100755
--- a/tests/View/ViewFactoryTest.php
+++ b/tests/View/ViewFactoryTest.php
@@ -7,6 +7,7 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Contracts\View\Engine;
+use Illuminate\Contracts\View\View as ViewContract;
use Illuminate\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\HtmlString;
@@ -87,6 +88,7 @@ public function testFirstCreatesNewViewInstanceWithProperPath()
$factory->addExtension('php', 'php');
$view = $factory->first(['bar', 'view'], ['foo' => 'bar'], ['baz' => 'boom']);
+ $this->assertInstanceOf(ViewContract::class, $view);
$this->assertSame($engine, $view->getEngine());
$this->assertSame($_SERVER['__test.view'], $view);
diff --git a/tests/View/fixtures/nested/basic.php b/tests/View/fixtures/nested/basic.php
index 557db03de997..e69de29bb2d1 100755
--- a/tests/View/fixtures/nested/basic.php
+++ b/tests/View/fixtures/nested/basic.php
@@ -1 +0,0 @@
-Hello World