Skip to content

Commit 9b71bdd

Browse files
committed
Added testImportOneOfManyAsync test case.
1 parent 56b9d03 commit 9b71bdd

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/Integration/Porter/PorterAsyncTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Amp\Iterator;
77
use Amp\Loop;
88
use Amp\Producer;
9+
use ScriptFUSION\Porter\ImportException;
910
use ScriptFUSION\Porter\Porter;
1011
use ScriptFUSION\Porter\Specification\AsyncImportSpecification;
1112
use ScriptFUSION\Porter\Transform\FilterTransformer;
@@ -22,6 +23,9 @@ protected function setUp(): void
2223
$this->specification = new AsyncImportSpecification($this->resource);
2324
}
2425

26+
/**
27+
* Tests that the full async import path, via connector, resource and provider, fetches a record correctly.
28+
*/
2529
public function testImportAsync(): \Generator
2630
{
2731
$records = $this->porter->importAsync($this->specification);
@@ -30,11 +34,25 @@ public function testImportAsync(): \Generator
3034
self::assertSame(['foo'], $records->getCurrent());
3135
}
3236

37+
/**
38+
* Tests that the full async import path, via connector, resource and provider, fetches one record correctly.
39+
*/
3340
public function testImportOneAsync(): \Generator
3441
{
3542
self::assertSame(['foo'], yield $this->porter->importOneAsync($this->specification));
3643
}
3744

45+
/**
46+
* Tests that when importOne receives multiple records from a resource, an exception is thrown.
47+
*/
48+
public function testImportOneOfManyAsync(): \Generator
49+
{
50+
$this->resource->shouldReceive('fetchAsync')->andReturn(Iterator\fromIterable([['foo'], ['bar']]));
51+
52+
$this->expectException(ImportException::class);
53+
yield $this->porter->importOneAsync($this->specification);
54+
}
55+
3856
/**
3957
* Tests that a stack of async filter transformers are applied correctly.
4058
* The order is deterministic because filters yield immediately.

0 commit comments

Comments
 (0)