|
1 | 1 | <?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder;
|
2 | 2 |
|
| 3 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author; |
3 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book;
|
4 | 5 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor;
|
5 | 6 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedBook;
|
@@ -32,29 +33,49 @@ public function testWhereInUsingCollectionQuery()
|
32 | 33 | $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id"));
|
33 | 34 | }
|
34 | 35 |
|
35 |
| - /** @group test */ |
36 | 36 | public function testWhereInWhenSetIsEmpty()
|
37 | 37 | {
|
38 |
| - $key = sha1('genealabs:laravel-model-caching:testing::memory::books:genealabslaravelmodelcachingtestsfixturesbook-author_id_in_1_2_3_4'); |
| 38 | + $key = sha1('genealabs:laravel-model-caching:testing::memory::authors:genealabslaravelmodelcachingtestsfixturesauthor-id_in_'); |
39 | 39 | $tags = [
|
40 |
| - 'genealabs:laravel-model-caching:testing::memory::genealabslaravelmodelcachingtestsfixturesbook', |
| 40 | + 'genealabs:laravel-model-caching:testing::memory::genealabslaravelmodelcachingtestsfixturesauthor', |
41 | 41 | ];
|
42 |
| - $authors = (new UncachedAuthor) |
43 |
| - ->where("id", "<", 0) |
44 |
| - ->get(["id"]); |
| 42 | + $authors = (new Author) |
| 43 | + ->whereIn("id", []) |
| 44 | + ->get(); |
| 45 | + $cachedResults = $this |
| 46 | + ->cache() |
| 47 | + ->tags($tags) |
| 48 | + ->get($key)['value']; |
| 49 | + $liveResults = (new UncachedAuthor) |
| 50 | + ->whereIn("id", []) |
| 51 | + ->get(); |
45 | 52 |
|
46 |
| - $books = (new Book) |
47 |
| - ->whereIn("author_id", $authors) |
| 53 | + $this->assertEquals($liveResults->pluck("id"), $authors->pluck("id")); |
| 54 | + $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id")); |
| 55 | + } |
| 56 | + |
| 57 | + public function testBindingsAreCorrectWithMultipleWhereInClauses() |
| 58 | + { |
| 59 | + $key = sha1('genealabs:laravel-model-caching:testing::memory::authors:genealabslaravelmodelcachingtestsfixturesauthor-name_in_John-id_in_-name_in_Mike'); |
| 60 | + $tags = [ |
| 61 | + 'genealabs:laravel-model-caching:testing::memory::genealabslaravelmodelcachingtestsfixturesauthor', |
| 62 | + ]; |
| 63 | + $authors = (new Author) |
| 64 | + ->whereIn("name", ["John"]) |
| 65 | + ->whereIn("id", []) |
| 66 | + ->whereIn("name", ["Mike"]) |
48 | 67 | ->get();
|
49 | 68 | $cachedResults = $this
|
50 | 69 | ->cache()
|
51 | 70 | ->tags($tags)
|
52 | 71 | ->get($key)['value'];
|
53 |
| - $liveResults = (new UncachedBook) |
54 |
| - ->whereIn("author_id", $authors) |
| 72 | + $liveResults = (new UncachedAuthor) |
| 73 | + ->whereIn("name", ["Mike"]) |
| 74 | + ->whereIn("id", []) |
| 75 | + ->whereIn("name", ["John"]) |
55 | 76 | ->get();
|
56 | 77 |
|
57 |
| - $this->assertEquals($liveResults->pluck("id"), $books->pluck("id")); |
58 |
| - $this->assertNull($cachedResults); |
| 78 | + $this->assertEquals($liveResults->pluck("id"), $authors->pluck("id")); |
| 79 | + $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id")); |
59 | 80 | }
|
60 | 81 | }
|
0 commit comments