Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
109 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter; | ||
|
||
/** | ||
* The exception that is thrown when an object could not be created. | ||
*/ | ||
class ObjectNotCreatedException extends \RuntimeException | ||
{ | ||
// Intentionally empty. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter\Provider; | ||
|
||
use ScriptFUSION\Porter\ObjectNotCreatedException; | ||
|
||
class ProviderFactory | ||
{ | ||
public function createProvider($name) | ||
{ | ||
switch ($name) { | ||
case StaticDataProvider::class: | ||
return new StaticDataProvider; | ||
} | ||
|
||
throw new ObjectNotCreatedException("Factory does not know how to create: \"$name\"."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter; | ||
|
||
use Exception; | ||
|
||
final class ProviderNotFoundException extends \RuntimeException | ||
{ | ||
// Intentionally empty. | ||
public function __construct($message, Exception $previous = null) | ||
{ | ||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
src/Porter/ImportSpecification.php → ...ter/Specification/ImportSpecification.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Porter/Specification/StaticDataImportSpecification.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter\Specification; | ||
|
||
use ScriptFUSION\Porter\Provider\StaticData; | ||
|
||
class StaticDataImportSpecification extends ImportSpecification | ||
{ | ||
public function __construct(\Iterator $data) | ||
{ | ||
parent::__construct(new StaticData($data)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace ScriptFUSIONTest\Functional; | ||
|
||
use ScriptFUSION\Porter\Porter; | ||
use ScriptFUSION\Porter\Specification\StaticDataImportSpecification; | ||
|
||
final class StaticDataTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function test() | ||
{ | ||
$records = (new Porter)->import(new StaticDataImportSpecification(new \ArrayIterator(['foo']))); | ||
|
||
$this->assertSame('foo', $records->current()); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
test/Unit/Porter/PorterTest.php → test/Integration/Porter/PorterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
test/Integration/Porter/Provider/StaticDataProviderTest.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace ScriptFUSIONTest\Unit\Porter\Connector; | ||
|
||
use ScriptFUSION\Porter\Connector\NullConnector; | ||
|
||
final class NullConnectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function test() | ||
{ | ||
$this->assertNull((new NullConnector)->fetch('foo')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters