1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Extraload\Pipeline; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Prophecy\Argument; |
7
|
|
|
use Extraload\Extractor\ExtractorInterface; |
8
|
|
|
use Extraload\Transformer\TransformerInterface; |
9
|
|
|
use Extraload\Loader\LoaderInterface; |
10
|
|
|
|
11
|
|
|
class DefaultPipelineSpec extends ObjectBehavior |
12
|
|
|
{ |
13
|
|
|
function let(ExtractorInterface $extractor, TransformerInterface $transformer, LoaderInterface $loader) |
14
|
|
|
{ |
15
|
|
|
$this->beConstructedWith($extractor, $transformer, $loader); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
function it_is_initializable() |
19
|
|
|
{ |
20
|
|
|
$this->shouldHaveType('Extraload\Pipeline\DefaultPipeline'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
function it_implements_pipeline_interface() |
24
|
|
|
{ |
25
|
|
|
$this->shouldImplement('Extraload\Pipeline\PipelineInterface'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
function it_does_not_transform_nor_load_if_no_data_extracted(ExtractorInterface $extractor, TransformerInterface $transformer, LoaderInterface $loader) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$extractor->extract()->shouldBeCalled()->willReturn(null); |
31
|
|
|
$loader->flush()->shouldBeCalled(); |
32
|
|
|
|
33
|
|
|
$this->process(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function it_processes_etl_sequentially(ExtractorInterface $extractor, TransformerInterface $transformer, LoaderInterface $loader) |
37
|
|
|
{ |
38
|
|
|
$extractor->extract()->shouldBeCalled()->willReturn(['a1', 'b1', 'c1'], null); |
39
|
|
|
$transformer->transform(['a1', 'b1', 'c1'])->shouldBeCalled()->willReturn(['c1', 'b1', 'a1']); |
40
|
|
|
$loader->load(['c1', 'b1', 'a1'])->shouldBeCalled(); |
41
|
|
|
$loader->flush()->shouldBeCalled(); |
42
|
|
|
|
43
|
|
|
$this->process(); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.