Skip to content

Commit

Permalink
add tests for whereNot database rule (#43003)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges authored Jun 29, 2022
1 parent 46fd623 commit 95ce178
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/Validation/ValidationExistsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,29 @@ public function testItChoosesValidRecordsUsingWhereNotInAndWhereNotInRulesTogeth
$this->assertTrue($v->passes());
}

public function testItChoosesValidRecordsUsingWhereNotRule()
{
$rule = new Exists('users', 'id');

$rule->whereNot('type', 'baz');

User::create(['id' => '1', 'type' => 'foo']);
User::create(['id' => '2', 'type' => 'bar']);
User::create(['id' => '3', 'type' => 'baz']);
User::create(['id' => '4', 'type' => 'other']);
User::create(['id' => '5', 'type' => 'baz']);

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, [], ['id' => $rule]);
$v->setPresenceVerifier(new DatabasePresenceVerifier(Eloquent::getConnectionResolver()));

$v->setData(['id' => 3]);
$this->assertFalse($v->passes());

$v->setData(['id' => 4]);
$this->assertTrue($v->passes());
}

public function testItIgnoresSoftDeletes()
{
$rule = new Exists('table');
Expand Down

0 comments on commit 95ce178

Please sign in to comment.