|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\UserBundle\Provider; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Bundle\UserBundle\Provider\AbstractUserProvider; |
|
18
|
|
|
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface; |
|
19
|
|
|
use Sylius\Component\User\Model\User; |
|
20
|
|
|
use Sylius\Component\User\Repository\UserRepositoryInterface; |
|
21
|
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface; |
|
22
|
|
|
|
|
23
|
|
|
final class EmailProviderSpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function let(UserRepositoryInterface $userRepository, CanonicalizerInterface $canonicalizer): void |
|
26
|
|
|
{ |
|
27
|
|
|
$this->beConstructedWith(User::class, $userRepository, $canonicalizer); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
function it_implements_symfony_user_provider_interface(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldImplement(UserProviderInterface::class); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_should_extend_user_provider(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->shouldHaveType(AbstractUserProvider::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_supports_sylius_user_model(): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->supportsClass(User::class)->shouldReturn(true); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_loads_user_by_email( |
|
46
|
|
|
UserRepositoryInterface $userRepository, |
|
47
|
|
|
CanonicalizerInterface $canonicalizer, |
|
48
|
|
|
User $user |
|
49
|
|
|
): void { |
|
50
|
|
|
$canonicalizer->canonicalize('[email protected]')->willReturn('[email protected]'); |
|
51
|
|
|
|
|
52
|
|
|
$userRepository->findOneByEmail('[email protected]')->willReturn($user); |
|
53
|
|
|
|
|
54
|
|
|
$this->loadUserByUsername('[email protected]')->shouldReturn($user); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
function it_updates_user_by_user_name(UserRepositoryInterface $userRepository, User $user): void |
|
58
|
|
|
{ |
|
59
|
|
|
$userRepository->find(1)->willReturn($user); |
|
60
|
|
|
|
|
61
|
|
|
$user->getId()->willReturn(1); |
|
62
|
|
|
|
|
63
|
|
|
$this->refreshUser($user)->shouldReturn($user); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|