Code Duplication    Length = 20-22 lines in 2 locations

tests/Integration/CachedBuilder/ScopeTest.php 1 location

@@ 39-60 (lines=22) @@
36
        $this->assertTrue($liveResults->contains($author));
37
    }
38
39
    public function testScopeClauseWithParameter()
40
    {
41
        $author = factory(Author::class, 1)
42
            ->create(['name' => 'Boris'])
43
            ->first();
44
        $authors = (new Author)
45
            ->nameStartsWith("B")
46
            ->get();
47
        $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-name_like_B%-authors.deleted_at_null");
48
        $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor"];
49
50
        $cachedResults = $this->cache()
51
            ->tags($tags)
52
            ->get($key)['value'];
53
        $liveResults = (new UncachedAuthor)
54
            ->nameStartsWith("B")
55
            ->get();
56
57
        $this->assertTrue($authors->contains($author));
58
        $this->assertTrue($cachedResults->contains($author));
59
        $this->assertTrue($liveResults->contains($author));
60
    }
61
62
    public function testGlobalScopesAreCached()
63
    {

tests/Integration/Traits/CachePrefixingTest.php 1 location

@@ 31-50 (lines=20) @@
28
        $this->assertNotEmpty($liveResults);
29
    }
30
31
    public function testDatabaseKeyingDisabled()
32
    {
33
        config(["laravel-model-caching.use-database-keying" => false]);
34
        $key = sha1("genealabs:laravel-model-caching:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-first");
35
        $tags = ["genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesauthor"];
36
37
        $author = (new Author)
38
            ->first();
39
        $cachedResults = $this->cache()
40
            ->tags($tags)
41
            ->get($key)['value'];
42
        $liveResults = (new UncachedAuthor)
43
            ->first();
44
45
        $this->assertEquals($liveResults->pluck("id"), $author->pluck("id"));
46
        $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id"));
47
        $this->assertNotEmpty($author);
48
        $this->assertNotEmpty($cachedResults);
49
        $this->assertNotEmpty($liveResults);
50
    }
51
}
52