This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mpyw/feature/support-union-argument
Revise: "Add support for union argument in constraint callable #11"
- Loading branch information
Showing
4 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Mpyw\EloquentHasByNonDependentSubquery\Tests\Models\Comment; | ||
use Mpyw\EloquentHasByNonDependentSubquery\Tests\Models\Post; | ||
|
||
$this->assertQueryEquals( | ||
<<<'EOD' | ||
select | ||
* | ||
from | ||
"comments" | ||
where | ||
"comments"."post_id" in ( | ||
select | ||
"posts"."id" | ||
from | ||
"posts" | ||
where | ||
"posts"."deleted_at" is not null | ||
) | ||
EOD | ||
, | ||
Comment::query()->hasByNonDependentSubquery( | ||
'post', | ||
function (Post|BelongsTo $query) { | ||
$this->assertInstanceof(BelongsTo::class, $query); | ||
$query->onlyTrashed(); | ||
} | ||
)->withTrashed() | ||
); | ||
|
||
$this->assertQueryEquals( | ||
<<<'EOD' | ||
select | ||
* | ||
from | ||
"comments" | ||
where | ||
"comments"."post_id" in ( | ||
select | ||
"posts"."id" | ||
from | ||
"posts" | ||
where | ||
"posts"."deleted_at" is not null | ||
) | ||
EOD | ||
, | ||
Comment::query()->hasByNonDependentSubquery( | ||
'post', | ||
function (BelongsTo|Builder $query) { | ||
$this->assertInstanceof(BelongsTo::class, $query); | ||
$query->onlyTrashed(); | ||
} | ||
)->withTrashed() | ||
); | ||
|
||
$this->assertQueryEquals( | ||
<<<'EOD' | ||
select | ||
* | ||
from | ||
"comments" | ||
where | ||
"comments"."post_id" in ( | ||
select | ||
"posts"."id" | ||
from | ||
"posts" | ||
where | ||
"posts"."deleted_at" is not null | ||
) | ||
EOD | ||
, | ||
Comment::query()->hasByNonDependentSubquery( | ||
'post', | ||
function (Post|Builder $query) { | ||
$this->assertInstanceof(Builder::class, $query); | ||
$query->onlyTrashed(); | ||
} | ||
)->withTrashed() | ||
); |