@@ -12,13 +12,6 @@ class AdvCampaignTest extends TestCase
12
12
{
13
13
use RefreshDatabase;
14
14
15
- protected function setUp (): void
16
- {
17
- parent ::setUp ();
18
-
19
- $ this ->generateRoles ();
20
- }
21
-
22
15
/** @test */
23
16
public function not_auth_user_cannot_create_it ()
24
17
{
@@ -41,7 +34,7 @@ public function auth_user_not_advertiser_cannot_create_campaign()
41
34
42
35
$ campaign = factory (AdvCampaign::class)->make ();
43
36
44
- $ this ->storeAssertFieldFailed ($ campaign ->toArray (), $ token , 'title ' , 401 , false );
37
+ $ this ->storeAssertFieldFailed ($ campaign ->toArray (), $ token , 'title ' , 403 , false );
45
38
46
39
auth ()->logout ();
47
40
}
@@ -89,10 +82,29 @@ public function auth_user_create_but_wrong_dates()
89
82
$ this ->storeAssertFieldFailed ($ data , $ token , 'from ' );
90
83
}
91
84
85
+ /** @test */
86
+ public function auth_user_create_not_enough_money ()
87
+ {
88
+ $ user = factory (User::class)->create (['role_id ' => 4 ]);
89
+ $ user ->account ->update (['amount ' => 50 ]);
90
+ $ token = auth ()->login ($ user );
91
+
92
+ $ data = [
93
+ 'title ' => "Updated stream " ,
94
+ 'brand ' => 'Brand ' ,
95
+ 'limit ' => 100 ,
96
+ 'from ' => Carbon::now ('UTC ' )->addMinutes (45 )->toDateTimeString (),
97
+ 'to ' => Carbon::now ('UTC ' )->addMinutes (245 )->toDateTimeString (),
98
+ ];
99
+
100
+ $ this ->storeAssertFieldFailed ($ data , $ token , 'limit ' );
101
+ }
102
+
92
103
/** @test */
93
104
public function auth_user_create_successfully ()
94
105
{
95
106
$ user = factory (User::class)->create (['role_id ' => 4 ]);
107
+ $ user ->account ->update (['amount ' => 200 ]);
96
108
$ token = auth ()->login ($ user );
97
109
98
110
$ data = [
@@ -119,7 +131,7 @@ public function auth_user_role_user_cannot_watch_list_it()
119
131
$ token = auth ()->login ($ user );
120
132
121
133
$ this ->json ('GET ' , '/api/campaigns ' , [], ['Authorization ' => "Bearer $ token " ])
122
- ->assertStatus (401 );
134
+ ->assertStatus (403 );
123
135
}
124
136
125
137
/** @test */
0 commit comments