File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
declare (strict_types=1 );
4
4
5
+ use App \Models \User ;
5
6
use Laravelcm \Gamify \Models \Reputation ;
6
7
8
+ beforeEach (function (): void {
9
+ $ this ->user = createUser (['reputation ' => 0 ]);
10
+ });
11
+
7
12
describe (Reputation::class, function (): void {
8
13
9
14
it ('gets user points ' , function (): void {
13
18
});
14
19
15
20
it ('gives reputation point to a user ' , function (): void {
16
- expect ($ user ->getPoints ())->toBe (0 );
21
+ expect ($ this -> user ->getPoints ())->toBe (0 );
17
22
18
23
$ user ->addPoint (10 );
19
24
20
- expect ($ user ->fresh ()->getPoints ())->toBe (10 );
25
+ expect ($ this -> user ->fresh ()->getPoints ())->toBe (10 );
21
26
});
22
27
23
28
it ('reduces reputation point for a user ' , function (): void {
38
43
expect ($ user ->fresh ()->getPoints ())->toBe (0 );
39
44
});
40
45
46
+ function createUser (array $ attributes = []): User
47
+ {
48
+ $ user = new User ;
49
+
50
+ $ user ->forceFill (array_merge ($ attributes , [
51
+ 'name ' => 'Demo ' ,
52
+
53
+ 'password ' => 'password ' ,
54
+ ]))->save ();
55
+
56
+ return $ user ->fresh ();
57
+ }
58
+
41
59
});
Original file line number Diff line number Diff line change 6
6
use Illuminate \Foundation \Testing \RefreshDatabase ;
7
7
use Tests \TestCase ;
8
8
9
- uses (TestCase::class, RefreshDatabase::class) > in ('Feature ' );
9
+ uses (TestCase::class, RefreshDatabase::class)-> in ('Feature ' );
10
10
11
11
function createUser (array $ attributes = []): User
12
12
{
You can’t perform that action at this time.
0 commit comments