continue()) { self::assertSame(\array_shift($expected), $value); } } /** * @depends testConcat */ public function testConcatWithFailedPipeline(): void { $exception = new TestException; $expected = \range(1, 6); $generator = new AsyncGenerator(static function () use ($exception) { yield 6; // Emit once before failing. throw $exception; }); $pipeline = Pipeline\concat([ Pipeline\fromIterable(\range(1, 5)), $generator, Pipeline\fromIterable(\range(7, 10)), ]); try { while (null !== $value = $pipeline->continue()) { self::assertSame(\array_shift($expected), $value); } self::fail("The exception used to fail the pipeline should be thrown from continue()"); } catch (TestException $reason) { self::assertSame($exception, $reason); } self::assertEmpty($expected); } public function testNonPipeline(): void { $this->expectException(\TypeError::class); /** @noinspection PhpParamsInspection */ Pipeline\concat([1]); } }