From 988ac40c704d443bafdf708687ee5caf4f4d336e Mon Sep 17 00:00:00 2001 From: Leonardo Marquine Date: Wed, 31 Oct 2018 18:30:27 -0300 Subject: [PATCH] Fix etl --- src/Etl.php | 8 ++------ tests/EtlTest.php | 14 ++++++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Etl.php b/src/Etl.php index df0652a..7cbc4f1 100644 --- a/src/Etl.php +++ b/src/Etl.php @@ -58,9 +58,7 @@ public function extract($extractor, $input, $options = []) { $extractor = $this->container->step($extractor, Extractor::class); - $options['input'] = $input; - - $extractor->options($options); + $extractor->input($input)->options($options); $this->pipeline->extractor($extractor); @@ -97,9 +95,7 @@ public function load($loader, $output, $options = []) { $loader = $this->container->step($loader, Loader::class); - $options['output'] = $output; - - $loader->options($options); + $loader->output($output)->options($options); $this->pipeline->pipe($loader); diff --git a/tests/EtlTest.php b/tests/EtlTest.php index b411ca7..1b7649b 100644 --- a/tests/EtlTest.php +++ b/tests/EtlTest.php @@ -11,7 +11,8 @@ class EtlTest extends TestCase public function extract_step() { $extractor = $this->createMock('Marquine\Etl\Extractors\Extractor'); - $extractor->expects($this->once())->method('options')->with(['option' => 'value', 'input' => 'input']); + $extractor->expects($this->once())->method('input')->with('input')->willReturnSelf(); + $extractor->expects($this->once())->method('options')->with(['options']); $container = $this->createMock('Marquine\Etl\Container'); $container->expects($this->once())->method('step')->with('step_name', 'Marquine\Etl\Extractors\Extractor')->willReturn($extractor); @@ -21,14 +22,14 @@ public function extract_step() $etl = new Etl($container, $pipeline); - $this->assertInstanceOf(Etl::class, $etl->extract('step_name', 'input', ['option' => 'value'])); + $this->assertInstanceOf(Etl::class, $etl->extract('step_name', 'input', ['options'])); } /** @test */ public function transform_step() { $transformer = $this->createMock('Marquine\Etl\Transformers\Transformer'); - $transformer->expects($this->once())->method('options')->with(['option' => 'value']); + $transformer->expects($this->once())->method('options')->with(['options']); $container = $this->createMock('Marquine\Etl\Container'); $container->expects($this->once())->method('step')->with('step_name', 'Marquine\Etl\Transformers\Transformer')->willReturn($transformer); @@ -38,14 +39,15 @@ public function transform_step() $etl = new Etl($container, $pipeline); - $this->assertInstanceOf(Etl::class, $etl->transform('step_name', ['option' => 'value'])); + $this->assertInstanceOf(Etl::class, $etl->transform('step_name', ['options'])); } /** @test */ public function load_step() { $loader = $this->createMock('Marquine\Etl\Loaders\Loader'); - $loader->expects($this->once())->method('options')->with(['option' => 'value', 'output' => 'output']); + $loader->expects($this->once())->method('output')->with('output')->willReturnSelf(); + $loader->expects($this->once())->method('options')->with(['options']); $container = $this->createMock('Marquine\Etl\Container'); $container->expects($this->once())->method('step')->with('step_name', 'Marquine\Etl\Loaders\Loader')->willReturn($loader); @@ -55,7 +57,7 @@ public function load_step() $etl = new Etl($container, $pipeline); - $this->assertInstanceOf(Etl::class, $etl->load('step_name', 'output', ['option' => 'value'])); + $this->assertInstanceOf(Etl::class, $etl->load('step_name', 'output', ['options'])); } /** @test */