ChainTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testResponseInFirstChain() 0 5 1
A testResponseInSecondChain() 0 5 1
A testResponseWithoutSuccess() 0 5 1
A create() 0 9 2
1
<?php
2
3
namespace ChainableTest;
4
5
use Chainable\Handler\ChainHandler;
6
use ChainableTest\Fixtures\ResponseA;
7
use ChainableTest\Fixtures\ResponseB;
8
9
class ChainTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testResponseInFirstChain()
12
    {
13
        $chainHandler = $this->create([new ResponseA(), new ResponseB()]);
14
        $this->assertEquals('A', $chainHandler->process('A'));
15
    }
16
17
    public function testResponseInSecondChain()
18
    {
19
        $chainHandler = $this->create([new ResponseA(), new ResponseB()]);
20
        $this->assertEquals('B', $chainHandler->process('B'));
21
    }
22
23
    public function testResponseWithoutSuccess()
24
    {
25
        $chainHandler = $this->create([new ResponseA(), new ResponseB()]);
26
        $this->assertNull($chainHandler->process('C'));
27
    }
28
29
    private function create($chains)
30
    {
31
        $chainHandler = new ChainHandler();
32
        foreach ($chains as $chain) {
33
            $chainHandler->append($chain);
34
        }
35
36
        return $chainHandler;
37
    }
38
}
39