1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SumoCoders\FrameworkMultiUserBundle\Tests\Command; |
4
|
|
|
|
5
|
|
|
use SumoCoders\FrameworkMultiUserBundle\Command\PasswordResetRequest; |
6
|
|
|
use SumoCoders\FrameworkMultiUserBundle\Command\PasswordResetRequestHandler; |
7
|
|
|
use SumoCoders\FrameworkMultiUserBundle\User\InMemoryUserRepository; |
8
|
|
|
use SumoCoders\FrameworkMultiUserBundle\User\UserRepositoryCollection; |
9
|
|
|
use Swift_Mailer; |
10
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
11
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
12
|
|
|
|
13
|
|
|
class PasswordResetRequestHandlerTest extends \PHPUnit_Framework_TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var UserRepository |
17
|
|
|
*/ |
18
|
|
|
private $userRepository; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var UserRepositoryCollection |
22
|
|
|
*/ |
23
|
|
|
private $userRepositoryCollection; |
24
|
|
|
|
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
$this->userRepository = new InMemoryUserRepository(); |
|
|
|
|
28
|
|
|
$this->userRepositoryCollection = new UserRepositoryCollection([$this->userRepository]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Test if CreateUserHandler gets handled. |
33
|
|
|
*/ |
34
|
|
|
public function testPasswordResetRequestGetsHandled() |
35
|
|
|
{ |
36
|
|
|
$mailerMock = $this->getMockBuilder(Swift_Mailer::class) |
37
|
|
|
->disableOriginalConstructor() |
38
|
|
|
->getMock(); |
39
|
|
|
$mailerMock->method('send')->willReturn(1); |
40
|
|
|
|
41
|
|
|
$translatorMock = $this->getMockBuilder(TranslatorInterface::class)->getMock(); |
42
|
|
|
|
43
|
|
|
$routerMock = $this->getMockBuilder(UrlGeneratorInterface::class) |
44
|
|
|
->disableOriginalConstructor() |
45
|
|
|
->getMock(); |
46
|
|
|
|
47
|
|
|
$handler = new PasswordResetRequestHandler($this->userRepositoryCollection, $mailerMock, $translatorMock, $routerMock); |
48
|
|
|
|
49
|
|
|
$user = $this->userRepository->findByUsername('wouter'); |
50
|
|
|
$event = new PasswordResetRequest($user); |
51
|
|
|
|
52
|
|
|
$this->assertEquals(1, $handler->handle($event)); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..