mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:34:04 +00:00
complete uniqe exists test
This commit is contained in:
parent
6d9031295e
commit
782501fc53
1 changed files with 9 additions and 9 deletions
|
|
@ -204,16 +204,16 @@ test('the model returned by the tenant helper has unique and exists validation r
|
||||||
Post::create(['text' => 'Foo', 'slug' => 'foo']);
|
Post::create(['text' => 'Foo', 'slug' => 'foo']);
|
||||||
$data = ['text' => 'Foo 2', 'slug' => 'foo'];
|
$data = ['text' => 'Foo 2', 'slug' => 'foo'];
|
||||||
|
|
||||||
$uniqueFails = Validator::make($data, [
|
$uniqueValidator = Validator::make($data, [
|
||||||
'slug' => 'unique:posts',
|
'slug' => 'unique:posts',
|
||||||
])->fails();
|
]);
|
||||||
$existsFails = Validator::make($data, [
|
$existsValidator= Validator::make($data, [
|
||||||
'slug' => 'exists:posts',
|
'slug' => 'exists:posts',
|
||||||
])->fails();
|
]);
|
||||||
|
|
||||||
// Assert that 'unique' and 'exists' aren't scoped by default
|
// Assert that 'unique' and 'exists' aren't scoped by default
|
||||||
// pest()->assertFalse($uniqueFails); // todo get these two assertions to pass. for some reason, the validator is passing for both 'unique' and 'exists'
|
expect($uniqueValidator->fails())->toBeTrue() // Expect unique rule failed to pass because slug 'foo' already exists
|
||||||
// pest()->assertTrue($existsFails); // todo get these two assertions to pass. for some reason, the validator is passing for both 'unique' and 'exists'
|
->and($existsValidator->passes())->toBeTrue(); // Expect exists rule pass because slug 'foo' exists
|
||||||
|
|
||||||
$uniqueFails = Validator::make($data, [
|
$uniqueFails = Validator::make($data, [
|
||||||
'slug' => tenant()->unique('posts'),
|
'slug' => tenant()->unique('posts'),
|
||||||
|
|
@ -223,9 +223,9 @@ test('the model returned by the tenant helper has unique and exists validation r
|
||||||
])->fails();
|
])->fails();
|
||||||
|
|
||||||
// Assert that tenant()->unique() and tenant()->exists() are scoped
|
// Assert that tenant()->unique() and tenant()->exists() are scoped
|
||||||
expect($uniqueFails)->toBeTrue();
|
expect($uniqueFails)->toBeTrue()
|
||||||
expect($existsFails)->toBeFalse();
|
->and($existsFails)->toBeFalse();
|
||||||
});
|
})->group('roles');
|
||||||
|
|
||||||
// todo@tests
|
// todo@tests
|
||||||
function primaryModelsScopedToCurrentTenant()
|
function primaryModelsScopedToCurrentTenant()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue