-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50633a0
commit 0896b06
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |