Skip to content

Commit

Permalink
Added unit test for ImportConnector::getProvider().
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Feb 2, 2022
1 parent 749f410 commit fe50a38
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ final class FixtureFactory
public static function buildImportConnector(
Connector $connector,
RecoverableExceptionHandler $recoverableExceptionHandler = null,
Provider $provider = null,
int $maxFetchAttempts = ImportSpecification::DEFAULT_FETCH_ATTEMPTS,
bool $mustCache = false,
Provider $provider = null
bool $mustCache = false
): ImportConnector {
return new ImportConnector(
$provider ?? \Mockery::mock(Provider::class),
Expand Down
3 changes: 3 additions & 0 deletions test/Functional/ThrottlePrecedenceHierarchyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ final class ThrottlePrecedenceHierarchyTest extends AsyncTestCase
use MockeryPHPUnitIntegration;

private $specificationThrottle;

private $connectorThrottle;

private $specification;

private $provider;

protected function setUp(): void
Expand Down
18 changes: 17 additions & 1 deletion test/Unit/Connector/ImportConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Connector\ImportConnector;
use ScriptFUSION\Porter\Connector\Recoverable\RecoverableExceptionHandler;
use ScriptFUSION\Porter\Provider\Provider;
use ScriptFUSIONTest\FixtureFactory;

/**
Expand Down Expand Up @@ -74,6 +75,7 @@ public function testFetchCacheEnabled(): void
->andReturn($output = 'foo')
->getMock(),
null,
null,
1,
true
);
Expand Down Expand Up @@ -108,7 +110,7 @@ public function testFetchCacheEnabledButNotAvailable(): void
{
$this->expectException(CacheUnavailableException::class);

FixtureFactory::buildImportConnector(\Mockery::mock(Connector::class), null, 1, true);
FixtureFactory::buildImportConnector(\Mockery::mock(Connector::class), null, null, 1, true);
}

/**
Expand Down Expand Up @@ -151,4 +153,18 @@ public function testFindBaseConnector(): void

self::assertSame($baseConnector, $connector->findBaseConnector());
}

/**
* Tests that the provider passed to the constructor can be retrieved via a getter.
*/
public function testGetProvider(): void
{
$connector = FixtureFactory::buildImportConnector(
\Mockery::mock(Connector::class),
null,
$provider = \Mockery::mock(Provider::class)
);

self::assertSame($provider, $connector->getProvider());
}
}

0 comments on commit fe50a38

Please sign in to comment.