generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from hotwired-laravel/partials-path-pattern
Allow configuring partials path pattern
- Loading branch information
Showing
5 changed files
with
113 additions
and
3 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
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,40 @@ | ||
<?php | ||
|
||
namespace HotwiredLaravel\TurboLaravel\Tests\Models; | ||
|
||
use HotwiredLaravel\TurboLaravel\Facades\Turbo; | ||
use HotwiredLaravel\TurboLaravel\NamesResolver; | ||
use HotwiredLaravel\TurboLaravel\Tests\TestCase; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Workbench\Database\Factories\ArticleFactory; | ||
|
||
class NamesResolverTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function resolves_partial_naming() | ||
{ | ||
$article = ArticleFactory::new()->make(); | ||
|
||
$this->assertEquals('articles._article', NamesResolver::partialNameFor($article)); | ||
} | ||
|
||
/** @test */ | ||
public function resolves_partial_naming_using_subfolder() | ||
{ | ||
$article = ArticleFactory::new()->make(); | ||
|
||
Turbo::usePartialsSubfolderPattern(); | ||
|
||
$this->assertEquals('articles.partials.article', NamesResolver::partialNameFor($article)); | ||
} | ||
|
||
/** @test */ | ||
public function resolves_using_custom_closure() | ||
{ | ||
$article = ArticleFactory::new()->make(); | ||
|
||
Turbo::resolvePartialsPathUsing(fn (Model $model) => 'partials.article'); | ||
|
||
$this->assertEquals('partials.article', NamesResolver::partialNameFor($article)); | ||
} | ||
} |
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