AbstractAdapterTest::testAdapter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the bee4/events package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2014
8
 * @author  Stephane HULARD <[email protected]>
9
 */
10
11
namespace Bee4\Events\Test\Units\Adapters;
12
13
/**
14
 * Check behaviour of an adapter
15
 */
16
abstract class AbstractAdapterTest extends \atoum
17
{
18
19
    protected $adapter;
20
21
    public function testAdapter()
22
    {
23
        $this
24
            ->given(
25
                $handler = function () {
26
                    echo "Youpi!";
27
                },
28
                $event = new \mock\Bee4\Events\EventInterface
29
            )
30
            ->when($this->adapter->add('name', $handler))
31
            ->output(function () use ($event) {
32
                $this->adapter->dispatch('name', $event);
33
            })
34
                ->isEqualTo("Youpi!");
35
    }
36
37 View Code Duplication
    public function testAdd()
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...
38
    {
39
        $this
40
            ->given($handler = function () {
41
                echo "Youpi!";
42
            })
43
            ->then
44
                ->array($this->adapter->get('name'))
45
                    ->hasSize(0)
46
            ->when($this->adapter->add('name', $handler))
47
            ->then
48
                ->array($this->adapter->get('name'))
49
                    ->hasSize(1);
50
    }
51
52
53 View Code Duplication
    public function testRemove()
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...
54
    {
55
        $this
56
            ->given(
57
                $handler = function () {
58
                    echo "Youpi!";
59
                },
60
                $this->adapter->add('name', $handler)
61
            )
62
            ->then
63
                ->array($this->adapter->get('name'))
64
                    ->hasSize(1)
65
            ->when($this->adapter->remove('name', $handler))
66
            ->then
67
                ->array($this->adapter->get('name'))
68
                    ->hasSize(0);
69
    }
70
}
71