소스 검색

Merge pull request #640 from zek/patch-1

Fix mergeWhen Bug
Shalvah 5 년 전
부모
커밋
778c0b5cc5
3개의 변경된 파일13개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 3
      src/Extracting/Strategies/Responses/UseApiResourceTags.php
  2. 5 3
      tests/Fixtures/index.md
  3. 7 5
      tests/Unit/GeneratorTestCase.php

+ 1 - 3
src/Extracting/Strategies/Responses/UseApiResourceTags.php

@@ -81,9 +81,7 @@ class UseApiResourceTags extends Strategy
             }
 
             /** @var Response $response */
-            $response = response()->json(
-                $resource->toArray(app(Request::class))
-            );
+            $response = $resource->toResponse(app(Request::class));
 
             return [
                 [

+ 5 - 3
tests/Fixtures/index.md

@@ -350,9 +350,11 @@ fetch(url, {
 
 ```json
 {
-    "id": 4,
-    "name": "Tested Again",
-    "email": "a@b.com"
+    "data": {
+        "id": 4,
+        "name": "Tested Again",
+        "email": "a@b.com"
+    }
 }
 ```
 

+ 7 - 5
tests/Unit/GeneratorTestCase.php

@@ -412,9 +412,11 @@ abstract class GeneratorTestCase extends TestCase
         $this->assertTrue(is_array($response));
         $this->assertEquals(200, $response['status']);
         $this->assertArraySubset([
-            'id' => 4,
-            'name' => 'Tested Again',
-            'email' => 'a@b.com',
+            'data' => [
+                'id' => 4,
+                'name' => 'Tested Again',
+                'email' => 'a@b.com',
+            ],
         ], json_decode($response['content'], true));
     }
 
@@ -440,12 +442,12 @@ abstract class GeneratorTestCase extends TestCase
             'id' => 4,
             'name' => 'Tested Again',
             'email' => 'a@b.com',
-        ], $content[0]);
+        ], $content['data'][0]);
         $this->assertArraySubset([
             'id' => 4,
             'name' => 'Tested Again',
             'email' => 'a@b.com',
-        ], $content[1]);
+        ], $content['data'][1]);
     }
 
     /** @test */