| @@ 36-56 (lines=21) @@ | ||
| 33 | $this->assertEquals($uncachedAuthor->id, $authors->id); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testWithQuery() |
|
| 37 | { |
|
| 38 | $author = (new Author) |
|
| 39 | ->where("id", 1) |
|
| 40 | ->with([ |
|
| 41 | 'books' => function ($query) { |
|
| 42 | $query->where("id", "<", 100); |
|
| 43 | } |
|
| 44 | ]) |
|
| 45 | ->first(); |
|
| 46 | $uncachedAuthor = (new UncachedAuthor)->with([ |
|
| 47 | 'books' => function ($query) { |
|
| 48 | $query->where("id", "<", 100); |
|
| 49 | }, |
|
| 50 | ]) |
|
| 51 | ->where("id", 1) |
|
| 52 | ->first(); |
|
| 53 | ||
| 54 | $this->assertEquals($uncachedAuthor->books()->count(), $author->books()->count()); |
|
| 55 | $this->assertEquals($uncachedAuthor->id, $author->id); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testMultiLevelWithQuery() |
|
| 59 | { |
|
| @@ 58-78 (lines=21) @@ | ||
| 55 | $this->assertEquals($uncachedAuthor->id, $author->id); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testMultiLevelWithQuery() |
|
| 59 | { |
|
| 60 | $author = (new Author) |
|
| 61 | ->where("id", 1) |
|
| 62 | ->with([ |
|
| 63 | 'books.publisher' => function ($query) { |
|
| 64 | $query->where("id", "<", 100); |
|
| 65 | } |
|
| 66 | ]) |
|
| 67 | ->first(); |
|
| 68 | $uncachedAuthor = (new UncachedAuthor)->with([ |
|
| 69 | 'books.publisher' => function ($query) { |
|
| 70 | $query->where("id", "<", 100); |
|
| 71 | }, |
|
| 72 | ]) |
|
| 73 | ->where("id", 1) |
|
| 74 | ->first(); |
|
| 75 | ||
| 76 | $this->assertEquals($uncachedAuthor->books()->count(), $author->books()->count()); |
|
| 77 | $this->assertEquals($uncachedAuthor->id, $author->id); |
|
| 78 | } |
|
| 79 | ||
| 80 | public function testWithBelongsToManyRelationshipQuery() |
|
| 81 | { |
|