Completed
Push — master ( 82d1fc...6f9908 )
by Ivannis Suárez
02:50 queued 29s
created

testCanHandlerVisitee()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
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 13
rs 9.4285
cc 1
eloc 10
nc 1
nop 3
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Cubiche\Core\Visitor\Tests\Units;
11
12
use Cubiche\Core\Visitor\DynamicDispatchVisitorInterface;
13
use Cubiche\Core\Visitor\VisiteeInterface;
14
15
/**
16
 * Dynamic Dispatch Visitor Interface Test Case Class.
17
 *
18
 * @author Karel Osorio Ramírez <[email protected]>
19
 */
20
abstract class DynamicDispatchVisitorInterfaceTestCase extends VisitorInterfaceTestCase
21
{
22
    /**
23
     * Test class.
24
     */
25
    public function testClass()
26
    {
27
        $this
28
            ->testedClass
29
                ->implements(DynamicDispatchVisitorInterface::class)
30
        ;
31
    }
32
33
    /**
34
     * Test visit method.
35
     *
36
     * @param DynamicDispatchVisitorInterface $visitor
37
     * @param VisiteeInterface                $visitee
38
     * @param string                          $visitorMethod
39
     * @param mixed                           $expected
40
     *
41
     * @dataProvider visitDataProvider
42
     */
43 View Code Duplication
    public function testVisit(
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...
44
        DynamicDispatchVisitorInterface $visitor,
45
        VisiteeInterface $visitee,
46
        $visitorMethod,
47
        $expected
48
    ) {
49
        $this
50
            ->given($visitor, $visitee)
51
            ->when($result = $visitor->visit($visitee))
52
            ->then()
53
                ->mock($visitor)
54
                    ->call($visitorMethod)
55
                        ->withArguments($visitee)
56
                            ->once()
57
                ->variable($result)
58
                    ->isEqualTo($expected);
59
    }
60
61
    /**
62
     * Test canHandlerVisitee method.
63
     *
64
     * @param DynamicDispatchVisitorInterface $visitor
65
     * @param VisiteeInterface                $visitee
66
     * @param bool                            $expected
67
     *
68
     * @dataProvider canHandlerVisiteeDataProvider
69
     */
70
    public function testCanHandlerVisitee(
71
        DynamicDispatchVisitorInterface $visitor,
72
        VisiteeInterface $visitee,
73
        $expected
74
    ) {
75
        $this
76
            ->given($visitor, $visitee)
77
            ->when($result = $visitor->canHandlerVisitee($visitee))
78
            ->then()
79
                ->boolean($result)
80
                    ->isEqualTo($expected)
81
        ;
82
    }
83
84
    /**
85
     * @return array
86
     */
87
    abstract protected function visitDataProvider();
88
89
    /**
90
     * @return array
91
     */
92
    abstract protected function canHandlerVisiteeDataProvider();
93
}
94