File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
amp-laravel/tests/Feature Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 22
33namespace Tests \Feature ;
44
5- use Illuminate \Foundation \Testing \RefreshDatabase ;
6- use Illuminate \Foundation \Testing \WithFaker ;
75use Tests \TestCase ;
6+ use App \Models \Slave ;
7+ use App \Models \Master ;
8+ use App \Traits \ResponseTrait ;
9+ use Illuminate \Foundation \Testing \WithFaker ;
810
911class MetricTest extends TestCase
1012{
11- use WithFaker;
13+ use WithFaker, ResponseTrait ;
1214
1315 public function testSubmitSlaveMetricsSuccessfully (): void
1416 {
17+ [$ request , $ client ] = $ this ->actingAsClient ();
18+
19+ $ master = Master::factory ()->create ([
20+ 'user_id ' => $ client ->id ,
21+ ]);
22+
23+ $ slave = Slave::factory ()->create ([
24+ 'master_id ' => $ master ->id ,
25+ ]);
26+
1527 $ payload = [
1628 'power ' => "10 " ,
1729 'energy ' => "30 " ,
1830 'voltage ' => "220 " ,
1931 'current ' => "20 " ,
20- 'master_id ' => 1 ,
32+ 'master_id ' => $ master -> id ,
2133 'date_month ' => "05-16 " ,
22- 'slave_id ' => 1
34+ 'slave_id ' => $ slave -> id
2335 ];
2436
25- $ response = $ this ->postJson ('http://localhost:8000/api/v1/metrics ' , $ payload );
37+ $ response = $ request ->postJson ('http://localhost:8000/api/v1/metrics ' , $ payload );
2638
2739 $ response ->assertStatus (200 )
2840 ->assertJson ([
You can’t perform that action at this time.
0 commit comments