|
| 1 | +<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration; |
| 2 | + |
| 3 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author; |
| 4 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book; |
| 5 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Profile; |
| 6 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Publisher; |
| 7 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Store; |
| 8 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor; |
| 9 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedBook; |
| 10 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedProfile; |
| 11 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedPublisher; |
| 12 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedStore; |
| 13 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Http\Resources\Author as AuthorResource; |
| 14 | +use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
| 15 | +use Illuminate\Foundation\Testing\RefreshDatabase; |
| 16 | +use Illuminate\Support\Collection; |
| 17 | + |
| 18 | +class CachedBuilderMultipleQueryTest extends IntegrationTestCase |
| 19 | +{ |
| 20 | + use RefreshDatabase; |
| 21 | + |
| 22 | + public function testCallingAllThenFirstQueriesReturnsDifferingResults() |
| 23 | + { |
| 24 | + $allAuthors = (new Author)->all(); |
| 25 | + $firstAuthor = (new Author)->first(); |
| 26 | + |
| 27 | + $this->assertNotEquals($allAuthors, $firstAuthor); |
| 28 | + $this->assertInstanceOf(Author::class, $firstAuthor); |
| 29 | + $this->assertInstanceOf(Collection::class, $allAuthors); |
| 30 | + } |
| 31 | + |
| 32 | + public function testCallingGetThenFirstQueriesReturnsDifferingResults() |
| 33 | + { |
| 34 | + $allAuthors = (new Author)->get(); |
| 35 | + $firstAuthor = (new Author)->first(); |
| 36 | + |
| 37 | + $this->assertNotEquals($allAuthors, $firstAuthor); |
| 38 | + $this->assertInstanceOf(Author::class, $firstAuthor); |
| 39 | + $this->assertInstanceOf(Collection::class, $allAuthors); |
| 40 | + } |
| 41 | +} |
0 commit comments