UserTrait::truncateUsersTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace DummyNamespace\Tests\Traits;
4
5
trait UserTrait
6
{
7
    public $user;
8
9
    public function getAUser()
10
    {
11
        return $this->user = \DB::table('users')->first();
12
    }
13
14
    public function seedUsers()
15
    {
16
        $now = \Carbon\Carbon::now();
17
        \DB::table('users')->insert([
18
            'name'       => 'PHPUnit',
19
            'email'      => '[email protected]',
20
            'password'   => \Hash::make('456'),
21
            'created_at' => $now,
22
            'updated_at' => $now,
23
        ]);
24
25
        \DB::table('users')->insert([
26
            'name'       => 'PHPUnit',
27
            'email'      => '[email protected]',
28
            'password'   => \Hash::make('456'),
29
            'created_at' => $now,
30
            'updated_at' => $now,
31
        ]);
32
    }
33
34
    public function truncateUsersTable()
35
    {
36
        \DB::table('users')->truncate();
37
    }
38
39
    public function reseedUsers()
40
    {
41
        $this->truncateUsersTable();
42
        $this->seedUsers();
43
        $this->getAUser();
44
    }
45
46
    /** @test */
47
    public function it_has_users()
48
    {
49
        $this->truncateUsersTable();
50
        $this->seedUsers();
51
52
        $user = \DB::table('users')->where('id', '=', 2)->first();
53
        $this->assertEquals('[email protected]', $user->email);
0 ignored issues
show
Bug introduced by
It seems like assertEquals() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        $this->/** @scrutinizer ignore-call */ 
54
               assertEquals('[email protected]', $user->email);
Loading history...
54
        $this->assertTrue(\Hash::check('456', $user->password));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        $this->/** @scrutinizer ignore-call */ 
55
               assertTrue(\Hash::check('456', $user->password));
Loading history...
55
56
        $user = \DB::table('users')->where('id', '=', 1)->first();
57
        $this->assertEquals('[email protected]', $user->email);
58
        $this->assertTrue(\Hash::check('456', $user->password));
59
    }
60
}
61