|
531 | 531 | expect(($results->first())->name)->toBe('Stark');
|
532 | 532 | });
|
533 | 533 |
|
| 534 | +test('whereNone', function () { |
| 535 | + $query = \DB::table('houses') |
| 536 | + ->whereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%'); |
| 537 | + |
| 538 | + $binds = $query->getBindings(); |
| 539 | + $bindKeys = array_keys($binds); |
| 540 | + |
| 541 | + $this->assertSame( |
| 542 | + 'FOR houseDoc IN houses FILTER not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[0] |
| 543 | + . ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[1] |
| 544 | + . ') RETURN houseDoc', |
| 545 | + $query->toSql(), |
| 546 | + ); |
| 547 | + |
| 548 | + $results = $query->get(); |
| 549 | + expect($results->count())->toBe(1); |
| 550 | + expect(($results->first())->name)->toBe('Targaryen'); |
| 551 | +}); |
| 552 | + |
| 553 | +test('orWhereNone', function () { |
| 554 | + $query = \DB::table('houses') |
| 555 | + ->where('name', 'Stark') |
| 556 | + ->orWhereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%'); |
| 557 | + |
| 558 | + $binds = $query->getBindings(); |
| 559 | + $bindKeys = array_keys($binds); |
| 560 | + |
| 561 | + $this->assertSame( |
| 562 | + 'FOR houseDoc IN houses FILTER `houseDoc`.`name` == @' . $bindKeys[0] |
| 563 | + |
| 564 | + . ' or not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[1] |
| 565 | + . ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[2] |
| 566 | + . ') RETURN houseDoc', |
| 567 | + $query->toSql(), |
| 568 | + ); |
| 569 | + |
| 570 | + $results = $query->get(); |
| 571 | + expect($results->count())->toBe(2); |
| 572 | + expect(($results->first())->name)->toBe('Stark'); |
| 573 | +}); |
| 574 | + |
| 575 | + |
| 576 | + |
534 | 577 | test('basic whereNot', function () {
|
535 | 578 | $builder = getBuilder();
|
536 | 579 | $builder->select('*')->from('characters')->where('surname', 'Lannister')->whereNot('alive', true);
|
|
0 commit comments