1 | <?php |
||||||||
2 | |||||||||
3 | namespace Shamaseen\Repository\Tests\Feature; |
||||||||
4 | |||||||||
5 | use App\Http\Controllers\Tests\TestController; |
||||||||
0 ignored issues
–
show
|
|||||||||
6 | use App\Models\Tests\Test; |
||||||||
0 ignored issues
–
show
The type
App\Models\Tests\Test 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
7 | use Illuminate\Support\Facades\Route; |
||||||||
8 | use Shamaseen\Repository\Tests\TestCase; |
||||||||
9 | use Symfony\Component\HttpFoundation\Response; |
||||||||
10 | |||||||||
11 | class CrudTest extends TestCase |
||||||||
12 | { |
||||||||
13 | /** |
||||||||
14 | * @param string $dataName |
||||||||
15 | */ |
||||||||
16 | public function __construct(?string $name = null, array $data = [], $dataName = '') |
||||||||
17 | { |
||||||||
18 | parent::__construct($name, $data, $dataName); |
||||||||
0 ignored issues
–
show
The call to
PHPUnit\Framework\TestCase::__construct() has too many arguments starting with $data .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() It seems like
$name can also be of type null ; however, parameter $name of PHPUnit\Framework\TestCase::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
19 | } |
||||||||
20 | |||||||||
21 | public function setUp(): void |
||||||||
22 | { |
||||||||
23 | parent::setUp(); |
||||||||
24 | $this->artisan("generate:repository $this->userPath/$this->modelName -f"); |
||||||||
25 | $this->createDatabase(); |
||||||||
26 | } |
||||||||
27 | |||||||||
28 | public function tearDown(): void |
||||||||
29 | { |
||||||||
30 | $this->dropDatabase(); |
||||||||
31 | parent::tearDown(); |
||||||||
32 | } |
||||||||
33 | |||||||||
34 | public function testIndex() |
||||||||
35 | { |
||||||||
36 | Route::get('tests', [TestController::class, 'index']); |
||||||||
37 | |||||||||
38 | $response = $this->getJson('tests'); |
||||||||
39 | |||||||||
40 | $this->assertContains($response->getStatusCode(), [ |
||||||||
41 | Response::HTTP_OK, Response::HTTP_PARTIAL_CONTENT, |
||||||||
42 | ]); |
||||||||
43 | } |
||||||||
44 | |||||||||
45 | public function testCreate() |
||||||||
46 | { |
||||||||
47 | Route::get('tests/create', [TestController::class, 'create']); |
||||||||
48 | |||||||||
49 | $response = $this->getJson('tests/create'); |
||||||||
50 | $this->assertContains($response->getStatusCode(), [ |
||||||||
51 | Response::HTTP_NO_CONTENT, |
||||||||
52 | ]); |
||||||||
53 | } |
||||||||
54 | |||||||||
55 | public function testShow() |
||||||||
56 | { |
||||||||
57 | $test = Test::create([ |
||||||||
58 | 'name' => 'test name', |
||||||||
59 | 'type' => 'a test' |
||||||||
60 | ]); |
||||||||
61 | |||||||||
62 | Route::get('tests/{id}', [TestController::class, 'show']); |
||||||||
63 | |||||||||
64 | $response = $this->getJson('tests/'.$test->id); |
||||||||
65 | |||||||||
66 | $this->assertContains($response->getStatusCode(), [ |
||||||||
67 | Response::HTTP_OK, |
||||||||
68 | ]); |
||||||||
69 | } |
||||||||
70 | |||||||||
71 | public function testStore() |
||||||||
72 | { |
||||||||
73 | Route::post('tests', [TestController::class, 'store']); |
||||||||
74 | |||||||||
75 | $data = [ |
||||||||
76 | 'name' => 'Create Test', |
||||||||
77 | 'type' => 'New', |
||||||||
78 | ]; |
||||||||
79 | |||||||||
80 | $response = $this->postJson('tests', $data); |
||||||||
81 | $this->assertContains($response->getStatusCode(), [ |
||||||||
82 | Response::HTTP_CREATED, |
||||||||
83 | ]); |
||||||||
84 | |||||||||
85 | $content = json_decode($response->getContent())->data; |
||||||||
86 | |||||||||
87 | $test = Test::findOrFail($content->id); |
||||||||
88 | $this->assertEquals($data['name'], $test->name); |
||||||||
89 | $this->assertEquals($data['type'], $test->type); |
||||||||
90 | |||||||||
91 | return $content->id; |
||||||||
92 | } |
||||||||
93 | |||||||||
94 | public function testUpdate() |
||||||||
95 | { |
||||||||
96 | Route::put('tests/{id}', [TestController::class, 'update']); |
||||||||
97 | |||||||||
98 | $test = Test::create([ |
||||||||
99 | 'name' => 'test name', |
||||||||
100 | 'type' => 'a test' |
||||||||
101 | ]); |
||||||||
102 | |||||||||
103 | $data = [ |
||||||||
104 | 'name' => 'Update Test', |
||||||||
105 | 'type' => 'Updated', |
||||||||
106 | ]; |
||||||||
107 | |||||||||
108 | $response = $this->putJson('tests/'.$test->id, $data); |
||||||||
109 | |||||||||
110 | $this->assertContains($response->getStatusCode(), [ |
||||||||
111 | Response::HTTP_OK, |
||||||||
112 | ]); |
||||||||
113 | |||||||||
114 | $test = Test::findOrFail($test->id); |
||||||||
115 | $this->assertEquals($data['name'], $test->name); |
||||||||
116 | $this->assertEquals($data['type'], $test->type); |
||||||||
117 | } |
||||||||
118 | |||||||||
119 | public function testDelete() |
||||||||
120 | { |
||||||||
121 | Route::delete('tests/{id}', [TestController::class, 'destroy']); |
||||||||
122 | |||||||||
123 | $test = Test::create([ |
||||||||
124 | 'name' => 'test name', |
||||||||
125 | 'type' => 'a test' |
||||||||
126 | ]); |
||||||||
127 | |||||||||
128 | $response = $this->deleteJson('tests/'.$test->id); |
||||||||
129 | $this->assertContains($response->getStatusCode(), [ |
||||||||
130 | Response::HTTP_OK, |
||||||||
131 | ]); |
||||||||
132 | |||||||||
133 | $this->assertNull(Test::find($test->id)); |
||||||||
134 | } |
||||||||
135 | } |
||||||||
136 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths