ResourceMapperTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A getEntityManagerMappingMissing() 0 4 1
A newResourceMapper() 0 4 1
A getEntityManagerName() 0 13 1
A getObjectName() 0 11 1
1
<?php
2
3
namespace Managlea\Tests;
4
5
6
use Managlea\Component\ResourceMapper;
7
use Managlea\Component\ResourceMapperInterface;
8
9
class ResourceMapperTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var ResourceMapperInterface
13
     */
14
    private $resourceMapper;
15
16
    public function setUp()
17
    {
18
        $this->resourceMapper = new ResourceMapper;
19
    }
20
21
    /**
22
     * @test
23
     * @expectedException \Exception
24
     */
25
    public function getEntityManagerMappingMissing()
26
    {
27
        $this->resourceMapper->getEntityManagerName('foo');
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function newResourceMapper()
34
    {
35
        $this->assertTrue($this->resourceMapper instanceof ResourceMapperInterface);
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function getEntityManagerName()
42
    {
43
        // Get default EntityManager
44
        $entityManager = $this->resourceMapper->getEntityManagerName('bar');
45
        $this->assertEquals($entityManager, 'DoctrineEntityManager');
46
47
        $entityManager = $this->resourceMapper->getEntityManagerName('baz');
48
        $this->assertEquals($entityManager, 'DoctrineEntityManager');
49
50
        // Get customer EntityManager
51
        $entityManager = $this->resourceMapper->getEntityManagerName('zoo');
52
        $this->assertEquals($entityManager, 'Zoo');
53
    }
54
55
    /**
56
     * @test
57
     */
58
    public function getObjectName()
59
    {
60
        $entityManager = $this->resourceMapper->getObjectName('bar');
61
        $this->assertEquals($entityManager, 'Entities\Product');
62
63
        $entityManager = $this->resourceMapper->getObjectName('baz');
64
        $this->assertEquals($entityManager, 'baz');
65
66
        $entityManager = $this->resourceMapper->getObjectName('zoo');
67
        $this->assertEquals($entityManager, 'Entities\Product');
68
    }
69
}
70