@@ -29,6 +29,81 @@ protected function registerApiRoutes()
2929 Route::get ('/products/{id} ' , [ProductsController::class, 'show ' ])->name ('products.show ' );
3030 }
3131
32+ #[Test]
33+ public function it_can_get_index_method_api_doc_metadata (): void
34+ {
35+ $ params = ProductsController::apiDocControllerMethodMetadata ('index ' );
36+
37+ $ this ->assertIsArray ($ params );
38+
39+ $ this ->assertEquals ('Products ' , $ params ['groupName ' ]);
40+ $ this ->assertEquals ('Endpoints for listing and viewing products ' , $ params ['groupDescription ' ]);
41+ $ this ->assertEquals ('List all products ' , $ params ['title ' ]);
42+ $ this ->assertEquals ('Fetch all products. Supports filtering, sorting, pagination and field selection. ' , $ params ['description ' ]);
43+ }
44+
45+ #[Test]
46+ public function it_can_get_show_method_api_doc_metadata (): void
47+ {
48+ $ params = ProductsController::apiDocControllerMethodMetadata ('show ' );
49+
50+ $ this ->assertIsArray ($ params );
51+
52+ $ this ->assertEquals ('Products ' , $ params ['groupName ' ]);
53+ $ this ->assertEquals ('Endpoints for listing and viewing products ' , $ params ['groupDescription ' ]);
54+ $ this ->assertEquals ('View a single product ' , $ params ['title ' ]);
55+ $ this ->assertEquals ('Fetch a single product. Supports field selection. ' , $ params ['description ' ]);
56+ }
57+
58+ #[Test]
59+ public function it_can_get_other_methods_api_doc_metadata (): void
60+ {
61+ $ params = ProductsController::apiDocControllerMethodMetadata ('fake ' );
62+
63+ $ this ->assertIsArray ($ params );
64+
65+ $ this ->assertEquals ('Products ' , $ params ['groupName ' ]);
66+ $ this ->assertEquals ('Endpoints for listing and viewing products ' , $ params ['groupDescription ' ]);
67+
68+ $ this ->assertArrayNotHasKey ('title ' , $ params );
69+ $ this ->assertArrayNotHasKey ('description ' , $ params );
70+ }
71+
72+ #[Test]
73+ public function it_can_get_index_method_api_doc_query_params (): void
74+ {
75+ $ params = ProductsController::apiDocControllerMethodQueryParameters ('index ' );
76+
77+ $ this ->assertIsArray ($ params );
78+
79+ $ this ->assertArrayHasKey ('fields ' , $ params );
80+ $ this ->assertArrayHasKey ('include ' , $ params );
81+ $ this ->assertArrayHasKey ('append ' , $ params );
82+ $ this ->assertArrayHasKey ('sort ' , $ params );
83+ $ this ->assertArrayHasKey ('per_page ' , $ params );
84+ $ this ->assertArrayHasKey ('page ' , $ params );
85+ $ this ->assertArrayHasKey ('filter[name] ' , $ params );
86+ $ this ->assertArrayHasKey ('filter[search] ' , $ params );
87+ }
88+
89+ #[Test]
90+ public function it_can_get_show_method_api_doc_query_params (): void
91+ {
92+ $ params = ProductsController::apiDocControllerMethodQueryParameters ('show ' );
93+
94+ $ this ->assertIsArray ($ params );
95+
96+ $ this ->assertArrayHasKey ('fields ' , $ params );
97+ $ this ->assertArrayHasKey ('include ' , $ params );
98+ $ this ->assertArrayHasKey ('append ' , $ params );
99+
100+ $ this ->assertArrayNotHasKey ('sort ' , $ params );
101+ $ this ->assertArrayNotHasKey ('per_page ' , $ params );
102+ $ this ->assertArrayNotHasKey ('page ' , $ params );
103+ $ this ->assertArrayNotHasKey ('filter[name] ' , $ params );
104+ $ this ->assertArrayNotHasKey ('filter[search] ' , $ params );
105+ }
106+
32107 #[Test]
33108 public function it_can_list_api_models (): void
34109 {
0 commit comments