Code Duplication    Length = 24-24 lines in 2 locations

tests/Unit/CachedBuilderTest.php 1 location

@@ 21-44 (lines=24) @@
18
{
19
    use RefreshDatabase;
20
21
    public function setUp()
22
    {
23
        parent::setUp();
24
25
        cache()->flush();
26
        factory(Author::class, 10)->create()
27
            ->each(function($author) {
28
                factory(Book::class, random_int(2, 10))->make()
29
                    ->each(function ($book) use ($author) {
30
                        $book->author()->associate($author);
31
                        $book->save();
32
                    });
33
                factory(Profile::class)->make([
34
                    'author_id' => $author->id,
35
                ]);
36
            });
37
38
        $bookIds = (new Book)->all()->pluck('id');
39
        factory(Store::class, 10)->create()
40
            ->each(function ($store) use ($bookIds) {
41
                $store->books()->sync(rand($bookIds->min(), $bookIds->max()));
42
            });
43
        cache()->flush();
44
    }
45
46
    public function testCacheIsEmptyBeforeLoadingModels()
47
    {

tests/Unit/CachedModelTest.php 1 location

@@ 18-41 (lines=24) @@
15
{
16
    use RefreshDatabase;
17
18
    public function setUp()
19
    {
20
        parent::setUp();
21
22
        cache()->flush();
23
        factory(Author::class, 10)->create()
24
            ->each(function($author) {
25
                factory(Book::class, random_int(2, 10))->make()
26
                    ->each(function ($book) use ($author) {
27
                        $book->author()->associate($author);
28
                        $book->save();
29
                    });
30
                factory(Profile::class)->make([
31
                    'author_id' => $author->id,
32
                ]);
33
            });
34
35
        $bookIds = (new Book)->all()->pluck('id');
36
        factory(Store::class, 10)->create()
37
            ->each(function ($store) use ($bookIds) {
38
                $store->books()->sync(rand($bookIds->min(), $bookIds->max()));
39
            });
40
        cache()->flush();
41
    }
42
43
    public function testAllModelResultsCreatesCache()
44
    {