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

JsonSerializerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testJsonFormatDeserialization() 0 6 1
A testMediaTypeSupport() 0 6 1
A testJsonFormatSerialization() 0 8 1
A getSerializer() 0 3 1
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