Skip to content

Commit

Permalink
[9.x] Improve test for whereNot and WhereNested in query Builder Class (
Browse files Browse the repository at this point in the history
  • Loading branch information
moharami authored Sep 15, 2022
1 parent 0432012 commit f955686
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Integration/Database/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ public function testWhereNot()
$this->assertSame('Bar Post', $results[0]->title);
}

public function testWhereNotInputStringParameter()
{
$results = DB::table('posts')->whereNot('title', 'Foo Post')->get();

$this->assertCount(1, $results);
$this->assertSame('Bar Post', $results[0]->title);

DB::table('posts')->insert([
['title' => 'Baz Post', 'content' => 'Lorem Ipsum.', 'created_at' => new Carbon('2017-11-12 13:14:15')],
]);

$results = DB::table('posts')->whereNot('title', 'Foo Post')->whereNot('title', 'Bar Post')->get();
$this->assertSame('Baz Post', $results[0]->title);
}

public function testOrWhereNot()
{
$results = DB::table('posts')->where('id', 1)->orWhereNot(function ($query) {
Expand Down Expand Up @@ -233,6 +248,15 @@ public function testOrWhereTime()
$this->assertSame(2, DB::table('posts')->where('id', 1)->orWhereTime('created_at', new Carbon('2018-01-02 03:04:05'))->count());
}

public function testWhereNested()
{
$results = DB::table('posts')->where('content', 'Lorem Ipsum.')->whereNested(function ($query) {
$query->where('title', 'Foo Post')
->orWhere('title', 'Bar Post');
})->count();
$this->assertSame(2, $results);
}

public function testPaginateWithSpecificColumns()
{
$result = DB::table('posts')->paginate(5, ['title', 'content']);
Expand Down

0 comments on commit f955686

Please sign in to comment.