Completed
Push — master ( b587fb...d05392 )
by David
20:34
created

CollectorTest::testResetAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Http\HttplugBundle\Tests\Unit\Collector;
4
5
use Http\HttplugBundle\Collector\Collector;
6
use Http\HttplugBundle\Collector\Stack;
7
use PHPUnit\Framework\TestCase;
8
9
class CollectorTest extends TestCase
10
{
11
    public function testCollectClientNames()
12
    {
13
        $collector = new Collector();
14
15
        $collector->addStack(new Stack('default', 'GET / HTTP/1.1'));
16
        $collector->addStack(new Stack('acme', 'GET / HTTP/1.1'));
17
        $collector->addStack(new Stack('acme', 'GET / HTTP/1.1'));
18
19
        $this->assertEquals(['default', 'acme'], $collector->getClients());
20
    }
21
22 View Code Duplication
    public function testActivateStack()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $parent = new Stack('acme', 'GET / HTTP/1.1');
25
        $stack = new Stack('acme', 'GET / HTTP/1.1');
26
27
        $collector = new Collector();
28
29
        $collector->activateStack($parent);
30
        $collector->activateStack($stack);
31
32
        $this->assertEquals($parent, $stack->getParent());
33
        $this->assertEquals($stack, $collector->getActiveStack());
34
    }
35
36 View Code Duplication
    public function testDeactivateStack()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $stack = new Stack('acme', 'GET / HTTP/1.1');
39
        $collector = new Collector();
40
41
        $collector->activateStack($stack);
42
        $this->assertNotNull($collector->getActiveStack());
43
44
        $collector->deactivateStack($stack);
45
        $this->assertNull($collector->getActiveStack());
46
    }
47
48 View Code Duplication
    public function testDeactivateStackSetParentAsActiveStack()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $parent = new Stack('acme', 'GET / HTTP/1.1');
51
        $stack = new Stack('acme', 'GET / HTTP/1.1');
52
53
        $collector = new Collector();
54
55
        $collector->activateStack($parent);
56
        $collector->activateStack($stack);
57
        $collector->deactivateStack($stack);
58
59
        $this->assertEquals($parent, $collector->getActiveStack());
60
    }
61
62
    public function testAddStack()
63
    {
64
        $stack = new Stack('acme', 'GET / HTTP/1.1');
65
        $collector = new Collector();
66
67
        $collector->addStack($stack);
68
69
        $this->assertEquals(['acme'], $collector->getClients());
70
        $this->assertEquals([$stack], $collector->getClientRootStacks('acme'));
71
    }
72
73 View Code Duplication
    public function testResetAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        $stack = new Stack('acme', 'GET / HTTP/1.1');
76
77
        $collector = new Collector();
78
        $collector->addStack($stack);
79
        $collector->activateStack($stack);
80
81
        $collector->reset();
82
83
        $this->assertNull($collector->getActiveStack());
84
        $this->assertEmpty($collector->getStacks());
85
    }
86
}
87