| @@ 18-35 (lines=18) @@ | ||
| 15 | use Illuminate\Foundation\Testing\RefreshDatabase; |
|
| 16 | use Illuminate\Support\Collection; |
|
| 17 | ||
| 18 | class DecrementTest extends IntegrationTestCase |
|
| 19 | { |
|
| 20 | public function testDecrementingInvalidatesCache() |
|
| 21 | { |
|
| 22 | $book = (new Book) |
|
| 23 | ->find(1); |
|
| 24 | $originalPrice = $book->price; |
|
| 25 | $originalDescription = $book->description; |
|
| 26 | ||
| 27 | $book->decrement("price", 1.25, ["description" => "test description update"]); |
|
| 28 | $book = (new Book) |
|
| 29 | ->find(1); |
|
| 30 | ||
| 31 | $this->assertEquals($originalPrice - 1.25, $book->price); |
|
| 32 | $this->assertNotEquals($originalDescription, $book->description); |
|
| 33 | $this->assertEquals($book->description, "test description update"); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 6-23 (lines=18) @@ | ||
| 3 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book; |
|
| 4 | use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
|
| 5 | ||
| 6 | class IncrementTest extends IntegrationTestCase |
|
| 7 | { |
|
| 8 | public function testIncrementingInvalidatesCache() |
|
| 9 | { |
|
| 10 | $book = (new Book) |
|
| 11 | ->find(1); |
|
| 12 | $originalPrice = $book->price; |
|
| 13 | $originalDescription = $book->description; |
|
| 14 | ||
| 15 | $book->increment("price", 1.25, ["description" => "test description update"]); |
|
| 16 | $book = (new Book) |
|
| 17 | ->find(1); |
|
| 18 | ||
| 19 | $this->assertEquals($originalPrice + 1.25, $book->price); |
|
| 20 | $this->assertNotEquals($originalDescription, $book->description); |
|
| 21 | $this->assertEquals($book->description, "test description update"); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||