Passed
Push — master ( 81f038...118fbb )
by Fu
03:51
created

ExampleTest::testShow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Modules\Example\Tests;
4
5
use Illuminate\Support\Str;
6
use Modules\Core\Enums\StatusCodeEnum;
7
use Modules\Example\Database\Seeders\ExampleTableSeederTableSeeder;
8
use Tests\TestCase;
0 ignored issues
show
Bug introduced by
The type Tests\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Illuminate\Foundation\Testing\RefreshDatabase;
10
11
class ExampleTest extends TestCase
12
{
13
    use RefreshDatabase;
14
15
    private $baseUri = 'api/v1/';
16
    private $resource = 'examples';
17
    private $uri;
18
19
    public function __construct()
20
    {
21
        $this->uri = $this->baseUri.Str::plural($this->resource);
22
23
        parent::__construct();
24
    }
25
26
    public function testIndex()
27
    {
28
        $this->get("{$this->uri}")->assertStatus(StatusCodeEnum::HTTP_OK);
29
    }
30
31
    public function testStore()
32
    {
33
        $this->post("{$this->uri}", ['name' => 'demo', 'value' => 'hello world'])
34
             ->assertStatus(StatusCodeEnum::HTTP_CREATED);
35
    }
36
37
    public function testShow()
38
    {
39
        $this->seed(ExampleTableSeederTableSeeder::class);
40
41
        $this->get("{$this->uri}/1")->assertStatus(StatusCodeEnum::HTTP_OK);
42
    }
43
44
    public function testUpdate()
45
    {
46
        $this->seed(ExampleTableSeederTableSeeder::class);
47
48
        $this->put("{$this->uri}/1", ['value' => 'Hello World'])->assertStatus(StatusCodeEnum::HTTP_RESET_CONTENT);
49
    }
50
51
    public function testDestroy()
52
    {
53
        $this->seed(ExampleTableSeederTableSeeder::class);
54
55
        $this->delete("{$this->uri}/1")->assertStatus(StatusCodeEnum::HTTP_NO_CONTENT);
56
    }
57
}
58