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
|
|
|
/** |
17
|
|
|
* |
18
|
|
|
*/ |
19
|
|
|
public function testGetInstanceViaStaticMethodNotNull () : void |
20
|
|
|
{ |
21
|
|
|
$this->assertNotNull( StepLoader::getInstance() ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
*/ |
27
|
|
|
public function testGetInstanceViaStaticMethodIsStepLoader () : void |
28
|
|
|
{ |
29
|
|
|
$this->assertInstanceOf( StepLoader::class, StepLoader::getInstance() ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws SourceWatcherException |
34
|
|
|
*/ |
35
|
|
|
public function testGetExtractor () : void |
36
|
|
|
{ |
37
|
|
|
$stepLoader = new StepLoader(); |
38
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "csv" ); |
39
|
|
|
$this->assertNotNull( $extractor ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @throws SourceWatcherException |
44
|
|
|
*/ |
45
|
|
|
public function testGetExtractorValidated () : void |
46
|
|
|
{ |
47
|
|
|
$stepLoader = new StepLoader(); |
48
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "csv" ); |
49
|
|
|
$this->assertInstanceOf( Extractor::class, $extractor ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @throws SourceWatcherException |
54
|
|
|
*/ |
55
|
|
|
public function testGetExtractorNoParentClassName () : void |
56
|
|
|
{ |
57
|
|
|
$this->expectException( SourceWatcherException::class ); |
58
|
|
|
|
59
|
|
|
$stepLoader = new StepLoader(); |
60
|
|
|
$stepLoader->getStep( "", "csv" ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @throws SourceWatcherException |
65
|
|
|
*/ |
66
|
|
|
public function testGetExtractorNoStepName () : void |
67
|
|
|
{ |
68
|
|
|
$this->expectException( SourceWatcherException::class ); |
69
|
|
|
|
70
|
|
|
$stepLoader = new StepLoader(); |
71
|
|
|
$stepLoader->getStep( Extractor::class, "" ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @throws SourceWatcherException |
76
|
|
|
*/ |
77
|
|
|
public function testGetNonExistingParentStep () : void |
78
|
|
|
{ |
79
|
|
|
$this->expectException( SourceWatcherException::class ); |
80
|
|
|
|
81
|
|
|
$stepLoader = new StepLoader(); |
82
|
|
|
$stepLoader->getStep( "Sequencer", "csv" ); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @throws SourceWatcherException |
87
|
|
|
*/ |
88
|
|
|
public function testGetNonExistingStepName () : void |
89
|
|
|
{ |
90
|
|
|
$stepLoader = new StepLoader(); |
91
|
|
|
$extractor = $stepLoader->getStep( Extractor::class, "rainbow" ); |
92
|
|
|
$this->assertNull( $extractor ); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|