ResourceMapperTest::getObjectName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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