Skip to content

Commit

Permalink
Updated Throttle interface parity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Oct 23, 2022
1 parent 9d436ca commit f66687a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Connector/ImportConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function fetchAsync(AsyncDataSource $source): mixed
{
return retry(
$this->maxFetchAttempts,
fn () => $this->throttle->watch($this->connector->fetchAsync(...), $source),
fn () => $this->throttle->async($this->connector->fetchAsync(...), $source),
$this->createExceptionHandler()
);
}
Expand Down
12 changes: 6 additions & 6 deletions test/Functional/ThrottlePrecedenceHierarchyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ protected function setUp(): void
public function testNonThrottledConnector(): void
{
$this->specification->setThrottle($this->specificationThrottle);
$this->specificationThrottle->expects('watch')->once()->andReturn(Future::complete());
$this->connectorThrottle->expects('watch')->never();
$this->specificationThrottle->expects('async')->once()->andReturn(Future::complete());
$this->connectorThrottle->expects('async')->never();

$connector = ImportConnectorFactory::create(
$this->provider,
Expand All @@ -72,8 +72,8 @@ public function testNonThrottledConnector(): void
*/
public function testThrottledConnector(): void
{
$this->specificationThrottle->expects('watch')->never();
$this->connectorThrottle->expects('watch')->once()->andReturn(Future::complete());
$this->specificationThrottle->expects('async')->never();
$this->connectorThrottle->expects('async')->once()->andReturn(Future::complete());

$connector = ImportConnectorFactory::create(
$this->provider,
Expand All @@ -91,8 +91,8 @@ public function testThrottledConnector(): void
public function testThrottledConnectorOverride(): void
{
$this->specification->setThrottle($this->specificationThrottle);
$this->specificationThrottle->expects('watch')->once()->andReturn(Future::complete());
$this->connectorThrottle->expects('watch')->never();
$this->specificationThrottle->expects('async')->once()->andReturn(Future::complete());
$this->connectorThrottle->expects('async')->never();

$connector = ImportConnectorFactory::create(
$this->provider,
Expand Down
8 changes: 4 additions & 4 deletions test/Integration/Connector/ImportConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function testAsyncUserRecoverableExceptionHandler(): void
try {
$connector->fetchAsync($this->asyncSource);
} catch (\Exception $e) {
self::assertSame($exception, $e);
self::assertSame($exception, $e, $e->getMessage());
}
}

Expand All @@ -143,7 +143,7 @@ public function testAsyncResourceRecoverableExceptionHandler(): void
try {
$connector->fetchAsync($this->asyncSource);
} catch (\Exception $e) {
self::assertSame($exception, $e);
self::assertSame($exception, $e, $e->getMessage());
}
}

Expand All @@ -168,13 +168,13 @@ public function testAsyncUserAndResourceRecoverableExceptionHandlers(): void
try {
$connector->fetchAsync($this->asyncSource);
} catch (\Exception $exception) {
self::assertSame($e1, $exception);
self::assertSame($e1, $exception, $exception->getMessage());
}

try {
$connector->fetchAsync($this->asyncSource);
} catch (\Exception $exception) {
self::assertSame($e2, $exception);
self::assertSame($e2, $exception, $exception->getMessage());
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/MockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function mockSingleRecordResource(Provider $provider): ProviderRes
public static function mockThrottle(): Throttle|MockInterface
{
return \Mockery::mock(Throttle::class)
->allows('watch')
->allows('async')
->andReturnUsing(fn (\Closure $closure, mixed ...$args) => async($closure, ...$args))
->byDefault()
->getMock()
Expand Down

0 comments on commit f66687a

Please sign in to comment.