-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.stub
executable file
·57 lines (43 loc) · 1.45 KB
/
test.stub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace {{ namespace }};
use Tests\TestCase;
class {{ class }} extends TestCase
{
// 'PATH_MODEL_TABLE'
public function testCreate{{ class }}()
{
$data = $this->model::factory()->make();
$this->postJson($this->path, $data->toArray())
->assertCreated();
$this->assertDatabaseHas($this->table, $data->toArray());
}
public function testShow{{ class }}()
{
$data = $this->model::factory()->create();
$response = $this->getJson($this->path . '/' . $data->getRouteKey());
$response->assertOk();
$response->assertJsonFragment($data->toArray());
}
public function testUpdate{{ class }}()
{
$data = $this->model::factory()->create();
$newData = $this->model::factory()->make();
$response = $this->putJson($this->path . '/' . $data->getRouteKey(), $newData->toArray());
$response->assertNoContent();
}
public function testList{{ class }}()
{
$this->model::factory()->count(10)->create();
$response = $this->get($this->path);
$response->assertOk();
$response->assertJsonCount(10, 'data');
}
public function testDelete{{ class }}()
{
$data = $this->model::factory()->create();
$this->delete($this->path . '/' . $data->getRouteKey())
->assertNoContent();
$this->assertDatabaseCount($this->table, 1);
$this->assertSoftDeleted($data);
}
}