1
|
|
|
<?php declare( strict_types = 1 ); |
2
|
|
|
|
3
|
|
|
namespace Coco\SourceWatcher\Tests\Core; |
4
|
|
|
|
5
|
|
|
use Coco\SourceWatcher\Core\Extractor; |
6
|
|
|
use Coco\SourceWatcher\Core\SourceWatcherException; |
7
|
|
|
use Coco\SourceWatcher\Core\StepLoader; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class StepLoaderTest |
12
|
|
|
* @package Coco\SourceWatcher\Tests\Core |
13
|
|
|
*/ |
14
|
|
|
class StepLoaderTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
public function testGetExtractor () : void |
17
|
|
|
{ |
18
|
|
|
try { |
19
|
|
|
$stepLoader = new StepLoader(); |
20
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "csv" ); |
21
|
|
|
$this->assertNotNull( $extractor ); |
22
|
|
|
} catch ( SourceWatcherException $sourceWatcherException ) { |
|
|
|
|
23
|
|
|
|
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testGetExtractorValidated () : void |
28
|
|
|
{ |
29
|
|
|
try { |
30
|
|
|
$stepLoader = new StepLoader(); |
31
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "csv" ); |
32
|
|
|
$this->assertInstanceOf( Extractor::class, $extractor ); |
33
|
|
|
} catch ( SourceWatcherException $sourceWatcherException ) { |
|
|
|
|
34
|
|
|
|
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testGetExtractorNoParentClassName () : void |
39
|
|
|
{ |
40
|
|
|
$this->expectException( SourceWatcherException::class ); |
41
|
|
|
|
42
|
|
|
$stepLoader = new StepLoader(); |
43
|
|
|
$stepLoader->getStep( "", "csv" ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testGetExtractorNoStepName () : void |
47
|
|
|
{ |
48
|
|
|
$this->expectException( SourceWatcherException::class ); |
49
|
|
|
|
50
|
|
|
$stepLoader = new StepLoader(); |
51
|
|
|
$stepLoader->getStep( Extractor::class, "" ); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testGetNonExistingParentStep () : void |
55
|
|
|
{ |
56
|
|
|
$this->expectException( SourceWatcherException::class ); |
57
|
|
|
|
58
|
|
|
$stepLoader = new StepLoader(); |
59
|
|
|
$stepLoader->getStep( "Sequencer", "csv" ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testGetNonExistingStepName () : void |
63
|
|
|
{ |
64
|
|
|
try { |
65
|
|
|
$stepLoader = new StepLoader(); |
66
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "rainbow" ); |
67
|
|
|
$this->assertNull( $extractor ); |
68
|
|
|
} catch ( SourceWatcherException $sourceWatcherException ) { |
|
|
|
|
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|