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 22
33declare (strict_types=1 );
44
5+ use App \Models \User ;
56use Laravelcm \Gamify \Models \Reputation ;
67
8+ beforeEach (function (): void {
9+ $ this ->user = createUser (['reputation ' => 0 ]);
10+ });
11+
712describe (Reputation::class, function (): void {
813
914 it ('gets user points ' , function (): void {
1318 });
1419
1520 it ('gives reputation point to a user ' , function (): void {
16- expect ($ user ->getPoints ())->toBe (0 );
21+ expect ($ this -> user ->getPoints ())->toBe (0 );
1722
1823 $ user ->addPoint (10 );
1924
20- expect ($ user ->fresh ()->getPoints ())->toBe (10 );
25+ expect ($ this -> user ->fresh ()->getPoints ())->toBe (10 );
2126 });
2227
2328 it ('reduces reputation point for a user ' , function (): void {
3843 expect ($ user ->fresh ()->getPoints ())->toBe (0 );
3944 });
4045
46+ function createUser (array $ attributes = []): User
47+ {
48+ $ user = new User ;
49+
50+ $ user ->forceFill (array_merge ($ attributes , [
51+ 'name ' => 'Demo ' ,
52+ 'email ' => 'demo@laravelcm.com ' ,
53+ 'password ' => 'password ' ,
54+ ]))->save ();
55+
56+ return $ user ->fresh ();
57+ }
58+
4159});
Original file line number Diff line number Diff line change 66use Illuminate \Foundation \Testing \RefreshDatabase ;
77use Tests \TestCase ;
88
9- uses (TestCase::class, RefreshDatabase::class) > in ('Feature ' );
9+ uses (TestCase::class, RefreshDatabase::class)-> in ('Feature ' );
1010
1111function createUser (array $ attributes = []): User
1212{
You can’t perform that action at this time.
0 commit comments