-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
1 parent
aa4bf59
commit 9dbbc6d
Showing
1 changed file
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Spatie\QueryBuilder\Tests; | ||
|
||
use Spatie\QueryBuilder\QueryBuilder; | ||
use Spatie\QueryBuilder\Tests\Models\TestModel; | ||
|
||
class QueryBuilderTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_will_determine_the_request_when_its_not_given() | ||
{ | ||
$this->getJson('/test-model?sort=name'); | ||
|
||
$builder = QueryBuilder::for(TestModel::class); | ||
|
||
$this->assertEquals([ | ||
'direction' => 'asc', | ||
'column' => 'name', | ||
], $builder->getQuery()->orders[0]); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_be_given_a_custom_base_query() | ||
{ | ||
$queryBuilder = QueryBuilder::for(TestModel::where('id', 1)); | ||
|
||
$eloquentBuilder = TestModel::where('id', 1); | ||
|
||
$this->assertEquals($eloquentBuilder->toSql(), $queryBuilder->toSql()); | ||
} | ||
} |