-
-
Notifications
You must be signed in to change notification settings - Fork 461
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 #607 from cviebrock/issue605
test runners, and #604 fix
- Loading branch information
Showing
6 changed files
with
68 additions
and
9 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
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,14 @@ | ||
<?php namespace Cviebrock\EloquentSluggable\Tests\Models; | ||
|
||
|
||
/** | ||
* Class PostWithEagerRelations | ||
* | ||
* @package Cviebrock\EloquentSluggable\Tests\Models | ||
*/ | ||
class PostWithEagerRelation extends PostWithRelation | ||
{ | ||
|
||
protected $with = ['author']; | ||
|
||
} |
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,41 @@ | ||
<?php namespace Cviebrock\EloquentSluggable\Tests; | ||
|
||
use Cviebrock\EloquentSluggable\Tests\Models\Author; | ||
use Cviebrock\EloquentSluggable\Tests\Models\PostWithEagerRelation; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Class RelationTests | ||
* | ||
* @package Tests | ||
*/ | ||
class RelationTests extends TestCase | ||
{ | ||
|
||
/** | ||
* Test basic slugging functionality. | ||
*/ | ||
public function testEagerLoading(): void | ||
{ | ||
Model::shouldBeStrict(true); | ||
|
||
$author = Author::create([ | ||
'name' => 'Arthur Conan Doyle' | ||
]); | ||
$post = new PostWithEagerRelation([ | ||
'title' => 'My First Post' | ||
]); | ||
$post->author()->associate($author); | ||
$post->save(); | ||
|
||
self::assertEquals('arthur-conan-doyle-my-first-post', $post->slug); | ||
|
||
$post2 = new PostWithEagerRelation([ | ||
'title' => 'My second post', | ||
]); | ||
$post2->author()->associate($author); | ||
$post2->save(); | ||
self::assertEquals('arthur-conan-doyle-my-second-post', $post2->slug); | ||
} | ||
|
||
} |