Completed
Branch master (8bfcf4)
by Tomasz
02:29
created

HandlerContainerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAlias() 0 11 1
A testAliasForInvalidClass() 0 6 1
A testInvalidHandler() 0 6 1
1
<?php
2
namespace Thunder\Serializard\Tests;
3
use Thunder\Serializard\HandlerContainer\HandlerContainer;
4
5
/**
6
 * @author Tomasz Kowalczyk <[email protected]>
7
 */
8
class HandlerContainerTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testAlias()
11
    {
12
        $handlers = new HandlerContainer();
13
        $handlers->add('stdClass', 'std', function() {
14
            return 'value';
15
        });
16
        $handlers->addAlias('DateTime', 'stdClass');
17
18
        $this->assertSame('value', call_user_func_array($handlers->getHandler('stdClass'), array()));
19
        $this->assertSame('value', call_user_func_array($handlers->getHandler('DateTime'), array()));
20
    }
21
22
    public function testAliasForInvalidClass()
23
    {
24
        $this->setExpectedException('RuntimeException');
25
        $handlers = new HandlerContainer();
26
        $handlers->addAlias('stdClass', 'DateTime');
27
    }
28
29
    public function testInvalidHandler()
30
    {
31
        $this->setExpectedException('RuntimeException');
32
        $handlers = new HandlerContainer();
33
        $handlers->add('stdClass', 'name', 'invalid');
34
    }
35
}
36