Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1618a63
commit bcda46a
Showing
11 changed files
with
234 additions
and
72 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,33 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\User; | ||
|
||
class BelongsToManyTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$roles = User::first()->roles()->offset(1)->get(); | ||
|
||
$this->assertEquals([2, 1], $roles->pluck('id')->all()); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$users = User::with('roles')->get(); | ||
|
||
$this->assertEquals([3, 2], $users[0]->roles->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $users[1]->roles->pluck('id')->all()); | ||
$this->assertArrayNotHasKey('@laravel_partition := `pivot_user_id`', $users[0]->roles[0]); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$users = User::all()->load('roles'); | ||
|
||
$this->assertEquals([3, 2], $users[0]->roles->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $users[1]->roles->pluck('id')->all()); | ||
$this->assertArrayNotHasKey('@laravel_partition := `pivot_user_id`', $users[0]->roles[0]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\User; | ||
|
||
class HasManyTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$posts = User::first()->posts()->offset(1)->get(); | ||
|
||
$this->assertEquals([2, 1], $posts->pluck('id')->all()); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$users = User::with('posts')->get(); | ||
|
||
$this->assertEquals([3, 2], $users[0]->posts->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $users[1]->posts->pluck('id')->all()); | ||
$this->assertArrayNotHasKey('laravel_row', $users[0]->post); | ||
$this->assertArrayNotHasKey('@laravel_partition := `user_id`', $users[0]->post); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$users = User::all()->load('posts'); | ||
|
||
$this->assertEquals([3, 2], $users[0]->posts->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $users[1]->posts->pluck('id')->all()); | ||
$this->assertArrayNotHasKey('laravel_row', $users[0]->post); | ||
$this->assertArrayNotHasKey('@laravel_partition := `user_id`', $users[0]->post); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\Country; | ||
|
||
class HasManyThroughTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$posts = Country::first()->posts()->offset(1)->get(); | ||
|
||
$this->assertEquals([2, 1], $posts->pluck('id')->all()); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$countries = Country::with('posts')->get(); | ||
|
||
$this->assertEquals([3, 2], $countries[0]->posts->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $countries[1]->posts->pluck('id')->all()); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$countries = Country::all()->load('posts'); | ||
|
||
$this->assertEquals([3, 2], $countries[0]->posts->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $countries[1]->posts->pluck('id')->all()); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\User; | ||
|
||
class HasOneTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$post = User::first()->post()->offset(1)->first(); | ||
|
||
$this->assertEquals(2, $post->id); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$users = User::with('post')->get(); | ||
|
||
$this->assertEquals(3, $users[0]->post->id); | ||
$this->assertEquals(6, $users[1]->post->id); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$users = User::all()->load('post'); | ||
|
||
$this->assertEquals(3, $users[0]->post->id); | ||
$this->assertEquals(6, $users[1]->post->id); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\Post; | ||
|
||
class MorphManyTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$comments = Post::first()->comments()->offset(1)->get(); | ||
|
||
$this->assertEquals([2, 1], $comments->pluck('id')->all()); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$posts = Post::with('comments')->get(); | ||
|
||
$this->assertEquals([3, 2], $posts[0]->comments->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $posts[1]->comments->pluck('id')->all()); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$posts = Post::all()->load('comments'); | ||
|
||
$this->assertEquals([3, 2], $posts[0]->comments->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $posts[1]->comments->pluck('id')->all()); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\Post; | ||
|
||
class MorphOneTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$comment = Post::first()->comment()->offset(1)->first(); | ||
|
||
$this->assertEquals(2, $comment->id); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$posts = Post::with('comment')->get(); | ||
|
||
$this->assertEquals(3, $posts[0]->comment->id); | ||
$this->assertEquals(6, $posts[1]->comment->id); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$posts = Post::all()->load('comment'); | ||
|
||
$this->assertEquals(3, $posts[0]->comment->id); | ||
$this->assertEquals(6, $posts[1]->comment->id); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Tests\Models\Post; | ||
|
||
class MorphToManyTest extends TestCase | ||
{ | ||
public function testLazyLoading() | ||
{ | ||
$tags = Post::first()->tags()->offset(1)->get(); | ||
|
||
$this->assertEquals([2, 1], $tags->pluck('id')->all()); | ||
} | ||
|
||
public function testEagerLoading() | ||
{ | ||
$posts = Post::with('tags')->get(); | ||
|
||
$this->assertEquals([3, 2], $posts[0]->tags->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $posts[1]->tags->pluck('id')->all()); | ||
} | ||
|
||
public function testLazyEagerLoading() | ||
{ | ||
$posts = Post::all()->load('tags'); | ||
|
||
$this->assertEquals([3, 2], $posts[0]->tags->pluck('id')->all()); | ||
$this->assertEquals([6, 5], $posts[1]->tags->pluck('id')->all()); | ||
} | ||
} |