From fe50a3801bd4d9348683c3f2ab7db5447f81fff7 Mon Sep 17 00:00:00 2001 From: Bilge Date: Wed, 2 Feb 2022 16:06:59 +0000 Subject: [PATCH] Added unit test for ImportConnector::getProvider(). --- test/FixtureFactory.php | 4 ++-- .../ThrottlePrecedenceHierarchyTest.php | 3 +++ test/Unit/Connector/ImportConnectorTest.php | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/test/FixtureFactory.php b/test/FixtureFactory.php index 0f00e68..10dfc58 100644 --- a/test/FixtureFactory.php +++ b/test/FixtureFactory.php @@ -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), diff --git a/test/Functional/ThrottlePrecedenceHierarchyTest.php b/test/Functional/ThrottlePrecedenceHierarchyTest.php index b9ee1e8..d5d2882 100644 --- a/test/Functional/ThrottlePrecedenceHierarchyTest.php +++ b/test/Functional/ThrottlePrecedenceHierarchyTest.php @@ -25,8 +25,11 @@ final class ThrottlePrecedenceHierarchyTest extends AsyncTestCase use MockeryPHPUnitIntegration; private $specificationThrottle; + private $connectorThrottle; + private $specification; + private $provider; protected function setUp(): void diff --git a/test/Unit/Connector/ImportConnectorTest.php b/test/Unit/Connector/ImportConnectorTest.php index cb53f66..0954dd7 100644 --- a/test/Unit/Connector/ImportConnectorTest.php +++ b/test/Unit/Connector/ImportConnectorTest.php @@ -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; /** @@ -74,6 +75,7 @@ public function testFetchCacheEnabled(): void ->andReturn($output = 'foo') ->getMock(), null, + null, 1, true ); @@ -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); } /** @@ -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()); + } }