Completed
Pull Request — master (#12)
by
unknown
05:50 queued 03:06
created

PasswordResetRequestHandlerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 2
c 4
b 0
f 2
lcom 1
cbo 6
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testPasswordResetRequestGetsHandled() 0 17 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Tests\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\Command\RequestPasswordReset;
6
use SumoCoders\FrameworkMultiUserBundle\Command\RequestPasswordResetHandler;
7
use SumoCoders\FrameworkMultiUserBundle\User\InMemoryUserRepository;
8
use SumoCoders\FrameworkMultiUserBundle\User\UserRepositoryCollection;
9
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
10
11
class PasswordResetRequestHandlerTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var UserRepository
15
     */
16
    private $userRepository;
17
18
    /**
19
     * @var UserRepositoryCollection
20
     */
21
    private $userRepositoryCollection;
22
23
    public function setUp()
24
    {
25
        $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...
26
        $this->userRepositoryCollection = new UserRepositoryCollection([$this->userRepository]);
27
    }
28
29
    /**
30
     * Test if CreateUserHandler gets handled.
31
     */
32
    public function testPasswordResetRequestGetsHandled()
33
    {
34
        $dispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)
35
            ->disableOriginalConstructor()
36
            ->getMock();
37
        $dispatcherMock->method('addListener');
38
39
        $handler = new RequestPasswordResetHandler(
40
            $this->userRepositoryCollection,
41
            $dispatcherMock
42
        );
43
44
        $user = $this->userRepository->findByUsername('wouter');
45
        $event = new RequestPasswordReset($user);
46
47
        $this->assertNull($handler->handle($event));
48
    }
49
}
50