Skip to content

Commit 7c16a70

Browse files
committed
Added missing ImportSpecification tests.
1 parent 6d16020 commit 7c16a70

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

test/Integration/Porter/Connector/CachingConnectorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Mockery\MockInterface;
66
use ScriptFUSION\Porter\Connector\CachingConnector;
77
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
8-
use ScriptFUSIONTest\Porter\Options\TestOptions;
8+
use ScriptFUSIONTest\Stubs\TestOptions;
99

1010
final class CachingConnectorTest extends \PHPUnit_Framework_TestCase
1111
{

test/Stubs/Invokable.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Stubs;
3+
4+
final class Invokable
5+
{
6+
public function __invoke()
7+
{
8+
// Inteiontionally empty.
9+
}
10+
}

test/Porter/Options/TestOptions.php renamed to test/Stubs/TestOptions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace ScriptFUSIONTest\Porter\Options;
2+
namespace ScriptFUSIONTest\Stubs;
33

44
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
55

test/Unit/Porter/ImportSpecificationTest.php

+41-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use ScriptFUSION\Porter\Specification\DuplicateTransformerException;
77
use ScriptFUSION\Porter\Specification\ImportSpecification;
88
use ScriptFUSION\Porter\Transform\Transformer;
9+
use ScriptFUSIONTest\Stubs\Invokable;
910

1011
final 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,37 @@ public function testCacheAdvice()
97102
$this->specification->setCacheAdvice($advice)->getCacheAdvice()
98103
);
99104
}
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+
}
100138
}

test/Unit/Porter/Options/EncapsulatedOptionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace ScriptFUSIONTest\Unit\Porter\Options;
33

4-
use ScriptFUSIONTest\Porter\Options\TestOptions;
4+
use ScriptFUSIONTest\Stubs\TestOptions;
55

66
final class EncapsulatedOptionsTest extends \PHPUnit_Framework_TestCase
77
{

0 commit comments

Comments
 (0)