GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (bd52da)
by Andrey
04:54 queued 01:45
created

ValidationMiddlewareTest::testHandleFailed()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
rs 9.2
cc 2
eloc 14
nc 3
nop 0
1
<?php
2
3
/**
4
 * (c) itmedia.by <[email protected]>
5
 */
6
7
namespace Itmedia\CommandBusBundle\Tests\Middleware;
8
9
use Doctrine\Common\Annotations\AnnotationReader;
10
use Doctrine\Common\Annotations\DocParser;
11
use Itmedia\CommandBusBundle\Exception\ValidationException;
12
use Itmedia\CommandBusBundle\Middleware\ValidationMiddleware;
13
use Itmedia\CommandBusBundle\Tests\Stub\TestCommand;
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\Validator\Constraints\Email;
16
use Symfony\Component\Validator\Validation;
17
use Symfony\Component\Validator\Constraints\NotBlank;
18
19
class ValidationMiddlewareTest extends TestCase
20
{
21
    public function testHandleFailed()
22
    {
23
        $this->loadConstraintsClass();
24
25
        $command = new TestCommand();
26
        $command->handle('Test', 'aaa');
27
28
29
        $validator = Validation::createValidatorBuilder()
30
            ->enableAnnotationMapping()
31
            ->getValidator();
32
33
        $middleware = new ValidationMiddleware($validator);
34
35
        try {
36
            $middleware->handle($command);
37
            $this->fail('Must throw ' . ValidationException::class);
38
        } catch (ValidationException $exception) {
39
            $this->assertArrayNotHasKey('username', $exception->getMessages());
40
            $this->assertArrayHasKey('email', $exception->getMessages());
41
        }
42
    }
43
44
45
    public function testHandleSuccess()
46
    {
47
        $this->loadConstraintsClass();
48
49
        $command = new TestCommand();
50
        $command->handle('Test', '[email protected]');
51
52
53
        $validator = Validation::createValidatorBuilder()
54
            ->enableAnnotationMapping()
55
            ->getValidator();
56
57
        $middleware = new ValidationMiddleware($validator);
58
59
        $middleware->handle($command);
60
    }
61
62
63
    private function loadConstraintsClass()
64
    {
65
        new NotBlank();
66
        new Email();
67
    }
68
}
69