1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Phiremock. |
4
|
|
|
* |
5
|
|
|
* Phiremock is free software: you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* Phiremock is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with Phiremock. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Mcustiel\Phiremock\Domain; |
20
|
|
|
|
21
|
|
|
use Mcustiel\Phiremock\Domain\Options\Priority; |
22
|
|
|
use Mcustiel\Phiremock\Domain\Options\ScenarioName; |
23
|
|
|
|
24
|
|
|
class Expectation |
25
|
|
|
{ |
26
|
|
|
/** @var Conditions */ |
27
|
|
|
private $requestConditions; |
28
|
|
|
|
29
|
|
|
/** @var ScenarioName */ |
30
|
|
|
private $scenarioName; |
31
|
|
|
|
32
|
|
|
/** @var Response */ |
33
|
|
|
private $response; |
34
|
|
|
|
35
|
|
|
/** @var Priority */ |
36
|
|
|
private $priority; |
37
|
|
|
|
38
|
|
|
/** @var Version */ |
39
|
|
|
private $version; |
40
|
|
|
|
41
|
39 |
|
public function __construct( |
42
|
|
|
Conditions $requestConditions, |
43
|
|
|
Response $response, |
44
|
|
|
ScenarioName $scenarioName = null, |
45
|
|
|
Priority $priority = null, |
46
|
|
|
Version $version = null |
47
|
|
|
) { |
48
|
39 |
|
$this->priority = $priority; |
49
|
39 |
|
$this->requestConditions = $requestConditions; |
50
|
39 |
|
$this->scenarioName = $scenarioName; |
51
|
39 |
|
$this->response = $response; |
52
|
39 |
|
$this->version = $version ?? new Version(1); |
53
|
39 |
|
} |
54
|
|
|
|
55
|
30 |
|
public function getVersion(): Version |
56
|
|
|
{ |
57
|
30 |
|
return $this->version; |
58
|
|
|
} |
59
|
|
|
|
60
|
27 |
|
public function getRequest(): Conditions |
61
|
|
|
{ |
62
|
27 |
|
return $this->requestConditions; |
63
|
|
|
} |
64
|
|
|
|
65
|
30 |
|
public function hasScenarioName(): bool |
66
|
|
|
{ |
67
|
30 |
|
return $this->scenarioName !== null; |
68
|
|
|
} |
69
|
|
|
|
70
|
9 |
|
public function getScenarioName(): ?ScenarioName |
71
|
|
|
{ |
72
|
9 |
|
return $this->scenarioName; |
73
|
|
|
} |
74
|
|
|
|
75
|
27 |
|
public function getResponse(): Response |
76
|
|
|
{ |
77
|
27 |
|
return $this->response; |
78
|
|
|
} |
79
|
|
|
|
80
|
30 |
|
public function hasPriority(): bool |
81
|
|
|
{ |
82
|
30 |
|
return null !== $this->priority; |
83
|
|
|
} |
84
|
|
|
|
85
|
12 |
|
public function getPriority(): ?Priority |
86
|
|
|
{ |
87
|
12 |
|
return $this->priority; |
88
|
|
|
} |
89
|
|
|
|
90
|
3 |
|
public function setPriority(Priority $priority): self |
91
|
|
|
{ |
92
|
3 |
|
$this->priority = $priority; |
93
|
|
|
|
94
|
3 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|