-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Tests\Clauses; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Tests\Models\Order; | ||
use Fico7489\Laravel\EloquentJoin\Tests\TestCase; | ||
|
||
class OrWhereInTest extends TestCase | ||
{ | ||
public function testWhere() | ||
{ | ||
Order::joinRelations('seller') | ||
->whereInJoin('seller.id', [1, 2]) | ||
->orWhereInJoin('seller.id', [3, 4]) | ||
->get(); | ||
|
||
$queryTest = 'select orders.* | ||
from "orders" | ||
left join "sellers" on "sellers"."id" = "orders"."seller_id" | ||
where ("sellers"."id" in (?, ?) | ||
or | ||
"sellers"."id" in (?, ?)) | ||
and "orders"."deleted_at" is null | ||
group by "orders"."id"'; | ||
|
||
$this->assertQueryMatches($queryTest, $this->fetchQuery()); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Tests\Clauses; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Tests\Models\Order; | ||
use Fico7489\Laravel\EloquentJoin\Tests\TestCase; | ||
|
||
class OrWhereNotInTest extends TestCase | ||
{ | ||
public function testWhere() | ||
{ | ||
Order::joinRelations('seller') | ||
->whereInJoin('seller.id', [1, 2]) | ||
->orWhereNotInJoin('seller.id', [3, 4]) | ||
->get(); | ||
|
||
$queryTest = 'select orders.* | ||
from "orders" | ||
left join "sellers" on "sellers"."id" = "orders"."seller_id" | ||
where "sellers"."id" in (?, ?) | ||
and "sellers"."id" not in (?, ?) | ||
and "orders"."deleted_at" is null | ||
group by "orders"."id"'; | ||
|
||
$this->assertQueryMatches($queryTest, $this->fetchQuery()); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Tests\Clauses; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Tests\Models\Order; | ||
use Fico7489\Laravel\EloquentJoin\Tests\TestCase; | ||
|
||
class WhereInTest extends TestCase | ||
{ | ||
public function testWhere() | ||
{ | ||
Order::joinRelations('seller') | ||
->whereInJoin('seller.id', [1, 2]) | ||
->get(); | ||
|
||
$queryTest = 'select orders.* | ||
from "orders" | ||
left join "sellers" on "sellers"."id" = "orders"."seller_id" | ||
where "sellers"."id" in (?, ?) | ||
and "orders"."deleted_at" is null | ||
group by "orders"."id"'; | ||
|
||
$this->assertQueryMatches($queryTest, $this->fetchQuery()); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Tests\Clauses; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Tests\Models\Order; | ||
use Fico7489\Laravel\EloquentJoin\Tests\TestCase; | ||
|
||
class WhereNotInTest extends TestCase | ||
{ | ||
public function testWhere() | ||
{ | ||
Order::joinRelations('seller') | ||
->whereNotInJoin('seller.id', [1, 2]) | ||
->get(); | ||
|
||
$queryTest = 'select orders.* | ||
from "orders" | ||
left join "sellers" on "sellers"."id" = "orders"."seller_id" | ||
where "sellers"."id" not in (?, ?) | ||
and "orders"."deleted_at" is null | ||
group by "orders"."id"'; | ||
|
||
$this->assertQueryMatches($queryTest, $this->fetchQuery()); | ||
} | ||
} |