Browse Source

test: add withMultipleFormRequestParameters

yusuke nakazawa 6 years ago
parent
commit
cf5f422051
2 changed files with 47 additions and 0 deletions
  1. 5 0
      tests/Fixtures/TestController.php
  2. 42 0
      tests/Unit/GeneratorTestCase.php

+ 5 - 0
tests/Fixtures/TestController.php

@@ -57,6 +57,11 @@ class TestController extends Controller
         return '';
     }
 
+    public function withMultipleFormRequestParameters(string $test, TestRequest $request)
+    {
+        return '';
+    }
+
     /**
      * @bodyParam direct_one string Is found directly on the method.
      */

+ 42 - 0
tests/Unit/GeneratorTestCase.php

@@ -139,6 +139,48 @@ abstract class GeneratorTestCase extends TestCase
         ], $bodyParameters);
     }
 
+    /** @test */
+    public function can_parse_multiple_form_request_body_parameters()
+    {
+        $route = $this->createRoute('GET', '/api/test', 'withMultipleFormRequestParameters');
+        $bodyParameters = $this->generator->processRoute($route)['bodyParameters'];
+
+        $this->assertArraySubset([
+            'user_id' => [
+                'type' => 'integer',
+                'required' => true,
+                'description' => 'The id of the user.',
+                'value' => 9,
+            ],
+            'room_id' => [
+                'type' => 'string',
+                'required' => false,
+                'description' => 'The id of the room.',
+            ],
+            'forever' => [
+                'type' => 'boolean',
+                'required' => false,
+                'description' => 'Whether to ban the user forever.',
+                'value' => false,
+            ],
+            'another_one' => [
+                'type' => 'number',
+                'required' => false,
+                'description' => 'Just need something here.',
+            ],
+            'yet_another_param' => [
+                'type' => 'object',
+                'required' => true,
+                'description' => '',
+            ],
+            'even_more_param' => [
+                'type' => 'array',
+                'required' => false,
+                'description' => '',
+            ],
+        ], $bodyParameters);
+    }
+
     /** @test */
     public function can_parse_query_parameters()
     {