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