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 (#1)
by Pascal
04:06
created

testJsonFormatDeserialization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saikootau\ApiBundle\Tests\Serializer;
6
7
use JMS\Serializer\SerializerBuilder;
8
use PHPUnit\Framework\TestCase;
9
use Saikootau\ApiBundle\Serializer\JsonSerializer;
10
use Saikootau\ApiBundle\MediaType\MediaTypes;
11
use Saikootau\ApiBundle\Tests\Serializer\Asset\Person;
12
13
class JsonSerializerTest extends TestCase
14
{
15
    public function testMediaTypeSupport(): void
16
    {
17
        $serializer = new JsonSerializer($this->getSerializer());
18
        $this->assertEquals('json', $serializer->getSupportedFormat());
19
        $this->assertContains(MediaTypes::TYPE_APPLICATION_JSON, $serializer->getSupportedMediaTypes());
20
        $this->assertSame(MediaTypes::TYPE_APPLICATION_JSON, $serializer->getContentType());
21
    }
22
23
    public function testJsonFormatSerialization(): void
24
    {
25
        $expectedSerialization = '{"name":"tester","gender":"male"}';
26
        $person = new Person();
27
        $person->name = 'tester';
28
        $person->gender = 'male';
29
        $serializer = new JsonSerializer($this->getSerializer());
30
        $this->assertEquals($expectedSerialization, $serializer->serialize($person));
31
    }
32
33
    public function testJsonFormatDeserialization(): void
34
    {
35
        $document = '{"name":"tester","gender":"male"}';
36
        $serializer = new JsonSerializer($this->getSerializer());
37
        $person = $serializer->deserialize($document, Person::class);
38
        $this->assertInstanceOf(Person::class, $person);
39
    }
40
41
    private function getSerializer()
42
    {
43
        return SerializerBuilder::create()->build();
44
    }
45
}
46