Passed
Push — master ( 484b96...d6d91c )
by Jean Paul
01:26
created

StepLoaderTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 21
c 2
b 0
f 0
dl 0
loc 79
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetExtractorNoParentClassName() 0 6 1
A testGetNonExistingStepName() 0 5 1
A testGetInstanceViaStaticMethodNotNull() 0 3 1
A testGetExtractorNoStepName() 0 6 1
A testGetExtractorValidated() 0 5 1
A testGetExtractor() 0 5 1
A testGetNonExistingParentStep() 0 6 1
A testGetInstanceViaStaticMethodIsStepLoader() 0 3 1
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