@@ 25-100 (lines=76) @@ | ||
22 | use InvalidArgumentException; |
|
23 | use Mockery as m; |
|
24 | ||
25 | class FilterTest extends TestCase |
|
26 | { |
|
27 | public function testInstanceOf() |
|
28 | { |
|
29 | $flow = new Filter(function () { |
|
30 | return true; |
|
31 | }); |
|
32 | ||
33 | static::assertInstanceOf(FlowInterface::class, $flow); |
|
34 | } |
|
35 | ||
36 | public function testInvalidInputThrowsAnException() |
|
37 | { |
|
38 | $file = m::mock(NodeInterface::class); |
|
39 | $flow = new Filter(function () { |
|
40 | }); |
|
41 | ||
42 | $this->expectException(InvalidArgumentException::class); |
|
43 | ||
44 | $flow->flow($file); |
|
45 | } |
|
46 | ||
47 | public function testFlow() |
|
48 | { |
|
49 | $func = function () use (&$called) { |
|
50 | $called = true; |
|
51 | return true; |
|
52 | }; |
|
53 | $flow = new Filter($func); |
|
54 | ||
55 | $node = m::mock(NodeCollectionInterface::class); |
|
56 | $node->shouldReceive('filter') |
|
57 | ->with($func) |
|
58 | ->andReturn($node); |
|
59 | ||
60 | $response = $flow->flow($node); |
|
61 | ||
62 | static::assertSame($response, $node); |
|
63 | } |
|
64 | ||
65 | public function testStaticFlow() |
|
66 | { |
|
67 | $func = function () use (&$called) { |
|
68 | $called = true; |
|
69 | return true; |
|
70 | }; |
|
71 | $flow = Flow::filter($func); |
|
72 | ||
73 | $node = m::mock(NodeCollectionInterface::class); |
|
74 | $node->shouldReceive('filter') |
|
75 | ->with($func) |
|
76 | ->andReturn($node); |
|
77 | ||
78 | $response = $flow->flow($node); |
|
79 | ||
80 | static::assertSame($response, $node); |
|
81 | } |
|
82 | ||
83 | public function callInvokeFlow() |
|
84 | { |
|
85 | $func = function () use (&$called) { |
|
86 | $called = true; |
|
87 | return true; |
|
88 | }; |
|
89 | $flow = Flow::filter($func); |
|
90 | ||
91 | $node = m::mock(NodeCollectionInterface::class); |
|
92 | $node->shouldReceive('filter') |
|
93 | ->with($func) |
|
94 | ->andReturn($node); |
|
95 | ||
96 | $response = call_user_func($flow, $node); |
|
97 | ||
98 | static::assertSame($response, $node); |
|
99 | } |
|
100 | } |
|
101 |
@@ 25-100 (lines=76) @@ | ||
22 | use InvalidArgumentException; |
|
23 | use Mockery as m; |
|
24 | ||
25 | class FirstTest extends TestCase |
|
26 | { |
|
27 | public function testInstanceOf() |
|
28 | { |
|
29 | $flow = new First(function () { |
|
30 | return true; |
|
31 | }); |
|
32 | ||
33 | static::assertInstanceOf(FlowInterface::class, $flow); |
|
34 | } |
|
35 | ||
36 | public function testInvalidInputThrowsAnException() |
|
37 | { |
|
38 | $file = m::mock(NodeInterface::class); |
|
39 | $flow = new First(function () { |
|
40 | }); |
|
41 | ||
42 | $this->expectException(InvalidArgumentException::class); |
|
43 | ||
44 | $flow->flow($file); |
|
45 | } |
|
46 | ||
47 | public function testFlow() |
|
48 | { |
|
49 | $func = function () use (&$called) { |
|
50 | $called = true; |
|
51 | return true; |
|
52 | }; |
|
53 | $flow = new First($func); |
|
54 | ||
55 | $node = m::mock(NodeCollectionInterface::class); |
|
56 | $node->shouldReceive('first') |
|
57 | ->with($func) |
|
58 | ->andReturn($node); |
|
59 | ||
60 | $response = $flow->flow($node); |
|
61 | ||
62 | static::assertSame($response, $node); |
|
63 | } |
|
64 | ||
65 | public function testStaticFlow() |
|
66 | { |
|
67 | $func = function () use (&$called) { |
|
68 | $called = true; |
|
69 | return true; |
|
70 | }; |
|
71 | $flow = Flow::first($func); |
|
72 | ||
73 | $node = m::mock(NodeCollectionInterface::class); |
|
74 | $node->shouldReceive('first') |
|
75 | ->with($func) |
|
76 | ->andReturn($node); |
|
77 | ||
78 | $response = $flow->flow($node); |
|
79 | ||
80 | static::assertSame($response, $node); |
|
81 | } |
|
82 | ||
83 | public function testInvokeFlow() |
|
84 | { |
|
85 | $func = function () use (&$called) { |
|
86 | $called = true; |
|
87 | return true; |
|
88 | }; |
|
89 | $flow = Flow::first($func); |
|
90 | ||
91 | $node = m::mock(NodeCollectionInterface::class); |
|
92 | $node->shouldReceive('first') |
|
93 | ->with($func) |
|
94 | ->andReturn($node); |
|
95 | ||
96 | $response = call_user_func($flow, $node); |
|
97 | ||
98 | static::assertSame($response, $node); |
|
99 | } |
|
100 | } |
|
101 |
@@ 25-100 (lines=76) @@ | ||
22 | use InvalidArgumentException; |
|
23 | use Mockery as m; |
|
24 | ||
25 | class LastTest extends TestCase |
|
26 | { |
|
27 | public function testInstanceOf() |
|
28 | { |
|
29 | $flow = new Last(function () { |
|
30 | return true; |
|
31 | }); |
|
32 | ||
33 | static::assertInstanceOf(FlowInterface::class, $flow); |
|
34 | } |
|
35 | ||
36 | public function testInvalidInputThrowsAnException() |
|
37 | { |
|
38 | $file = m::mock(NodeInterface::class); |
|
39 | $flow = new Last(function () { |
|
40 | }); |
|
41 | ||
42 | $this->expectException(InvalidArgumentException::class); |
|
43 | ||
44 | $flow->flow($file); |
|
45 | } |
|
46 | ||
47 | public function testFlow() |
|
48 | { |
|
49 | $func = function () use (&$called) { |
|
50 | $called = true; |
|
51 | return true; |
|
52 | }; |
|
53 | $flow = new Last($func); |
|
54 | ||
55 | $node = m::mock(NodeCollectionInterface::class); |
|
56 | $node->shouldReceive('last') |
|
57 | ->with($func) |
|
58 | ->andReturn($node); |
|
59 | ||
60 | $response = $flow->flow($node); |
|
61 | ||
62 | static::assertSame($response, $node); |
|
63 | } |
|
64 | ||
65 | public function testStaticFlow() |
|
66 | { |
|
67 | $func = function () use (&$called) { |
|
68 | $called = true; |
|
69 | return true; |
|
70 | }; |
|
71 | $flow = Flow::last($func); |
|
72 | ||
73 | $node = m::mock(NodeCollectionInterface::class); |
|
74 | $node->shouldReceive('last') |
|
75 | ->with($func) |
|
76 | ->andReturn($node); |
|
77 | ||
78 | $response = $flow->flow($node); |
|
79 | ||
80 | static::assertSame($response, $node); |
|
81 | } |
|
82 | ||
83 | public function testInvokeFlow() |
|
84 | { |
|
85 | $func = function () use (&$called) { |
|
86 | $called = true; |
|
87 | return true; |
|
88 | }; |
|
89 | $flow = Flow::last($func); |
|
90 | ||
91 | $node = m::mock(NodeCollectionInterface::class); |
|
92 | $node->shouldReceive('last') |
|
93 | ->with($func) |
|
94 | ->andReturn($node); |
|
95 | ||
96 | $response = call_user_func($flow, $node); |
|
97 | ||
98 | static::assertSame($response, $node); |
|
99 | } |
|
100 | } |
|
101 |