Skip to content

Commit

Permalink
Add a couple more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist committed Jan 17, 2018
1 parent aa4bf59 commit 9dbbc6d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/QueryBuilderTest.php
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());
}
}

0 comments on commit 9dbbc6d

Please sign in to comment.