Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added StaticDataProvider and accompanying test.
- Loading branch information
Showing
5 changed files
with
66 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter\Connector; | ||
|
||
class NullConnector implements Connector | ||
{ | ||
public function fetch($destination, array $parameters = []) | ||
{ | ||
// 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,24 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter\Provider; | ||
|
||
use ScriptFUSION\Porter\Connector\Connector; | ||
|
||
class StaticData implements ProviderData | ||
{ | ||
private $data; | ||
|
||
public function __construct(\Iterator $data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
public function getProviderName() | ||
{ | ||
return StaticDataProvider::class; | ||
} | ||
|
||
public function fetch(Connector $connector) | ||
{ | ||
return $this->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,12 @@ | ||
<?php | ||
namespace ScriptFUSION\Porter\Provider; | ||
|
||
use ScriptFUSION\Porter\Connector\NullConnector; | ||
|
||
class StaticDataProvider extends Provider | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(new NullConnector); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/Integration/Porter/Provider/StaticDataProviderTest.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,18 @@ | ||
<?php | ||
namespace ScriptFUSIONTest\Integration\Porter\Provider; | ||
|
||
use ScriptFUSION\Porter\ImportSpecification; | ||
use ScriptFUSION\Porter\Porter; | ||
use ScriptFUSION\Porter\Provider\StaticData; | ||
use ScriptFUSION\Porter\Provider\StaticDataProvider; | ||
|
||
final class StaticDataProviderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function test() | ||
{ | ||
$porter = (new Porter)->addProvider(new StaticDataProvider); | ||
$records = $porter->import(new ImportSpecification(new StaticData(new \ArrayIterator(['foo'])))); | ||
|
||
$this->assertSame('foo', $records->current()); | ||
} | ||
} |