Skip to content

Commit 2d4b602

Browse files
committed
test: rename steps
1 parent df2213b commit 2d4b602

File tree

14 files changed

+97
-84
lines changed

14 files changed

+97
-84
lines changed

tests/acceptance/TestHelpers/HttpRequestHelper.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,22 @@ public static function getRequestTimeout(): int {
665665
public static function getJsonDecodedResponseBodyContent(ResponseInterface $response): mixed {
666666
return json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR);
667667
}
668+
669+
/**
670+
* @return bool
671+
*/
672+
public static function sendScenarioLineReferencesInXRequestId(): bool {
673+
return (\getenv("SEND_SCENARIO_LINE_REFERENCES") === "true");
674+
}
675+
676+
/**
677+
* @return bool
678+
*/
679+
public static function getXRequestIdRegex(): string {
680+
if (self::sendScenarioLineReferencesInXRequestId()){
681+
return '/^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/';
682+
}
683+
$host = gethostname();
684+
return "/^$host\/.*$/";
685+
}
668686
}

tests/acceptance/bootstrap/FeatureContext.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ class FeatureContext extends BehatVariablesContext {
145145
* in the apiComments suite.
146146
*/
147147
private string $stepLineRef = '';
148-
private bool $sendStepLineRef = false;
149-
private bool $sendStepLineRefHasBeenChecked = false;
150148

151149
/**
152150
* @var boolean true if TEST_SERVER_FED_URL is defined
@@ -416,17 +414,6 @@ public function isTestingWithLdap(): bool {
416414
return (\getenv("TEST_WITH_LDAP") === "true");
417415
}
418416

419-
/**
420-
* @return bool
421-
*/
422-
public function sendScenarioLineReferencesInXRequestId(): ?bool {
423-
if ($this->sendStepLineRefHasBeenChecked === false) {
424-
$this->sendStepLineRef = (\getenv("SEND_SCENARIO_LINE_REFERENCES") === "true");
425-
$this->sendStepLineRefHasBeenChecked = true;
426-
}
427-
return $this->sendStepLineRef;
428-
}
429-
430417
/**
431418
* @return bool
432419
*/
@@ -880,7 +867,7 @@ public function getRemoteBaseUrlWithoutScheme(): string {
880867
* @return string
881868
*/
882869
public function getStepLineRef(): string {
883-
if (!$this->sendStepLineRef) {
870+
if (!HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) {
884871
return '';
885872
}
886873

@@ -2435,6 +2422,14 @@ public function substituteInLineCodes(
24352422
"getUUIDv4Regex"
24362423
],
24372424
"parameter" => []
2425+
],
2426+
[
2427+
"code" => "%request_id_pattern%",
2428+
"function" => [
2429+
__NAMESPACE__ . '\TestHelpers\HttpRequestHelper',
2430+
"getXRequestIdRegex"
2431+
],
2432+
"parameter" => []
24382433
]
24392434
];
24402435
if ($user !== null) {
@@ -2644,7 +2639,7 @@ public function before(BeforeScenarioScope $scope): void {
26442639
$environment->registerContext($this->spacesContext);
26452640
}
26462641

2647-
if ($this->sendScenarioLineReferencesInXRequestId()) {
2642+
if (HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) {
26482643
$this->scenarioString = $suiteName . '/' . $featureFileName . ':' . $scenarioLine;
26492644
} else {
26502645
$this->scenarioString = '';
@@ -2678,7 +2673,7 @@ public function before(BeforeScenarioScope $scope): void {
26782673
* @return void
26792674
*/
26802675
public function beforeEachStep(BeforeStepScope $scope): void {
2681-
if ($this->sendScenarioLineReferencesInXRequestId()) {
2676+
if (HttpRequestHelper::sendScenarioLineReferencesInXRequestId()) {
26822677
$this->stepLineRef = $this->scenarioString . '-' . $scope->getStep()->getLine();
26832678
} else {
26842679
$this->stepLineRef = '';

tests/acceptance/bootstrap/SpacesContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,7 +3795,7 @@ public function sendPropfindRequestToSpace(string $user, string $spaceName, ?str
37953795
}
37963796

37973797
/**
3798-
* @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (mountpoint|space) "([^"]*)" with these key and value pairs:$/
3798+
* @Then /^as user "([^"]*)" the (PROPFIND|REPORT) response should contain a (resource|space) "([^"]*)" with these key and value pairs:$/
37993799
*
38003800
* @param string $user
38013801
* @param string $method # method should be either PROPFIND or REPORT

tests/acceptance/bootstrap/WebDav.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,9 +3554,9 @@ public function headersShouldMatchRegularExpressions(TableNode $table):void {
35543554
$expectedHeaderValue = $header[1];
35553555
$expectedHeaderValue = $this->substituteInLineCodes(
35563556
$expectedHeaderValue,
3557-
null,
3558-
['preg_quote' => ['/']]
3557+
null
35593558
);
3559+
var_dump($expectedHeaderValue);
35603560

35613561
$returnedHeaders = $this->response->getHeader($headerName);
35623562
$returnedHeader = $returnedHeaders[0];

tests/acceptance/features/apiContract/copy.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Feature: Copy test
2121
| Origin | %base_url% |
2222
Then the HTTP status code should be "201"
2323
And the following headers should match these regular expressions
24-
| Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ |
25-
| Access-Control-Allow-Origin | /^%base_url%$/ |
26-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
24+
| Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ |
25+
| Access-Control-Allow-Origin | /^%base_url%$/ |
26+
| X-Request-Id | %request_id_pattern% |
2727

tests/acceptance/features/apiContract/propfind.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: Propfind test
1818
When user "Alice" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API
1919
Then the HTTP status code should be "207"
2020
And the following headers should match these regular expressions
21-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
21+
| X-Request-Id | %request_id_pattern% |
2222
And as user "Alice" the PROPFIND response should contain a space "new-space" with these key and value pairs:
2323
| key | value |
2424
| oc:fileid | %file_id_pattern% |
@@ -38,7 +38,7 @@ Feature: Propfind test
3838
When user "Brian" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API
3939
Then the HTTP status code should be "207"
4040
And the following headers should match these regular expressions
41-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
41+
| X-Request-Id | %request_id_pattern% |
4242
And as user "Brian" the PROPFIND response should contain a space "new-space" with these key and value pairs:
4343
| key | value |
4444
| oc:fileid | %file_id_pattern% |
@@ -62,7 +62,7 @@ Feature: Propfind test
6262
| permissionsRole | <space-role> |
6363
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain" with depth "0" using the WebDAV API
6464
Then the HTTP status code should be "207"
65-
And as user "Brian" the PROPFIND response should contain a mountpoint "folderMain" with these key and value pairs:
65+
And as user "Brian" the PROPFIND response should contain a resource "folderMain" with these key and value pairs:
6666
| key | value |
6767
| oc:fileid | %file_id_pattern% |
6868
| oc:file-parent | %file_id_pattern% |
@@ -85,7 +85,7 @@ Feature: Propfind test
8585
| permissionsRole | <space-role> |
8686
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain/subFolder1/subFolder2" with depth "0" using the WebDAV API
8787
Then the HTTP status code should be "207"
88-
And as user "Brian" the PROPFIND response should contain a mountpoint "subFolder2" with these key and value pairs:
88+
And as user "Brian" the PROPFIND response should contain a resource "subFolder2" with these key and value pairs:
8989
| key | value |
9090
| oc:fileid | %file_id_pattern% |
9191
| oc:file-parent | %file_id_pattern% |
@@ -108,7 +108,7 @@ Feature: Propfind test
108108
| permissionsRole | <space-role> |
109109
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "testfile.txt" with depth "0" using the WebDAV API
110110
Then the HTTP status code should be "207"
111-
And as user "Brian" the PROPFIND response should contain a mountpoint "testfile.txt" with these key and value pairs:
111+
And as user "Brian" the PROPFIND response should contain a resource "testfile.txt" with these key and value pairs:
112112
| key | value |
113113
| oc:fileid | %file_id_pattern% |
114114
| oc:file-parent | %file_id_pattern% |

tests/acceptance/features/apiContract/sharesReport.feature

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Feature: REPORT request to Shares space
2525
When user "Brian" searches for "SubFolder1" using the WebDAV API
2626
Then the HTTP status code should be "207"
2727
And the following headers should match these regular expressions
28-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
29-
And as user "Brian" the REPORT response should contain a mountpoint "SubFolder1" with these key and value pairs:
28+
| X-Request-Id | %request_id_pattern% |
29+
And as user "Brian" the REPORT response should contain a resource "SubFolder1" with these key and value pairs:
3030
| key | value |
3131
| oc:fileid | %file_id_pattern% |
3232
| oc:file-parent | %file_id_pattern% |
@@ -47,8 +47,8 @@ Feature: REPORT request to Shares space
4747
When user "Brian" searches for "frodo.txt" using the WebDAV API
4848
Then the HTTP status code should be "207"
4949
And the following headers should match these regular expressions
50-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
51-
And as user "Brian" the REPORT response should contain a mountpoint "frodo.txt" with these key and value pairs:
50+
| X-Request-Id | %request_id_pattern% |
51+
And as user "Brian" the REPORT response should contain a resource "frodo.txt" with these key and value pairs:
5252
| key | value |
5353
| oc:fileid | %file_id_pattern% |
5454
| oc:file-parent | %file_id_pattern% |
@@ -77,7 +77,7 @@ Feature: REPORT request to Shares space
7777
When user "Brian" searches for "folderToBrian" using the WebDAV API
7878
Then the HTTP status code should be "207"
7979
And the following headers should match these regular expressions
80-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
80+
| X-Request-Id | %request_id_pattern% |
8181
And the search result should contain "0" entries
8282
Examples:
8383
| dav-path-version |
@@ -99,8 +99,8 @@ Feature: REPORT request to Shares space
9999
When user "Brian" searches for "secureFolder" using the WebDAV API
100100
Then the HTTP status code should be "207"
101101
And the following headers should match these regular expressions
102-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
103-
And as user "Brian" the REPORT response should contain a mountpoint "secureFolder" with these key and value pairs:
102+
| X-Request-Id | %request_id_pattern% |
103+
And as user "Brian" the REPORT response should contain a resource "secureFolder" with these key and value pairs:
104104
| key | value |
105105
| oc:shareroot | /secureFolder |
106106
| oc:name | secureFolder |
@@ -110,9 +110,9 @@ Feature: REPORT request to Shares space
110110
| oc:remote-item-id | %file_id_pattern% |
111111
When user "Brian" searches for "secure.txt" using the WebDAV API
112112
And the following headers should match these regular expressions
113-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
113+
| X-Request-Id | %request_id_pattern% |
114114
Then the HTTP status code should be "207"
115-
And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs:
115+
And as user "Brian" the REPORT response should contain a resource "secure.txt" with these key and value pairs:
116116
| key | value |
117117
| oc:shareroot | /secureFolder |
118118
| oc:name | secure.txt |
@@ -139,8 +139,8 @@ Feature: REPORT request to Shares space
139139
When user "Brian" searches for "secure.txt" using the WebDAV API
140140
Then the HTTP status code should be "207"
141141
And the following headers should match these regular expressions
142-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
143-
And as user "Brian" the REPORT response should contain a mountpoint "secure.txt" with these key and value pairs:
142+
| X-Request-Id | %request_id_pattern% |
143+
And as user "Brian" the REPORT response should contain a resource "secure.txt" with these key and value pairs:
144144
| key | value |
145145
| oc:shareroot | /secure.txt |
146146
| oc:name | secure.txt |

tests/acceptance/features/apiContract/spacesReport.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Feature: REPORT request to project space
2121
And the search result of user "Alice" should contain only these entries:
2222
| /testFile.txt |
2323
And the following headers should match these regular expressions
24-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
25-
And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs:
24+
| X-Request-Id | %request_id_pattern% |
25+
And as user "Alice" the REPORT response should contain a resource "testFile.txt" with these key and value pairs:
2626
| key | value |
2727
| oc:fileid | %file_id_pattern% |
2828
| oc:file-parent | %file_id_pattern% |
@@ -41,8 +41,8 @@ Feature: REPORT request to project space
4141
And the search result of user "Alice" should contain only these entries:
4242
| /folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
4343
And the following headers should match these regular expressions
44-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
45-
And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs:
44+
| X-Request-Id | %request_id_pattern% |
45+
And as user "Alice" the REPORT response should contain a resource "insideTheFolder.txt" with these key and value pairs:
4646
| key | value |
4747
| oc:fileid | %file_id_pattern% |
4848
| oc:file-parent | %file_id_pattern% |
@@ -60,8 +60,8 @@ Feature: REPORT request to project space
6060
And the search result of user "Alice" should contain only these entries:
6161
| /folderMain |
6262
And the following headers should match these regular expressions
63-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
64-
And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs:
63+
| X-Request-Id | %request_id_pattern% |
64+
And as user "Alice" the REPORT response should contain a resource "folderMain" with these key and value pairs:
6565
| key | value |
6666
| oc:fileid | %file_id_pattern% |
6767
| oc:file-parent | %file_id_pattern% |
@@ -79,9 +79,9 @@ Feature: REPORT request to project space
7979
And the search result of user "Alice" should contain only these entries:
8080
| /folderMain/sub-folder |
8181
And the following headers should match these regular expressions
82-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
82+
| X-Request-Id | %request_id_pattern% |
8383
And the HTTP status code should be "207"
84-
And as user "Alice" the REPORT response should contain a mountpoint "findData" with these key and value pairs:
84+
And as user "Alice" the REPORT response should contain a resource "sub-folder" with these key and value pairs:
8585
| key | value |
8686
| oc:fileid | %file_id_pattern% |
8787
| oc:file-parent | %file_id_pattern% |

tests/acceptance/features/apiContract/spacesSharesReport.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Feature: Report test
3030
When user "Brian" searches for "SubFolder1" using the WebDAV API
3131
Then the HTTP status code should be "207"
3232
And the following headers should match these regular expressions
33-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
34-
And as user "Brian" the REPORT response should contain a mountpoint "folderMain" with these key and value pairs:
33+
| X-Request-Id | %request_id_pattern% |
34+
And as user "Brian" the REPORT response should contain a resource "SubFolder1" with these key and value pairs:
3535
| key | value |
3636
| oc:fileid | %file_id_pattern% |
3737
| oc:file-parent | %file_id_pattern% |
@@ -54,8 +54,8 @@ Feature: Report test
5454
When user "Brian" searches for "insideTheFolder.txt" using the WebDAV API
5555
Then the HTTP status code should be "207"
5656
And the following headers should match these regular expressions
57-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
58-
And as user "Brian" the REPORT response should contain a mountpoint "insideTheFolder.txt" with these key and value pairs:
57+
| X-Request-Id | %request_id_pattern% |
58+
And as user "Brian" the REPORT response should contain a resource "insideTheFolder.txt" with these key and value pairs:
5959
| key | value |
6060
| oc:fileid | %file_id_pattern% |
6161
| oc:file-parent | %file_id_pattern% |
@@ -78,5 +78,5 @@ Feature: Report test
7878
When user "Brian" searches for "folderMain" using the WebDAV API
7979
Then the HTTP status code should be "207"
8080
And the following headers should match these regular expressions
81-
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
81+
| X-Request-Id | %request_id_pattern% |
8282
And the search result should contain "0" entries

0 commit comments

Comments
 (0)