-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration tests and custom prefixes
- Loading branch information
1 parent
5a1eb8b
commit 1ff0379
Showing
8 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\View; | ||
|
||
use Illuminate\Support\Facades\Blade; | ||
use Illuminate\Support\Facades\View; | ||
use InvalidArgumentException; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class BladeAnonymousComponentTest extends TestCase | ||
{ | ||
public function test_anonymous_components_with_custom_paths_can_be_rendered() | ||
{ | ||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-1', 'layouts'); | ||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-2'); | ||
|
||
$view = View::make('page')->render(); | ||
|
||
$this->assertTrue(str_contains($view, 'Panel content.')); | ||
$this->assertTrue(str_contains($view, 'class="app-layout"')); | ||
$this->assertTrue(str_contains($view, 'class="danger-button"')); | ||
} | ||
|
||
public function test_anonymous_components_with_custom_paths_cant_be_rendered_as_normal_views() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
|
||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-1', 'layouts'); | ||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-2'); | ||
|
||
$view = View::make('layouts::app')->render(); | ||
} | ||
|
||
public function test_anonymous_components_with_custom_paths_cant_be_rendered_as_normal_views_even_with_no_prefix() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
|
||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-1', 'layouts'); | ||
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-2'); | ||
|
||
$view = View::make('panel')->render(); | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
$app['config']->set('view.paths', [__DIR__.'/anonymous-components-templates']); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="app-layout"> | ||
{{ $slot }} | ||
</div> |
3 changes: 3 additions & 0 deletions
3
tests/Integration/View/anonymous-components-2/buttons/danger.blade.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="danger-button"> | ||
Danger button. | ||
</div> |
3 changes: 3 additions & 0 deletions
3
tests/Integration/View/anonymous-components-2/panel.blade.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="panel"> | ||
{{ $slot }} | ||
</div> |
7 changes: 7 additions & 0 deletions
7
tests/Integration/View/anonymous-components-templates/page.blade.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<x-layouts::app> | ||
<x-panel> | ||
Panel content. | ||
|
||
<x-buttons.danger /> | ||
</x-panel> | ||
</x-layouts::app> |
This file contains 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