6
6
use ScriptFUSION \Porter \Specification \DuplicateTransformerException ;
7
7
use ScriptFUSION \Porter \Specification \ImportSpecification ;
8
8
use ScriptFUSION \Porter \Transform \Transformer ;
9
+ use ScriptFUSIONTest \Stubs \Invokable ;
9
10
10
11
final class ImportSpecificationTest extends \PHPUnit_Framework_TestCase
11
12
{
@@ -26,7 +27,10 @@ public function testClone()
26
27
{
27
28
$ this ->specification
28
29
->addTransformer (\Mockery::mock (Transformer::class))
29
- ->setContext ($ context = (object )[]);
30
+ ->setContext ($ context = (object )[])
31
+ ->setFetchExceptionHandler ($ handler = new Invokable )
32
+ ;
33
+
30
34
$ specification = clone $ this ->specification ;
31
35
32
36
self ::assertNotSame ($ this ->resource , $ specification ->getResource ());
@@ -42,6 +46,7 @@ public function testClone()
42
46
self ::assertCount (count ($ this ->specification ->getTransformers ()), $ specification ->getTransformers ());
43
47
44
48
self ::assertNotSame ($ context , $ specification ->getContext ());
49
+ self ::assertNotSame ($ handler , $ specification ->getFetchExceptionHandler ());
45
50
}
46
51
47
52
public function testProviderData ()
@@ -79,10 +84,10 @@ public function testAddTransformers()
79
84
80
85
public function testAddSameTransformer ()
81
86
{
82
- $ this ->specification ->addTransformer ($ transformer1 = \Mockery::mock (Transformer::class));
87
+ $ this ->specification ->addTransformer ($ transformer = \Mockery::mock (Transformer::class));
83
88
84
89
$ this ->setExpectedException (DuplicateTransformerException::class);
85
- $ this ->specification ->addTransformer ($ transformer1 );
90
+ $ this ->specification ->addTransformer ($ transformer );
86
91
}
87
92
88
93
public function testContext ()
@@ -97,4 +102,37 @@ public function testCacheAdvice()
97
102
$ this ->specification ->setCacheAdvice ($ advice )->getCacheAdvice ()
98
103
);
99
104
}
105
+
106
+ /**
107
+ * @param mixed $input
108
+ * @param int $output
109
+ *
110
+ * @dataProvider provideFetchAttempts
111
+ */
112
+ public function testMaxFetchAttempts ($ input , $ output )
113
+ {
114
+ self ::assertSame ($ output , $ this ->specification ->setMaxFetchAttempts ($ input )->getMaxFetchAttempts ());
115
+ }
116
+
117
+ public function provideFetchAttempts ()
118
+ {
119
+ return [
120
+ // Valid.
121
+ [1 , 1 ],
122
+ [2 , 2 ],
123
+
124
+ // Invalid.
125
+ 'Too low, positive ' => [0 , 1 ],
126
+ 'Too low, negative ' => [-1 , 1 ],
127
+ 'Float in range ' => [1.9 , 1 ],
128
+ ];
129
+ }
130
+
131
+ public function testExceptionHandler ()
132
+ {
133
+ self ::assertSame (
134
+ $ handler = new Invokable ,
135
+ $ this ->specification ->setFetchExceptionHandler ($ handler )->getFetchExceptionHandler ()
136
+ );
137
+ }
100
138
}
0 commit comments