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.

contextConfigDataProvider()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace JMS\SerializerBundle\Tests\ContextFactory;
4
5
use JMS\Serializer\Context;
6
use JMS\SerializerBundle\ContextFactory\ConfiguredContextFactory;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Class ConfiguredContextFactoryTest
11
 */
12
class ConfiguredContextFactoryTest extends TestCase
13
{
14
    /**
15
     * testCreateSerializationContext
16
     *
17
     * @param string $version
18
     * @param bool $serializeNulls
19
     * @param array $attributes
20
     * @param array $groups
21
     * @param string $expectedInterface
22
     * @param string $expectedContextClass
23
     * @param string $factoryMethod
24
     *
25
     * @return void
26
     * @dataProvider contextConfigDataProvider
27
     */
28
    public function testCreateSerializationContext(
29
        $version,
30
        $serializeNulls,
31
        array $attributes,
32
        array $groups,
33
        $expectedInterface,
34
        $expectedContextClass,
35
        $factoryMethod
36
    )
37
    {
38
        $object = new ConfiguredContextFactory();
39
40
        $object->setVersion($version);
41
        $object->setSerializeNulls($serializeNulls);
42
        $object->setGroups($groups);
43
        $object->setAttributes($attributes);
44
45
        $this->assertInstanceOf($expectedInterface, $object);
46
47
        $context = $object->$factoryMethod();
48
        /** @var Context $context */
49
        $this->assertInstanceOf($expectedContextClass, $context);
50
        $this->assertSame($serializeNulls, $context->shouldSerializeNull());
51
52
        $this->assertSame($version, $context->attributes->get('version')->get());
53
        $this->assertSame($groups, $context->attributes->get('groups')->get());
54
        foreach ($attributes as $k => $v) {
55
            $this->assertSame($v, $context->attributes->get($k)->get());
56
        }
57
    }
58
59
    public function testMaxDepthExclusionStrategy()
60
    {
61
        $object = new ConfiguredContextFactory();
62
63
        $object->enableMaxDepthChecks();
64
65
        $context = $object->createDeserializationContext();
66
        $this->assertInstanceOf('JMS\Serializer\Exclusion\DepthExclusionStrategy', $context->getExclusionStrategy());
67
68
        $context = $object->createDeserializationContext();
69
        $this->assertInstanceOf('JMS\Serializer\Exclusion\DepthExclusionStrategy', $context->getExclusionStrategy());
70
    }
71
72
    public function contextConfigDataProvider()
73
    {
74
        return [
75
            [
76
                sprintf('%d.%d.%d', mt_rand(1, 10), mt_rand(1, 10), mt_rand(1, 10)),
77
                true,
78
                [
79
                    'x' => mt_rand(0, PHP_INT_MAX),
80
                ],
81
                ['Default', 'Registration'],
82
                'JMS\Serializer\ContextFactory\SerializationContextFactoryInterface',
83
                'JMS\Serializer\SerializationContext',
84
                'createSerializationContext'
85
            ],
86
            [
87
                sprintf('%d.%d.%d', mt_rand(1, 10), mt_rand(1, 10), mt_rand(1, 10)),
88
                true,
89
                [
90
                    'x' => mt_rand(0, PHP_INT_MAX),
91
                ],
92
                ['Default', 'Registration'],
93
                'JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface',
94
                'JMS\Serializer\DeserializationContext',
95
                'createDeserializationContext'
96
            ],
97
        ];
98
    }
99
}
100