|
6 | 6 | use Illuminate\Routing\Route;
|
7 | 7 | use Knuckles\Camel\Extraction\ExtractedEndpointData;
|
8 | 8 | use Knuckles\Scribe\Tools\DocumentationConfig;
|
9 |
| -use Tests\Fixtures\LaravelData\AttributeRules; |
10 |
| -use Tests\Fixtures\LaravelData\CustomAttributeRules; |
11 |
| -use Tests\Fixtures\LaravelData\ManualRules; |
12 |
| -use Tests\Fixtures\LaravelData\NoRules; |
13 |
| -use Tests\Fixtures\ParentClasses\ParentClassLaravelData; |
14 |
| -use Tests\Fixtures\ParentClasses\WithoutParentClassLaravelData; |
15 |
| -use Tests\Fixtures\Requests\RequestRules; |
| 9 | +use Tests\Fixtures\Controllers\LaravelDataController; |
16 | 10 |
|
17 | 11 | mutates(LaravelDataBodyParam::class);
|
18 | 12 |
|
19 |
| -test('generate doc body params from method with AttributeRules', function (): void { |
20 |
| - $route = new Route('', '', fn(AttributeRules $attributeRules): null => null); |
| 13 | +test('generate doc body params from method with attributeRules', function (): void { |
| 14 | + $route = new Route('', '', [LaravelDataController::class, 'attributeRules']); |
21 | 15 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
22 | 16 |
|
23 | 17 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
28 | 22 | expect($result)->toEqual($this->getParamsAttributeRules());
|
29 | 23 | });
|
30 | 24 |
|
31 |
| -test('generate doc body params from method with CustomAttributeRules', function (): void { |
32 |
| - $route = new Route('', '', fn(CustomAttributeRules $attributeRules): null => null); |
| 25 | +test('generate doc body params from method with customAttributeRules', function (): void { |
| 26 | + $route = new Route('', '', [LaravelDataController::class, 'customAttributeRules']); |
33 | 27 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
34 | 28 |
|
35 | 29 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
40 | 34 | expect($result)->toEqual($this->getParamsCustomAttributeRules());
|
41 | 35 | });
|
42 | 36 |
|
43 |
| -test('generate doc body params from method with ManualRules', function (): void { |
44 |
| - $route = new Route('', '', fn(ManualRules $attributeRules): null => null); |
| 37 | +test('generate doc body params from method with manualRules', function (): void { |
| 38 | + $route = new Route('', '', [LaravelDataController::class, 'manualRules']); |
45 | 39 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
46 | 40 |
|
47 | 41 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
52 | 46 | expect($result)->toEqual($this->getParamsManualRules());
|
53 | 47 | });
|
54 | 48 |
|
55 |
| -test('generate doc body params from method with NoRules', function (): void { |
56 |
| - $route = new Route('', '', fn(NoRules $attributeRules): null => null); |
| 49 | +test('generate doc body params from method with noRules', function (): void { |
| 50 | + $route = new Route('', '', [LaravelDataController::class, 'noRules']); |
57 | 51 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
58 | 52 |
|
59 | 53 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
64 | 58 | expect($result)->toEqual($this->getParamsNoRules());
|
65 | 59 | });
|
66 | 60 |
|
67 |
| -test('generate doc body params from method with WithoutParentClassLaravelData', function (): void { |
68 |
| - $route = new Route('', '', fn(WithoutParentClassLaravelData $attributeRules): null => null); |
| 61 | +test('generate doc body params from method with withoutLaravelData', function (): void { |
| 62 | + $route = new Route('', '', [LaravelDataController::class, 'withoutLaravelData']); |
69 | 63 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
70 | 64 |
|
71 | 65 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
76 | 70 | expect($result)->toBeEmpty();
|
77 | 71 | });
|
78 | 72 |
|
79 |
| -test('generate doc body params from method with ParentClassLaravelData', function (): void { |
80 |
| - $route = new Route('', '', fn(ParentClassLaravelData $attributeRules): null => null); |
| 73 | +test('generate doc body params from method with emptyLaravelData', function (): void { |
| 74 | + $route = new Route('', '', [LaravelDataController::class, 'emptyLaravelData']); |
81 | 75 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
82 | 76 |
|
83 | 77 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
88 | 82 | expect($result)->toBeEmpty();
|
89 | 83 | });
|
90 | 84 |
|
91 |
| -test('generate doc body params from method with empty parameters', function (): void { |
92 |
| - $route = new Route('', '', fn(): null => null); |
| 85 | +test('generate doc body params from method with empty emptyMethod', function (): void { |
| 86 | + $route = new Route('', '', [LaravelDataController::class, 'emptyMethod']); |
93 | 87 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
94 | 88 |
|
95 | 89 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
100 | 94 | expect($result)->toBeEmpty();
|
101 | 95 | });
|
102 | 96 |
|
103 |
| -test('generate doc body params from method with more parameters', function (): void { |
104 |
| - $route = new Route('', '', fn(string $id, int $number, float $price): null => null); |
| 97 | +test('generate doc body params from method with more moreParameters', function (): void { |
| 98 | + $route = new Route('', '', [LaravelDataController::class, 'moreParameters']); |
105 | 99 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
106 | 100 |
|
107 | 101 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
112 | 106 | expect($result)->toBeEmpty();
|
113 | 107 | });
|
114 | 108 |
|
115 |
| -test('generate doc body params from method with RequestRules', function (): void { |
116 |
| - $route = new Route('', '', fn(RequestRules $requestRules): null => null); |
| 109 | +test('generate doc body params from method with requestRules', function (): void { |
| 110 | + $route = new Route('', '', [LaravelDataController::class, 'requestRules']); |
117 | 111 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
118 | 112 |
|
119 | 113 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
124 | 118 | expect($result)->toBeEmpty();
|
125 | 119 | });
|
126 | 120 |
|
127 |
| -test('generate doc body params from method with RequestRules and AttributeRules', function (): void { |
128 |
| - $route = new Route('', '', fn(RequestRules $requestRules, AttributeRules $attributeRules): null => null); |
| 121 | +test('generate doc body params from method with requestAndLaravelData', function (): void { |
| 122 | + $route = new Route('', '', [LaravelDataController::class, 'requestAndLaravelData']); |
129 | 123 | $laravelDataBodyParam = new LaravelDataBodyParam(new DocumentationConfig());
|
130 | 124 |
|
131 | 125 | $result = $laravelDataBodyParam(ExtractedEndpointData::fromRoute($route));
|
|
0 commit comments