BaseCodeceptionCest::_beforeStep()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting;
5
6
use Codeception\Scenario;
7
use Codeception\Step;
8
use ReflectionClass;
9
use SmartWeb\ModuleTesting\Contracts\Test\CodeceptionCest;
10
use SmartWeb\ModuleTesting\Util\BacksUpItems;
11
use SmartWeb\ModuleTesting\Util\WithMockery;
12
13
14
/**
15
 * Class BaseCodeceptionCest
16
 *
17
 * @package SmartWeb\ModuleTesting
18
 */
19
abstract class BaseCodeceptionCest implements CodeceptionCest
20
{
21
    
22
    use WithMockery, BacksUpItems;
23
    
24
    /**
25
     * @var Scenario
26
     */
27
    protected $scenario;
28
    
29
    /**
30
     * @var Step
31
     */
32
    protected $step;
33
    
34
    // region <<-[ Codeception hooks ]->>
35
    
36
    /**
37
     * @inheritDoc
38
     */
39
    public function _initialize()
40
    {
41
    
42
    }
43
    
44
    /**
45
     * @inheritDoc
46
     */
47
    public function _cleanup()
48
    {
49
    
50
    }
51
    
52
    /**
53
     * @inheritDoc
54
     */
55
    public function _beforeSuite(array $settings = [])
56
    {
57
        $this->getCopier();
58
    }
59
    
60
    /**
61
     * @inheritDoc
62
     */
63
    public function _afterSuite()
64
    {
65
    
66
    }
67
    
68
    /**
69
     * @inheritDoc
70
     */
71
    public function _beforeStep(Step $step)
72
    {
73
        $this->step = $step;
74
    }
75
    
76
    /**
77
     * @inheritDoc
78
     */
79
    public function _afterStep(Step $step)
80
    {
81
        unset($step);
82
    }
83
    
84
    // endregion [ Codeception hooks ]
85
    
86
    /**
87
     * @return Scenario
88
     */
89
    protected function getScenario() : Scenario
90
    {
91
        return $this->scenario;
92
    }
93
    
94
    /**
95
     * @return Step
96
     */
97
    protected function getStep() : Step
98
    {
99
        return $this->step;
100
    }
101
    
102
    /**
103
     * @return object
104
     */
105
    final protected function getTesterAttribute()
106
    {
107
        $reflectionClass = new ReflectionClass($this->getActorClass());
108
        
109
        return $reflectionClass->newInstance($this->scenario);
110
    }
111
    
112
    // FIXME: Is there not a better way to dynamically create the correct actor class from here?
113
    
114
    /**
115
     * @return string
116
     */
117
    abstract protected function getActorClass() : string;
118
    
119
}
120