Skip to content

Commit 87920d7

Browse files
committed
Refactored
1 parent 5c112ee commit 87920d7

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

tests/bundle/Functional/ViewTest.php

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ class ViewTest extends TestCase
1010
{
1111
use ResourceAssertionsTrait;
1212

13+
private const VIEW_ENDPOINT_ACCEPT_TYPE = 'View+json';
14+
private const VIEW_ENDPOINT_URL = '/api/ibexa/v2/views';
15+
16+
private const FORMAT_XML = 'xml';
17+
private const FORMAT_JSON = 'json';
18+
19+
private const OPERATOR_EQUALITY = 'eq';
20+
private const OPERATOR_IN = 'in';
21+
22+
private const CRITERION_LOCATION_DEPTH = 'LocationDepth';
23+
private const CRITERION_IS_MAIN_LOCATION = 'IsMainLocation';
24+
1325
/**
1426
* Covers POST /views.
1527
*/
@@ -38,9 +50,9 @@ public function testViewRequestWithOrStatement(): void
3850
XML;
3951
$request = $this->createHttpRequest(
4052
'POST',
41-
'/api/ibexa/v2/views',
53+
self::VIEW_ENDPOINT_URL,
4254
'ViewInput+xml',
43-
'View+json',
55+
self::VIEW_ENDPOINT_ACCEPT_TYPE,
4456
$body
4557
);
4658
$response = $this->sendHttpRequest($request);
@@ -58,9 +70,9 @@ public function testCriterions(string $body, string $type): void
5870
{
5971
$request = $this->createHttpRequest(
6072
'POST',
61-
'/api/ibexa/v2/views',
73+
self::VIEW_ENDPOINT_URL,
6274
"ViewInput+$type",
63-
'View+json',
75+
self::VIEW_ENDPOINT_ACCEPT_TYPE,
6476
$body
6577
);
6678
$response = $this->sendHttpRequest($request);
@@ -82,34 +94,34 @@ public function provideForViewTest(): iterable
8294
strtoupper($format),
8395
);
8496

85-
yield $template('LocationDepth', 'eq', 'xml') => [
97+
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_EQUALITY, self::FORMAT_XML) => [
8698
file_get_contents(__DIR__ . '/_input/search/LocationDepth.eq.xml'),
87-
'xml',
99+
self::FORMAT_XML,
88100
];
89101

90-
yield $template('LocationDepth', 'eq', 'json') => [
102+
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_EQUALITY, self::FORMAT_JSON) => [
91103
file_get_contents(__DIR__ . '/_input/search/LocationDepth.eq.json'),
92-
'json',
104+
self::FORMAT_JSON,
93105
];
94106

95-
yield $template('LocationDepth', 'in', 'xml') => [
107+
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_IN, self::FORMAT_XML) => [
96108
file_get_contents(__DIR__ . '/_input/search/LocationDepth.in.xml'),
97-
'xml',
109+
self::FORMAT_XML,
98110
];
99111

100-
yield $template('LocationDepth', 'in', 'json') => [
112+
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_IN, self::FORMAT_JSON) => [
101113
file_get_contents(__DIR__ . '/_input/search/LocationDepth.in.json'),
102-
'json',
114+
self::FORMAT_JSON,
103115
];
104116

105-
yield $template('IsMainLocation', 'eq', 'xml') => [
117+
yield $template(self::CRITERION_IS_MAIN_LOCATION, self::OPERATOR_EQUALITY, self::FORMAT_XML) => [
106118
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.xml'),
107-
'xml',
119+
self::FORMAT_XML,
108120
];
109121

110-
yield $template('IsMainLocation', 'eq', 'json') => [
122+
yield $template(self::CRITERION_IS_MAIN_LOCATION, self::OPERATOR_EQUALITY, self::FORMAT_JSON) => [
111123
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.json'),
112-
'json',
124+
self::FORMAT_JSON,
113125
];
114126
}
115127

@@ -144,9 +156,9 @@ public function testViewRequestWithAndStatement(): void
144156
XML;
145157
$request = $this->createHttpRequest(
146158
'POST',
147-
'/api/ibexa/v2/views',
159+
self::VIEW_ENDPOINT_URL,
148160
'ViewInput+xml',
149-
'View+json',
161+
self::VIEW_ENDPOINT_ACCEPT_TYPE,
150162
$body
151163
);
152164
$response = $this->sendHttpRequest($request);

0 commit comments

Comments
 (0)