Skip to content

Commit

Permalink
Fix etl
Browse files Browse the repository at this point in the history
  • Loading branch information
leomarquine committed Oct 31, 2018
1 parent b124eb2 commit 988ac40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/Etl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
14 changes: 8 additions & 6 deletions tests/EtlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 */
Expand Down

0 comments on commit 988ac40

Please sign in to comment.