Completed
Pull Request — master (#20)
by Wachter
08:03
created

TaskHandlerFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 7 1
A testCreateNotExists() 0 8 1
A testCreateNoHandler() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\Tests\Unit\Handler;
13
14
use Task\Handler\TaskHandlerInterface;
15
use Task\Handler\TaskHandlerNotExistsException;
16
use Task\TaskBundle\Handler\TaskHandlerFactory;
17
use Task\TaskBundle\Tests\Functional\TestHandler;
18
19
/**
20
 * Tests for class TaskHandlerFactory.
21
 */
22
class TaskHandlerFactoryTest extends \PHPUnit_Framework_TestCase
23
{
24
    public function testCreate()
25
    {
26
        $handler = new TestHandler();
27
        $taskHandlerFactory = new TaskHandlerFactory([TestHandler::class => $handler]);
28
29
        $this->assertEquals($handler, $taskHandlerFactory->create(TestHandler::class));
30
    }
31
32
    public function testCreateNotExists()
33
    {
34
        $this->setExpectedException(TaskHandlerNotExistsException::class);
35
36
        $taskHandlerFactory = new TaskHandlerFactory([TestHandler::class => new TestHandler()]);
37
38
        $taskHandlerFactory->create(\stdClass::class);
39
    }
40
41
    public function testCreateNoHandler()
42
    {
43
        $this->setExpectedException(TaskHandlerNotExistsException::class);
44
45
        $taskHandlerFactory = new TaskHandlerFactory([]);
46
47
        $taskHandlerFactory->create(\stdClass::class);
48
    }
49
}
50