Completed
Pull Request — master (#10)
by
unknown
05:51 queued 02:49
created

DeleteUserHandlerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testUpdateUserGetsHandled() 0 15 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Tests\Command;
4
5
use SumoCoders\FrameworkMultiUserBundle\Command\DeleteUser;
6
use SumoCoders\FrameworkMultiUserBundle\Command\DeleteUserHandler;
7
use SumoCoders\FrameworkMultiUserBundle\User\InMemoryUserRepository;
8
9
class DeleteUserHandlerTest extends \PHPUnit_Framework_TestCase
10
{
11
    private $userRepository;
12
13
    public function setUp()
14
    {
15
        $this->userRepository = new InMemoryUserRepository();
16
    }
17
18
    /**
19
     * Test if DeleteUserHandler gets handled.
20
     */
21
    public function testUpdateUserGetsHandled()
22
    {
23
        $handler = new DeleteUserHandler($this->userRepository);
24
25
        $deletingUser = $this->userRepository->findByUsername('wouter');
26
27
        $command = new DeleteUser($deletingUser);
0 ignored issues
show
Documentation introduced by
$deletingUser is of type object<Symfony\Component...ser\UserInterface>|null, but the function expects a object<SumoCoders\Framew...tiUserBundle\User\User>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29
        $handler->handle($command);
30
31
        $this->assertNotNull($deletingUser);
32
        $this->assertNull(
33
            $this->userRepository->findByUsername('wouter')
34
        );
35
    }
36
}
37