Skip to content

Commit d5641d3

Browse files
committed
Use assertCreated for new Resource responses
1 parent f289ca7 commit d5641d3

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/Generators/TestGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,12 @@ protected function buildTestCases(Controller $controller)
378378

379379
array_unshift($assertions['response'], $assertion);
380380
} elseif ($statement instanceof ResourceStatement) {
381-
$assertions['response'][] = '$response->assertOk();';
381+
if ($name === 'store') {
382+
$assertions['response'][] = '$response->assertCreated();';
383+
} else {
384+
$assertions['response'][] = '$response->assertOk();';
385+
}
386+
382387
$assertions['response'][] = '$response->assertJsonStructure([]);';
383388
} elseif ($statement instanceof RespondStatement) {
384389
$tested_bits |= self::TESTS_RESPONDS;

tests/fixtures/tests/api-shorthand-validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function store_saves()
7171
$this->assertCount(1, $certificates);
7272
$certificate = $certificates->first();
7373

74-
$response->assertOk();
74+
$response->assertCreated();
7575
$response->assertJsonStructure([]);
7676
}
7777

tests/fixtures/tests/certificate-pascal-case-example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function store_saves()
7171
$this->assertCount(1, $certificates);
7272
$certificate = $certificates->first();
7373

74-
$response->assertOk();
74+
$response->assertCreated();
7575
$response->assertJsonStructure([]);
7676
}
7777

tests/fixtures/tests/certificate-type-pascal-case-example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function store_saves()
5858
$this->assertCount(1, $certificateTypes);
5959
$certificateType = $certificateTypes->first();
6060

61-
$response->assertOk();
61+
$response->assertCreated();
6262
$response->assertJsonStructure([]);
6363
}
6464

tests/fixtures/tests/models-with-custom-namespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function store_saves()
6464
$this->assertCount(1, $categories);
6565
$category = $categories->first();
6666

67-
$response->assertOk();
67+
$response->assertCreated();
6868
$response->assertJsonStructure([]);
6969
}
7070

0 commit comments

Comments
 (0)