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.
Completed
Push — master ( 48aa34...e9e817 )
by Mario
29:19 queued 01:50
created

FieldHandlerRegistryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 15 1
A testAddingHandlers() 0 5 1
A testItReturnsProperHandler() 0 19 1
A testItReturnsNullWhenSupportedHandlerNotFound() 0 8 1
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler;
4
5
use eZ\Publish\Core\FieldType\Integer\Value as TestValue;
6
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomFieldHandlerInterface;
7
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\FieldHandlerRegistry;
8
use PHPUnit\Framework\TestCase;
9
10
class FieldHandlerRegistryTest extends TestCase
11
{
12
    /**
13
     * @var FieldHandlerRegistry
14
     */
15
    protected $registry;
16
17
    /**
18
     * @var \PHPUnit_Framework_MockObject_MockObject
19
     */
20
    protected $customHandler1;
21
22
    /**
23
     * @var \PHPUnit_Framework_MockObject_MockObject
24
     */
25
    protected $customHandler2;
26
27
    public function setUp()
28
    {
29
        $this->registry = new FieldHandlerRegistry();
30
        $this->customHandler1 = $this->getMockBuilder(CustomFieldHandlerInterface::class)
31
            ->disableOriginalConstructor()
32
            ->setMethods(array('supports', 'toString'))
33
            ->getMock();
34
35
        $this->customHandler2 = $this->getMockBuilder(CustomFieldHandlerInterface::class)
36
            ->disableOriginalConstructor()
37
            ->setMethods(array('supports', 'toString'))
38
            ->getMock();
39
40
        parent::setUp();
41
    }
42
43
    public function testAddingHandlers()
44
    {
45
        $this->registry->addHandler($this->customHandler1);
46
        $this->registry->addHandler($this->customHandler2);
47
    }
48
49
    public function testItReturnsProperHandler()
50
    {
51
        $value = new TestValue(2);
52
53
        $this->registry->addHandler($this->customHandler1);
54
        $this->registry->addHandler($this->customHandler2);
55
56
        $this->customHandler1->expects($this->once())
57
            ->method('supports')
58
            ->willReturn(false);
59
60
        $this->customHandler2->expects($this->once())
61
            ->method('supports')
62
            ->willReturn(true);
63
64
        $handler = $this->registry->handle($value);
65
66
        $this->assertSame($this->customHandler2, $handler);
67
    }
68
69
    public function testItReturnsNullWhenSupportedHandlerNotFound()
70
    {
71
        $value = new TestValue(2);
72
73
        $handler = $this->registry->handle($value);
74
75
        $this->assertNull($handler);
76
    }
77
}
78