|
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\Server\Actions; |
|
20
|
|
|
|
|
21
|
|
|
use Monolog\Logger; |
|
22
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
23
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
24
|
|
|
|
|
25
|
|
|
class ResetAction implements ActionInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** @var ClearScenariosAction */ |
|
28
|
|
|
private $scenariosCleaner; |
|
29
|
|
|
/** @var ResetRequestsCountAction */ |
|
30
|
|
|
private $requestCounterCleaner; |
|
31
|
|
|
/** @var ReloadPreconfiguredExpectationsAction */ |
|
32
|
|
|
private $expectationsReloader; |
|
33
|
|
|
/** @var Logger */ |
|
34
|
|
|
private $logger; |
|
35
|
|
|
|
|
36
|
|
|
public function __construct( |
|
37
|
|
|
ClearScenariosAction $scenariosCleaner, |
|
38
|
|
|
ResetRequestsCountAction $requestCounterCleaner, |
|
39
|
|
|
ReloadPreconfiguredExpectationsAction $expectationsReloader, |
|
40
|
|
|
Logger $logger |
|
41
|
|
|
) { |
|
42
|
|
|
$this->scenariosCleaner = $scenariosCleaner; |
|
43
|
|
|
$this->requestCounterCleaner = $requestCounterCleaner; |
|
44
|
|
|
$this->expectationsReloader = $expectationsReloader; |
|
45
|
|
|
$this->logger = $logger; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function execute(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
|
49
|
|
|
{ |
|
50
|
|
|
$this->logger->debug('Executing reset'); |
|
51
|
|
|
$response = $this->scenariosCleaner->execute($request, $response); |
|
52
|
|
|
$response = $this->requestCounterCleaner->execute($request, $response); |
|
53
|
|
|
|
|
54
|
|
|
return $this->expectationsReloader->execute($request, $response); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|