Completed
Pull Request — master (#12)
by
unknown
03:19
created

testPasswordResetRequestGetsHandled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 22
rs 9.2
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Tests\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\Command\RequestPasswordReset;
6
use SumoCoders\FrameworkMultiUserBundle\Command\PasswordResetRequestHandler;
7
use SumoCoders\FrameworkMultiUserBundle\Event\OnPasswordResetTokenCreated;
8
use SumoCoders\FrameworkMultiUserBundle\User\InMemoryUserRepository;
9
use SumoCoders\FrameworkMultiUserBundle\User\UserRepositoryCollection;
10
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
11
12
class PasswordResetRequestHandlerTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var UserRepository
16
     */
17
    private $userRepository;
18
19
    /**
20
     * @var UserRepositoryCollection
21
     */
22
    private $userRepositoryCollection;
23
24
    public function setUp()
25
    {
26
        $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...
27
        $this->userRepositoryCollection = new UserRepositoryCollection([$this->userRepository]);
28
    }
29
30
    /**
31
     * Test if CreateUserHandler gets handled.
32
     */
33
    public function testPasswordResetRequestGetsHandled()
34
    {
35
        $listener = $this->getMockBuilder(OnPasswordResetTokenCreated::class)
36
            ->disableOriginalConstructor()
37
            ->getMock();
38
39
        $dispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)
40
            ->disableOriginalConstructor()
41
            ->getMock();
42
        $dispatcherMock->method('addListener');
43
44
        $handler = new PasswordResetRequestHandler(
45
            $this->userRepositoryCollection,
46
            $dispatcherMock,
47
            $listener
48
        );
49
50
        $user = $this->userRepository->findByUsername('wouter');
51
        $event = new RequestPasswordReset($user);
52
53
        $this->assertNull($handler->handle($event));
54
    }
55
}
56