|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the KleijnWeb\SwaggerBundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace KleijnWeb\SwaggerBundle\Test; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Bundle\FrameworkBundle\Client; |
|
12
|
|
|
use Symfony\Component\BrowserKit\Request; |
|
13
|
|
|
use Symfony\Component\DomCrawler\Crawler; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author John Kleijn <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class ApiTestClient extends Client |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var Client |
|
22
|
|
|
*/ |
|
23
|
|
|
private $target; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(Client $client) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->target = $client; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Makes a request from a Request object directly. |
|
35
|
|
|
* |
|
36
|
|
|
* @param Request $request A Request instance |
|
37
|
|
|
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), |
|
38
|
|
|
* and reload()) |
|
39
|
|
|
* |
|
40
|
|
|
* @return Crawler |
|
41
|
|
|
*/ |
|
42
|
|
|
public function requestFromRequest(Request $request, $changeHistory = true) |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->target->requestFromRequest($request, $changeHistory); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return null|\Symfony\Component\HttpFoundation\Request |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getRequest() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->target->getRequest(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return null|\Symfony\Component\HttpFoundation\Response |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getResponse() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->target->getResponse(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return \Symfony\Component\DependencyInjection\ContainerInterface |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getContainer() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->target->getContainer(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return \Symfony\Component\HttpKernel\KernelInterface |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getKernel() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->target->getKernel(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return \Symfony\Component\HttpKernel\Profiler\Profile |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getProfile() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->target->getProfile(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return \Symfony\Component\HttpKernel\Profiler\Profile |
|
89
|
|
|
*/ |
|
90
|
|
|
public function enableProfiler() |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->target->getProfile(); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return void |
|
97
|
|
|
*/ |
|
98
|
|
|
public function disableReboot() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->target->disableReboot(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return void |
|
105
|
|
|
*/ |
|
106
|
|
|
public function enableReboot() |
|
107
|
|
|
{ |
|
108
|
|
|
$this->target->enableReboot(); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|