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
Pull Request — master (#556)
by Evgenij
02:53
created

ConfiguredContextFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 74
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testCreateSerializationContext() 0 29 2
B contextConfigDataProvider() 0 27 1
1
<?php
2
3
namespace JMS\SerializerBundle\Tests\ContextFactory;
4
5
use JMS\Serializer\Context;
6
use JMS\SerializerBundle\ContextFactory\ConfiguredContextFactory;
7
8
/**
9
 * Class ConfiguredContextFactoryTest
10
 */
11
class ConfiguredContextFactoryTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * testCreateSerializationContext
15
     *
16
     * @param string $version
17
     * @param bool   $serializeNulls
18
     * @param array  $attributes
19
     * @param array  $groups
20
     * @param string $expectedInterface
21
     * @param string $expectedContextClass
22
     * @param string $factoryMethod
23
     *
24
     * @return void
25
     * @dataProvider contextConfigDataProvider
26
     */
27
    public function testCreateSerializationContext(
28
        $version,
29
        $serializeNulls,
30
        array $attributes,
31
        array $groups,
32
        $expectedInterface,
33
        $expectedContextClass,
34
        $factoryMethod
35
    ) {
36
        $object = new ConfiguredContextFactory();
37
38
        $object->setVersion($version);
39
        $object->setSerializeNulls($serializeNulls);
40
        $object->setGroups($groups);
41
        $object->setAttributes($attributes);
42
43
        $this->assertInstanceOf($expectedInterface, $object);
44
45
        $context = $object->$factoryMethod();
46
        /** @var Context $context */
47
        $this->assertInstanceOf($expectedContextClass, $context);
48
        $this->assertSame($serializeNulls, $context->shouldSerializeNull());
49
50
        $this->assertSame($version, $context->attributes->get('version')->get());
51
        $this->assertSame($groups, $context->attributes->get('groups')->get());
52
        foreach ($attributes as $k => $v) {
53
            $this->assertSame($v, $context->attributes->get($k)->get());
54
        }
55
    }
56
57
    public function contextConfigDataProvider()
58
    {
59
        return [
60
            [
61
                sprintf('%d.%d.%d', mt_rand(1, 10), mt_rand(1, 10), mt_rand(1, 10)),
62
                true,
63
                [
64
                    'x' => mt_rand(0, PHP_INT_MAX),
65
                ],
66
                [ 'Default', 'Registration' ],
67
                'JMS\Serializer\ContextFactory\SerializationContextFactoryInterface',
68
                'JMS\Serializer\SerializationContext',
69
                'createSerializationContext'
70
            ],
71
            [
72
                sprintf('%d.%d.%d', mt_rand(1, 10), mt_rand(1, 10), mt_rand(1, 10)),
73
                true,
74
                [
75
                    'x' => mt_rand(0, PHP_INT_MAX),
76
                ],
77
                [ 'Default', 'Registration' ],
78
                'JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface',
79
                'JMS\Serializer\DeserializationContext',
80
                'createDeserializationContext'
81
            ],
82
        ];
83
    }
84
}
85