Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added resource type parameter to Provider::getConnector #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Bilge marked this conversation as resolved.
Show resolved Hide resolved
* @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