Completed
Pull Request — master (#12)
by
unknown
02:53
created

PasswordResetRequestHandlerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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\RouterInterface;
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();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \SumoCoders\Framewor...nMemoryUserRepository() of type object<SumoCoders\Framew...InMemoryUserRepository> is incompatible with the declared type object<SumoCoders\Framew...Command\UserRepository> of property $userRepository.

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..

Loading history...
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(RouterInterface::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