Completed
Pull Request — master (#10)
by
unknown
02:54
created

CreateUserHandlerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCreateUserGetsHandled() 0 21 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Tests\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\Command\CreateUser;
6
use SumoCoders\FrameworkMultiUserBundle\Command\CreateUserHandler;
7
use SumoCoders\FrameworkMultiUserBundle\User\InMemoryUserRepository;
8
9
class CreateUserHandlerTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var UserRepository
13
     */
14
    private $userRepository;
15
16
    public function setUp()
17
    {
18
        $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...
19
    }
20
21
    /**
22
     * Test if CreateUserHandler gets handled.
23
     */
24
    public function testCreateUserGetsHandled()
25
    {
26
        $handler = new CreateUserHandler($this->userRepository);
27
28
        $user = new CreateUser('sumo', 'randomPassword', 'sumocoders');
29
30
        $handler->handle($user);
31
32
        $this->assertEquals(
33
            'sumo',
34
            $this->userRepository->findByUsername('sumo')->getUsername()
35
        );
36
        $this->assertEquals(
37
            'sumocoders',
38
            $this->userRepository->findByUsername('sumo')->getDisplayName()
39
        );
40
        $this->assertEquals(
41
            'randomPassword',
42
            $this->userRepository->findByUsername('sumo')->getPassword()
43
        );
44
    }
45
}
46