8000 [Tests] Fix broken tests · ossycodes/laravel-json-api@67b5ea2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67b5ea2

Browse files
committed
[Tests] Fix broken tests
Two tests were failing because of the use of posts and videos resources for the comment commentable relationship - and each model has a different primary key column (id vs uuid). This test setup was a bit unrealistic as morph-to relations are more likely to have the same id type on the different models.
1 parent 7480ed3 commit 67b5ea2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/lib/Integration/Eloquent/MorphToTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function testUpdateReplacesNullRelationshipWithResource()
174174
public function testUpdateChangesRelatedResource()
175175
{
176176
/** @var Comment $comment */
177-
$comment = factory(Comment::class)->states('video')->create();
177+
$comment = factory(Comment::class)->states('post')->create();
178178

179179
/** @var Post $post */
180180
$post = factory(Post::class)->create();
@@ -280,17 +280,17 @@ public function testReplaceRelationshipWithNull()
280280
public function testReplaceRelationshipWithDifferentResource()
281281
{
282282
$comment = factory(Comment::class)->states('post')->create();
283-
$video = factory(Video::class)->create();
283+
$post = factory(Post::class)->create();
284284

285-
$data = ['type' => 'videos', 'id' => (string) $video->getKey()];
285+
$data = ['type' => 'posts', 'id' => (string) $post->getKey()];
286286

287287
$this->doReplaceRelationship($comment, 'commentable', $data)
288288
->assertStatus(204);
289289

290290
$this->assertDatabaseHas('comments', [
291291
'id' => $comment->getKey(),
292-
'commentable_type' => Video::class,
293-
'commentable_id' => $video->getKey(),
292+
'commentable_type' => Post::class,
293+
'commentable_id' => $post->getKey(),
294294
]);
295295
}
296296
}

0 commit comments

Comments
 (0)
0