1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PHPKitchen\CodeSpecs\Expectation\Routing; |
4
|
|
|
|
5
|
|
|
use PHPKitchen\CodeSpecs\Contract\TestGuy; |
6
|
|
|
use PHPKitchen\CodeSpecs\Directive\Wait; |
7
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Internal\StepsList; |
8
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\ArrayMatcher; |
9
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\BooleanMatcher; |
10
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\ClassMatcher; |
11
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\DirectoryMatcher; |
12
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\FileMatcher; |
13
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\NumberMatcher; |
14
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\ObjectMatcher; |
15
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\StringMatcher; |
16
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\ValueMatcher; |
17
|
|
|
use PHPKitchen\CodeSpecs\Mixin\TestGuyMethods; |
|
|
|
|
18
|
|
|
|
19
|
|
|
class Router { |
20
|
|
|
/** |
21
|
|
|
* @var StepsList |
22
|
|
|
*/ |
23
|
|
|
private $steps; |
24
|
|
|
/** |
25
|
|
|
* @var \PHPUnit\Framework\Test |
26
|
|
|
*/ |
27
|
|
|
protected $context; |
28
|
|
|
protected $variableName = ''; |
29
|
|
|
//region ----------------------- SPECIFICATION METHODS ----------------------- |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Starts a chain of asserts from {@link StringMatcher}. |
33
|
|
|
* |
34
|
|
|
* @param string $variable variable to be tested |
35
|
|
|
* |
36
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\StringMatcher |
37
|
|
|
*/ |
38
|
|
|
public function seeString($string): StringMatcher { |
39
|
|
|
return $this->dispatch($string) |
40
|
|
|
->isString(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Starts a chain of asserts from {@link ArrayMatcher}. |
45
|
|
|
* |
46
|
|
|
* @param array|\ArrayAccess $variable variable to be tested |
47
|
|
|
* |
48
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\ArrayMatcher |
49
|
|
|
*/ |
50
|
|
|
public function seeArray($variable): ArrayMatcher { |
51
|
|
|
return $this->dispatch($variable) |
52
|
|
|
->isArray(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Starts a chain of asserts from {@link BooleanMatcher}. |
57
|
|
|
* |
58
|
|
|
* @param boolean $variable variable to be tested |
59
|
|
|
* |
60
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\BooleanMatcher |
61
|
|
|
*/ |
62
|
|
|
public function seeBool($variable): BooleanMatcher { |
63
|
|
|
return $this->dispatch($variable) |
64
|
|
|
->isBoolean(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Starts a chain of asserts from {@link NumberMatcher}. |
69
|
|
|
* |
70
|
|
|
* @param int|float $variable variable to be tested |
71
|
|
|
* |
72
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\NumberMatcher |
73
|
|
|
*/ |
74
|
|
|
public function seeNumber($variable): NumberMatcher { |
75
|
|
|
return $this->dispatch($variable) |
76
|
|
|
->isNumber(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Starts a chain of asserts from {@link ObjectMatcher}. |
81
|
|
|
* |
82
|
|
|
* @param object $variable variable to be tested |
83
|
|
|
* |
84
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\ObjectMatcher |
85
|
|
|
*/ |
86
|
|
|
public function seeObject($variable): ObjectMatcher { |
87
|
|
|
return $this->dispatch($variable) |
88
|
|
|
->isObject(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Starts a chain of asserts from {@link ClassMatcher}. |
93
|
|
|
* |
94
|
|
|
* @param string $variable variable to be tested |
95
|
|
|
* |
96
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\ClassMatcher |
97
|
|
|
*/ |
98
|
|
|
public function seeClass($variable): ClassMatcher { |
99
|
|
|
return $this->dispatch($variable) |
100
|
|
|
->isClass(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Starts a chain of asserts from {@link FileMatcher}. |
105
|
|
|
* |
106
|
|
|
* @param string $variable variable to be tested |
107
|
|
|
* |
108
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\FileMatcher |
109
|
|
|
*/ |
110
|
|
|
public function seeFile($variable): FileMatcher { |
111
|
|
|
return $this->dispatch($variable) |
112
|
|
|
->isFile(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Starts a chain of asserts from {@link DirectoryMatcher}. |
117
|
|
|
* |
118
|
|
|
* @param string $variable variable to be tested |
119
|
|
|
* |
120
|
|
|
* @return \PHPKitchen\CodeSpecs\Expectation\Matcher\DirectoryMatcher |
121
|
|
|
*/ |
122
|
|
|
public function seeDirectory($variable): DirectoryMatcher { |
123
|
|
|
return $this->dispatch($variable) |
124
|
|
|
->isDirectory(); |
125
|
|
|
} |
126
|
|
|
//endregion |
127
|
|
|
|
128
|
|
|
//region ----------------------- UTIL METHODS ----------------------- |
129
|
|
|
|
130
|
|
|
protected function initStepsList() { |
131
|
|
|
$this->steps = StepsList::getInstance(); |
132
|
|
|
$this->steps->clear(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
private function dispatch($actualValue): Dispatcher { |
136
|
|
|
return $this->createDispatcher(Dispatcher::class, $actualValue); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
private function createDispatcher($class, $actualValue): Dispatcher { |
140
|
|
|
$dispatcher = new $class($this->context, $actualValue, $this->variableName); |
141
|
|
|
$this->variableName = ''; |
142
|
|
|
|
143
|
|
|
return $dispatcher; |
144
|
|
|
} |
145
|
|
|
//endregion |
146
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths