From 0dc9f2d323fa277128f8290f8437bd35fec1cb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E4=BA=91=E5=B3=B0?= Date: Thu, 1 Sep 2022 16:00:00 +0800 Subject: [PATCH] fix(pest): complete. --- tests/Feature/OrWhereMorphRelationInTest.php | 15 ++++++++++++ tests/Feature/OrWhereRelationInTest.php | 25 ++++++++++++++++++++ tests/Feature/WhereMorphRelationInTest.php | 13 ++++++++++ tests/Feature/WhereRelationInTest.php | 17 +++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 tests/Feature/OrWhereMorphRelationInTest.php create mode 100644 tests/Feature/OrWhereRelationInTest.php create mode 100644 tests/Feature/WhereMorphRelationInTest.php create mode 100644 tests/Feature/WhereRelationInTest.php diff --git a/tests/Feature/OrWhereMorphRelationInTest.php b/tests/Feature/OrWhereMorphRelationInTest.php new file mode 100644 index 0000000..8ec7357 --- /dev/null +++ b/tests/Feature/OrWhereMorphRelationInTest.php @@ -0,0 +1,15 @@ +=', 2) + ->orWhereMorphRelation('commentable', [Post::class], 'title', 'like', '%code%') + ->orderBy('id')->pluck('id'); + $orWhereMorphRelationIn = Comment::where('status', '>=', 2) + ->orWhereMorphRelationIn('commentable', [Post::class], 'title', 'like', '%code%') + ->orderBy('id')->pluck('id'); + + expect($orWhereMorphRelation)->toEqual($orWhereMorphRelationIn); +}); diff --git a/tests/Feature/OrWhereRelationInTest.php b/tests/Feature/OrWhereRelationInTest.php new file mode 100644 index 0000000..004efe5 --- /dev/null +++ b/tests/Feature/OrWhereRelationInTest.php @@ -0,0 +1,25 @@ +', 18) + ->orWhereRelation('posts', 'title', 'like', '%code%') + ->orderBy('id')->pluck('id'); + $orWhereRelationIn = User::where('age', '>', 18) + ->orWhereRelationIn('posts', 'title', 'like', '%code%') + ->orderBy('id')->pluck('id'); + + expect($orWhereRelation)->toEqual($orWhereRelationIn); +}); + +test('nested whereRelationIn same as nested whereRelation', function () { + $orWhereRelation = User::where('age', '>', 18) + ->orWhereRelation('posts.comments', 'status', '>=', '2') + ->orderBy('id')->pluck('id'); + $orWhereRelationIn = User::where('age', '>', 18) + ->orWhereRelationIn('posts.comments', 'status', '>=', '2') + ->orderBy('id')->pluck('id'); + + expect($orWhereRelation)->toEqual($orWhereRelationIn); +}); diff --git a/tests/Feature/WhereMorphRelationInTest.php b/tests/Feature/WhereMorphRelationInTest.php new file mode 100644 index 0000000..c6d9275 --- /dev/null +++ b/tests/Feature/WhereMorphRelationInTest.php @@ -0,0 +1,13 @@ +orderBy('id')->pluck('id'); + $whereMorphRelationIn = Comment::whereMorphRelationIn('commentable', [Post::class], 'title', 'like', '%code%') + ->orderBy('id')->pluck('id'); + + expect($whereMorphRelation)->toEqual($whereMorphRelationIn); +}); diff --git a/tests/Feature/WhereRelationInTest.php b/tests/Feature/WhereRelationInTest.php new file mode 100644 index 0000000..d41bd65 --- /dev/null +++ b/tests/Feature/WhereRelationInTest.php @@ -0,0 +1,17 @@ +orderBy('id')->pluck('id'); + $whereRelationIn = User::whereRelationIn('posts', 'title', 'like', '%code%')->orderBy('id')->pluck('id'); + + expect($whereRelation)->toEqual($whereRelationIn); +}); + +test('nested whereRelationIn same as nested whereRelation', function () { + $whereRelation = User::whereRelation('posts.comments', 'status', '>=', '2')->orderBy('id')->pluck('id'); + $whereRelationIn = User::whereRelationIn('posts.comments', 'status', '>=', '2')->orderBy('id')->pluck('id'); + + expect($whereRelation)->toEqual($whereRelationIn); +});