From 23b6fe9a2f295f9df67faa87bbc13a837cce95bb Mon Sep 17 00:00:00 2001 From: Will Taylor-Jackson Date: Fri, 24 Sep 2021 15:58:17 +0100 Subject: [PATCH] tests: for snake case morph relation name --- tests/RelationsTest.php | 12 ++++++------ tests/models/Client.php | 2 +- tests/models/Photo.php | 2 +- tests/models/User.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/RelationsTest.php b/tests/RelationsTest.php index c702f0e2b..b1b73e6cc 100644 --- a/tests/RelationsTest.php +++ b/tests/RelationsTest.php @@ -370,21 +370,21 @@ public function testMorph(): void $this->assertEquals($photo->id, $client->photo->id); $photo = Photo::first(); - $this->assertEquals($photo->imageable->name, $user->name); + $this->assertEquals($photo->hasImage->name, $user->name); $user = User::with('photos')->find($user->_id); $relations = $user->getRelations(); $this->assertArrayHasKey('photos', $relations); $this->assertEquals(1, $relations['photos']->count()); - $photos = Photo::with('imageable')->get(); + $photos = Photo::with('hasImage')->get(); $relations = $photos[0]->getRelations(); - $this->assertArrayHasKey('imageable', $relations); - $this->assertInstanceOf(User::class, $photos[0]->imageable); + $this->assertArrayHasKey('hasImage', $relations); + $this->assertInstanceOf(User::class, $photos[0]->hasImage); $relations = $photos[1]->getRelations(); - $this->assertArrayHasKey('imageable', $relations); - $this->assertInstanceOf(Client::class, $photos[1]->imageable); + $this->assertArrayHasKey('hasImage', $relations); + $this->assertInstanceOf(Client::class, $photos[1]->hasImage); } public function testHasManyHas(): void diff --git a/tests/models/Client.php b/tests/models/Client.php index 2c1388a6c..65c5d81a0 100644 --- a/tests/models/Client.php +++ b/tests/models/Client.php @@ -20,7 +20,7 @@ public function users(): BelongsToMany public function photo(): MorphOne { - return $this->morphOne('Photo', 'imageable'); + return $this->morphOne('Photo', 'has_image'); } public function addresses(): HasMany diff --git a/tests/models/Photo.php b/tests/models/Photo.php index 8cb800922..05c06d443 100644 --- a/tests/models/Photo.php +++ b/tests/models/Photo.php @@ -11,7 +11,7 @@ class Photo extends Eloquent protected $collection = 'photos'; protected static $unguarded = true; - public function imageable(): MorphTo + public function hasImage(): MorphTo { return $this->morphTo(); } diff --git a/tests/models/User.php b/tests/models/User.php index b394ea6e7..f9360f545 100644 --- a/tests/models/User.php +++ b/tests/models/User.php @@ -73,7 +73,7 @@ public function groups() public function photos() { - return $this->morphMany('Photo', 'imageable'); + return $this->morphMany('Photo', 'has_image'); } public function addresses()