RunTest::testStaticInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 20
loc 20
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of graze/data-flow
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-flow/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-flow
12
 */
13
14
namespace Graze\DataFlow\Test\Unit\Runner;
15
16
use Graze\DataFlow\Flow;
17
use Graze\DataFlow\Flow\FlowCollection;
18
use Graze\DataFlow\Flow\Runner\Run;
19
use Graze\DataFlow\FlowInterface;
20
use Graze\DataFlow\Test\TestCase;
21
use Graze\DataNode\NodeInterface;
22
use Mockery as m;
23
24
class RunTest extends TestCase
25
{
26
    public function testInstanceOf()
27
    {
28
        $runner = new Run();
29
        static::assertInstanceOf(FlowCollection::class, $runner);
30
        static::assertInstanceOf(FlowInterface::class, $runner);
31
    }
32
33 View Code Duplication
    public function testRunSequentially()
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...
34
    {
35
        $flow1 = m::mock(FlowInterface::class);
36
        $flow2 = m::mock(FlowInterface::class);
37
38
        $runner = new Run($flow1, $flow2);
39
40
        $node1 = m::mock(NodeInterface::class);
41
        $node2 = m::mock(NodeInterface::class);
42
        $node3 = m::mock(NodeInterface::class);
43
44
        $flow1->shouldReceive('flow')
45
              ->with($node1)
46
              ->andReturn($node2);
47
        $flow2->shouldReceive('flow')
48
              ->with($node2)
49
              ->andReturn($node3);
50
51
        static::assertEquals($node3, $runner->flow($node1));
52
    }
53
54 View Code Duplication
    public function testStaticInstance()
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...
55
    {
56
        $flow1 = m::mock(FlowInterface::class);
57
        $flow2 = m::mock(FlowInterface::class);
58
59
        $runner = Flow::run($flow1, $flow2);
0 ignored issues
show
Unused Code introduced by
The call to Flow::run() has too many arguments starting with $flow2.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
60
61
        $node1 = m::mock(NodeInterface::class);
62
        $node2 = m::mock(NodeInterface::class);
63
        $node3 = m::mock(NodeInterface::class);
64
65
        $flow1->shouldReceive('flow')
66
              ->with($node1)
67
              ->andReturn($node2);
68
        $flow2->shouldReceive('flow')
69
              ->with($node2)
70
              ->andReturn($node3);
71
72
        static::assertEquals($node3, $runner->flow($node1));
73
    }
74
75 View Code Duplication
    public function testInvokeFlow()
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...
76
    {
77
        $flow1 = m::mock(FlowInterface::class);
78
        $flow2 = m::mock(FlowInterface::class);
79
80
        $runner = Flow::run($flow1, $flow2);
0 ignored issues
show
Unused Code introduced by
The call to Flow::run() has too many arguments starting with $flow2.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
81
82
        $node1 = m::mock(NodeInterface::class);
83
        $node2 = m::mock(NodeInterface::class);
84
        $node3 = m::mock(NodeInterface::class);
85
86
        $flow1->shouldReceive('flow')
87
              ->with($node1)
88
              ->andReturn($node2);
89
        $flow2->shouldReceive('flow')
90
              ->with($node2)
91
              ->andReturn($node3);
92
93
        static::assertEquals($node3, call_user_func($runner, $node1));
94
    }
95
}
96