Completed
Pull Request — master (#80)
by John
07:45 queued 02:38
created

SerializationTypeResolverTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 4
c 3
b 2
f 0
lcom 1
cbo 2
dl 0
loc 41
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A canResolveTypesInOrderUsingMultipleNamespaces() 0 4 1
A canReverseLookupPreviouslyResolvedType() 0 5 1
A reverseLookupWillFailIfNotPreviouslyResolved() 0 4 1
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Tests\Serialize;
10
11
use KleijnWeb\SwaggerBundle\Serialize\SerializationTypeResolver;
12
13
/**
14
 * @author John Kleijn <[email protected]>
15
 */
16
class SerializationTypeResolverTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @var SerializationTypeResolver
20
     */
21
    private $resolver;
22
23
    protected function setUp()
24
    {
25
        $this->resolver = new SerializationTypeResolver([
26
            'KleijnWeb\SwaggerBundle\Tests\Serialize\Stubs\Namespace2',
27
            'KleijnWeb\SwaggerBundle\Tests\Serialize\Stubs\Namespace1'
28
        ]);
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function canResolveTypesInOrderUsingMultipleNamespaces()
35
    {
36
        $this->assertSame(Stubs\Namespace2\Foo::class, $this->resolver->resolveUsingTypeName('Foo'));
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function canReverseLookupPreviouslyResolvedType()
43
    {
44
        $this->resolver->resolveUsingTypeName('Foo');
45
        $this->assertSame('Foo', $this->resolver->reverseLookup(Stubs\Namespace2\Foo::class));
46
    }
47
48
    /**
49
     * @test
50
     * @expectedException \InvalidArgumentException
51
     */
52
    public function reverseLookupWillFailIfNotPreviouslyResolved()
53
    {
54
        $this->assertSame('Foo', $this->resolver->reverseLookup(Stubs\Namespace2\Foo::class));
55
    }
56
}
57