7 declare(strict_types=1);
13 use PHPUnit\Framework\TestCase;
40 $this->validator =
$objectManager->get(HttpMethodValidator::class);
42 if (!$this->request instanceof HttpRequest) {
43 throw new \RuntimeException(
'We need HTTP request');
51 private function getMap(): array
53 $map = $this->map->getMap();
54 if (count($map) < 2) {
55 throw new \RuntimeException(
56 'We need at least 2 HTTP methods allowed' 61 foreach ($map as
$method => $interface) {
62 $sorted[] = [
'method' =>
$method,
'interface' => $interface];
75 $map = $this->getMap();
77 $action1 = $this->getMockForAbstractClass($map[0][
'interface']);
78 $this->request->setMethod($map[0][
'method']);
79 $this->validator->validate($this->request, $action1);
81 $action2 = $this->getMockForAbstractClass(ActionInterface::class);
82 $this->validator->validate($this->request, $action2);
92 $this->request->setMethod(
'method' .rand(0, 1000));
93 $action = $this->getMockForAbstractClass(ActionInterface::class);
95 $this->validator->validate($this->request, $action);
103 $map = $this->getMap();
105 $this->request->setMethod($map[1][
'method']);
106 $action = $this->getMockForAbstractClass($map[0][
'interface']);
108 $this->validator->validate($this->request, $action);
static getObjectManager()