Completed
Push — master ( 7c00aa...d8aae5 )
by Ivannis Suárez
19:41
created

ValidatorMiddlewareTests   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 43
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testHandle() 0 37 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Bus\Tests\Units\Middlewares\Validator;
13
14
use Cubiche\Core\Bus\Middlewares\Validator\ValidatorMiddleware;
15
use Cubiche\Core\Bus\Tests\Fixtures\Message\LoginUserMessage;
16
use Cubiche\Core\Bus\Tests\Fixtures\Message\LogoutUserMessage;
17
use Cubiche\Core\Bus\Tests\Units\TestCase;
18
use Cubiche\Core\Validator\Exception\ValidationException;
19
20
/**
21
 * ValidatorMiddleware class.
22
 *
23
 * Generated by TestGenerator on 2016-04-11 at 15:18:25.
24
 */
25
class ValidatorMiddlewareTests extends TestCase
26
{
27
    /**
28
     * Test handle method.
29
     */
30
    public function testHandle()
31
    {
32
        $this
33
            ->given($middleware = new ValidatorMiddleware())
34
            ->and($command = new LoginUserMessage('[email protected]', 'plainpassword'))
0 ignored issues
show
Unused Code introduced by
The call to LoginUserMessage::__construct() has too many arguments starting with 'plainpassword'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
35
            ->and($callable = function (LoginUserMessage $command) {
36
                $command->setEmail('[email protected]');
37
            })
38
            ->when($middleware->handle($command, $callable))
39
            ->then()
40
                ->string($command->email())
41
                    ->isEqualTo('[email protected]')
42
        ;
43
44
        $this
45
            ->given($middleware = new ValidatorMiddleware())
46
            ->and($command = new LoginUserMessage('invalid.email.com', 'plainpassword'))
0 ignored issues
show
Unused Code introduced by
The call to LoginUserMessage::__construct() has too many arguments starting with 'plainpassword'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
47
            ->and($callable = function () {
48
            })
49
            ->then()
50
                ->exception(function () use ($middleware, $command, $callable) {
51
                    $middleware->handle($command, $callable);
52
                })->isInstanceOf(ValidationException::class)
53
        ;
54
55
        $this
56
            ->given($middleware = new ValidatorMiddleware())
57
            ->and($command = new LogoutUserMessage('invalid.email.com'))
58
            ->and($callable = function (LogoutUserMessage $command) {
59
                $command->setEmail('[email protected]');
60
            })
61
            ->when($middleware->handle($command, $callable))
62
            ->then()
63
                ->string($command->email())
64
                    ->isEqualTo('[email protected]')
65
        ;
66
    }
67
}
68