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

HandlerContainerTest::testInvalidHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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