Skip to content

Commit 5275b8d

Browse files
committed
laravel_test_and_seeds_fix: Fixed "testSubmitSlaveMetricsSuccessfully" in MetricTest
1 parent 9606151 commit 5275b8d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

amp-laravel/tests/Feature/MetricTest.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22

33
namespace Tests\Feature;
44

5-
use Illuminate\Foundation\Testing\RefreshDatabase;
6-
use Illuminate\Foundation\Testing\WithFaker;
75
use Tests\TestCase;
6+
use App\Models\Slave;
7+
use App\Models\Master;
8+
use App\Traits\ResponseTrait;
9+
use Illuminate\Foundation\Testing\WithFaker;
810

911
class 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([

0 commit comments

Comments
 (0)