Skip to content

Commit

Permalink
Added resource type parameter to Provider::getConnector.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Nov 6, 2017
1 parent 61f6432 commit 4be5207
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Collection/RecordCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class RecordCollection implements \Iterator

private $previousCollection;

public function __construct(\Iterator $records, RecordCollection $previousCollection = null)
public function __construct(\Iterator $records, self $previousCollection = null)
{
$this->records = $records;
$this->previousCollection = $previousCollection;
Expand Down
1 change: 1 addition & 0 deletions src/Connector/CachingConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct(
}

/**
* @param ConnectionContext $context
* @param string $source
* @param EncapsulatedOptions|null $options
*
Expand Down
2 changes: 1 addition & 1 deletion src/Porter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function fetch(ProviderResource $resource, $providerName, ConnectionCont
}

$records = $resource->fetch(
new ImportConnector($provider->getConnector(), $context),
new ImportConnector($provider->getConnector(get_class($resource)), $context),
$provider instanceof ProviderOptions ? clone $provider->getOptions() : null
);

Expand Down
8 changes: 5 additions & 3 deletions src/Provider/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
use ScriptFUSION\Porter\Connector\Connector;

/**
* Provides a method for accessing a connector.
* Provides a method for getting a connector.
*/
interface Provider
{
/**
* Gets a connector for accessing resource data.
* Gets a connector for fetching resource data.
*
* @param string $resourceType The resource type from which data will be fetched.
*
* @return Connector
*/
public function getConnector();
public function getConnector($resourceType);
}
2 changes: 1 addition & 1 deletion src/Provider/StaticDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct()
$this->connector = new NullConnector;
}

public function getConnector()
public function getConnector($resourceType)
{
return $this->connector;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/Porter/PorterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function setUp()
$this->porter = new Porter($this->container = \Mockery::spy(ContainerInterface::class));

$this->registerProvider($this->provider = MockFactory::mockProvider());
$this->connector = $this->provider->getConnector();
$this->connector = $this->provider->getConnector('');
$this->resource = MockFactory::mockResource($this->provider);
$this->specification = new ImportSpecification($this->resource);
}
Expand Down
3 changes: 2 additions & 1 deletion test/MockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public static function mockProvider()
{
return \Mockery::namedMock(uniqid(Provider::class, false), Provider::class)
->shouldReceive('getConnector')
->with(\Mockery::type('string'))
->andReturn(
\Mockery::mock(Connector::class)
->shouldReceive('fetch')
->andReturn('foo')
->getMock()
->byDefault()
->getMock()
)
->getMock()
;
Expand Down

0 comments on commit 4be5207

Please sign in to comment.