66use ScriptFUSION \Porter \Specification \DuplicateTransformerException ;
77use ScriptFUSION \Porter \Specification \ImportSpecification ;
88use ScriptFUSION \Porter \Transform \Transformer ;
9+ use ScriptFUSIONTest \Stubs \Invokable ;
910
1011final class ImportSpecificationTest extends \PHPUnit_Framework_TestCase
1112{
@@ -26,7 +27,10 @@ public function testClone()
2627 {
2728 $ this ->specification
2829 ->addTransformer (\Mockery::mock (Transformer::class))
29- ->setContext ($ context = (object )[]);
30+ ->setContext ($ context = (object )[])
31+ ->setFetchExceptionHandler ($ handler = new Invokable )
32+ ;
33+
3034 $ specification = clone $ this ->specification ;
3135
3236 self ::assertNotSame ($ this ->resource , $ specification ->getResource ());
@@ -42,6 +46,7 @@ public function testClone()
4246 self ::assertCount (count ($ this ->specification ->getTransformers ()), $ specification ->getTransformers ());
4347
4448 self ::assertNotSame ($ context , $ specification ->getContext ());
49+ self ::assertNotSame ($ handler , $ specification ->getFetchExceptionHandler ());
4550 }
4651
4752 public function testProviderData ()
@@ -79,10 +84,10 @@ public function testAddTransformers()
7984
8085 public function testAddSameTransformer ()
8186 {
82- $ this ->specification ->addTransformer ($ transformer1 = \Mockery::mock (Transformer::class));
87+ $ this ->specification ->addTransformer ($ transformer = \Mockery::mock (Transformer::class));
8388
8489 $ this ->setExpectedException (DuplicateTransformerException::class);
85- $ this ->specification ->addTransformer ($ transformer1 );
90+ $ this ->specification ->addTransformer ($ transformer );
8691 }
8792
8893 public function testContext ()
@@ -97,4 +102,34 @@ public function testCacheAdvice()
97102 $ this ->specification ->setCacheAdvice ($ advice )->getCacheAdvice ()
98103 );
99104 }
105+
106+ /**
107+ * @dataProvider provideFetchAttempts
108+ */
109+ public function testMaxFetchAttempts ($ input , $ output )
110+ {
111+ self ::assertSame ($ output , $ this ->specification ->setMaxFetchAttempts ($ input )->getMaxFetchAttempts ());
112+ }
113+
114+ public function provideFetchAttempts ()
115+ {
116+ return [
117+ // Valid.
118+ [1 , 1 ],
119+ [2 , 2 ],
120+
121+ // Invalid.
122+ 'Too low, positive ' => [0 , 1 ],
123+ 'Too low, negative ' => [-1 , 1 ],
124+ 'Float in range ' => [1.9 , 1 ],
125+ ];
126+ }
127+
128+ public function testExceptionHandler ()
129+ {
130+ self ::assertSame (
131+ $ handler = new Invokable ,
132+ $ this ->specification ->setFetchExceptionHandler ($ handler )->getFetchExceptionHandler ()
133+ );
134+ }
100135}
0 commit comments