Code Duplication    Length = 21-24 lines in 2 locations

tests/Integration/CachedBuilder/UpdateExistingPivotTest.php 1 location

@@ 6-29 (lines=24) @@
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book;
4
use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase;
5
6
class UpdateExistingPivotTest extends IntegrationTestCase
7
{
8
    public function testInRandomOrderCachesResults()
9
    {
10
        $book = (new Book)
11
            ->with("stores")
12
            ->whereHas("stores")
13
            ->first();
14
        $book->stores()
15
            ->updateExistingPivot(
16
                $book->stores->first()->id,
17
                ["test" => "value"]
18
            );
19
        $updatedCount = (new Book)
20
            ->with("stores")
21
            ->whereHas("stores")
22
            ->first()
23
            ->stores()
24
            ->wherePivot("test", "value")
25
            ->count();
26
27
        $this->assertEquals(1, $updatedCount);
28
    }
29
}
30

tests/Integration/CachedBuilder/UpdateRelationTest.php 1 location

@@ 6-26 (lines=21) @@
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book;
4
use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase;
5
6
class UpdateRelationTest extends IntegrationTestCase
7
{
8
    public function testInRandomOrderCachesResults()
9
    {
10
        $book = (new Book)
11
            ->with("stores")
12
            ->whereHas("stores")
13
            ->first();
14
        $book->stores()
15
            ->update(["name" => "test store name change"]);
16
        $updatedCount = (new Book)
17
            ->with("stores")
18
            ->whereHas("stores")
19
            ->first()
20
            ->stores()
21
            ->where("name", "test store name change")
22
            ->count();
23
24
        $this->assertEquals(1, $updatedCount);
25
    }
26
}
27