Skip to content

Commit

Permalink
Add Job tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leomarquine committed Sep 2, 2017
1 parent 50633a0 commit 0896b06
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/JobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Tests;

use Marquine\Etl\Job;
use Marquine\Etl\Loaders\LoaderInterface ;
use Marquine\Etl\Extractors\ExtractorInterface;
use Marquine\Etl\Transformers\TransformerInterface;

class JobTest extends TestCase
{
/** @test */
function extract()
{
$job = new Job;

$extractor = new class implements ExtractorInterface {
public $property;
public $called = false;
public function extract($source) { $this->called = true; }
};

$job->extract($extractor, 'source', ['property' => 'value']);

$this->assertTrue($extractor->called);
$this->assertEquals($extractor->property, 'value');
}

/** @test */
function transform()
{
$job = new Job;

$transformer = new class implements TransformerInterface {
public $property;
public $called = false;
public function transform($items) { $this->called = true; }
};

$job->transform($transformer, ['property' => 'value']);

$this->assertTrue($transformer->called);
$this->assertEquals($transformer->property, 'value');
}

/** @test */
function load()
{
$job = new Job;

$loader = new class implements LoaderInterface {
public $property;
public $called = false;
public function load($destination, $items) { $this->called = true; }
};

$job->load($loader, 'destination', ['property' => 'value']);

$this->assertTrue($loader->called);
$this->assertEquals($loader->property, 'value');
}
}

0 comments on commit 0896b06

Please sign in to comment.