|
6 | 6 | use Amp\Iterator; |
7 | 7 | use Amp\Loop; |
8 | 8 | use Amp\Producer; |
| 9 | +use ScriptFUSION\Porter\Connector\AsyncConnector; |
| 10 | +use ScriptFUSION\Porter\Connector\ConnectorOptions; |
| 11 | +use ScriptFUSION\Porter\ForeignResourceException; |
9 | 12 | use ScriptFUSION\Porter\ImportException; |
10 | 13 | use ScriptFUSION\Porter\IncompatibleProviderException; |
11 | 14 | use ScriptFUSION\Porter\Porter; |
12 | | -use ScriptFUSION\Porter\Provider\AsyncProvider; |
13 | 15 | use ScriptFUSION\Porter\Provider\Provider; |
14 | 16 | use ScriptFUSION\Porter\Specification\AsyncImportSpecification; |
15 | 17 | use ScriptFUSION\Porter\Transform\FilterTransformer; |
| 18 | +use ScriptFUSIONTest\MockFactory; |
16 | 19 |
|
17 | 20 | /** |
18 | 21 | * @see Porter |
@@ -67,6 +70,30 @@ public function testImportIncompatibleProvider(): \Generator |
67 | 70 | yield $this->porter->importAsync($this->specification->setProviderName($providerName)); |
68 | 71 | } |
69 | 72 |
|
| 73 | + /** |
| 74 | + * Tests that when a resource's provider class name does not match the provider an exception is thrown. |
| 75 | + */ |
| 76 | + public function testImportForeignResource(): \Generator |
| 77 | + { |
| 78 | + // Replace existing provider with a different one. |
| 79 | + $this->registerProvider(MockFactory::mockProvider(), \get_class($this->provider)); |
| 80 | + |
| 81 | + $this->expectException(ForeignResourceException::class); |
| 82 | + yield $this->porter->importAsync($this->specification); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Tests that when importing using a connector that exports options, but no clone method, an exception is thrown. |
| 87 | + */ |
| 88 | + public function testImportConnectorWithOptions(): void |
| 89 | + { |
| 90 | + $this->provider->shouldReceive('getAsyncConnector') |
| 91 | + ->andReturn(\Mockery::mock(AsyncConnector::class, ConnectorOptions::class)); |
| 92 | + |
| 93 | + $this->expectException(\LogicException::class); |
| 94 | + $this->porter->importAsync($this->specification); |
| 95 | + } |
| 96 | + |
70 | 97 | /** |
71 | 98 | * Tests that a stack of async filter transformers are applied correctly. |
72 | 99 | * The order is deterministic because filters yield immediately. |
|
0 commit comments