48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\User;
|
|
use App\Policies\Frontend\CustomerPolicy;
|
|
|
|
covers(CustomerPolicy::class);
|
|
|
|
describe('CustomerPolicy', function () {
|
|
describe('manageOwnProfile', function () {
|
|
it('returns false when user is a User instance', function () {
|
|
// GIVEN
|
|
$policy = new CustomerPolicy();
|
|
$user = \Mockery::mock(User::class);
|
|
|
|
// WHEN
|
|
$result = $policy->manageOwnProfile($user);
|
|
|
|
// THEN
|
|
expect($result)->toBeFalse();
|
|
});
|
|
|
|
it('returns true when user is a Customer instance', function () {
|
|
// GIVEN
|
|
$policy = new CustomerPolicy();
|
|
$customer = \Mockery::mock(Customer::class);
|
|
|
|
// WHEN
|
|
$result = $policy->manageOwnProfile($customer);
|
|
|
|
// THEN
|
|
expect($result)->toBeTrue();
|
|
});
|
|
|
|
it('returns false when user is null', function () {
|
|
// GIVEN
|
|
$policy = new CustomerPolicy();
|
|
|
|
// WHEN
|
|
$result = $policy->manageOwnProfile(null);
|
|
|
|
// THEN
|
|
expect($result)->toBeFalse();
|
|
});
|
|
});
|
|
});
|