Quellcode durchsuchen

Merge pull request #640 from zek/patch-1

Fix mergeWhen Bug
Shalvah vor 5 Jahren
Ursprung
Commit
778c0b5cc5

+ 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 */