Skip to content

Commit 42014d7

Browse files
authored
Merge pull request #10804 from owncloud/add-lint-rule-for-tests
[tests-only][full-ci] updating lint rules for test code
2 parents dc02488 + 089ccc1 commit 42014d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2914
-1151
lines changed

.php-cs-fixer.dist.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
->exclude($excludeDirs)
1313
->in(__DIR__);
1414

15-
$config = new OC\CodingStandard\Config();
15+
$ocRule = (new OC\CodingStandard\Config())->getRules();
16+
$config = new PhpCsFixer\Config();
17+
$config->setFinder($finder)
18+
->setIndent("\t")
19+
->setRules(
20+
array_merge(
21+
$ocRule,
22+
[
23+
"return_type_declaration" => [
24+
"space_before" => "none",
25+
],
26+
'single_space_around_construct' => true
27+
]
28+
)
29+
);
1630
$config->setFinder($finder);
1731
return $config;

phpcs.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
2020
</rule>
2121

22-
<rule ref="Generic.Files.LineLength">
23-
<exclude name="Generic.Files.LineLength.TooLong" />
24-
</rule>
25-
2622
<rule ref="PEAR">
2723
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
2824
<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
@@ -77,4 +73,18 @@
7773
<exclude-pattern>*/lib/storagewrapper.php</exclude-pattern>
7874
</rule>
7975

76+
<rule ref="Generic.Commenting.Todo">
77+
<message>Please review this TODO comment: %s</message>
78+
<type>error</type>
79+
</rule>
80+
<rule ref="Squiz.PHP.NonExecutableCode" />
81+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
82+
<rule ref="Generic.Files.LineLength">
83+
<properties>
84+
<property name="ignoreComments" value="true" />
85+
<type>error</type>
86+
<property name="lineLimit" value="120" />
87+
<property name="absoluteLineLimit" value="120" />
88+
</properties>
89+
</rule>
8090
</ruleset>

tests/acceptance/TestHelpers/Asserts/WebDav.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function assertDavResponseElementIs(
4242
?string $expectedValue,
4343
?array $responseXmlArray,
4444
?string $extraErrorText = ''
45-
):void {
45+
): void {
4646
if ($extraErrorText !== '') {
4747
$extraErrorText = $extraErrorText . " ";
4848
}
@@ -58,7 +58,9 @@ public static function assertDavResponseElementIs(
5858
} elseif ($element === "reason") {
5959
$result = $responseXmlArray['value'][3]['value'];
6060
} else {
61-
self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in.");
61+
self::fail(
62+
__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in."
63+
);
6264
}
6365

6466
self::assertEquals(
@@ -78,7 +80,7 @@ public static function assertDavResponseElementIs(
7880
public static function assertResponseContainsShareTypes(
7981
SimpleXMLElement $responseXmlObject,
8082
?array $expectedShareTypes
81-
):void {
83+
): void {
8284
foreach ($expectedShareTypes as $row) {
8385
$xmlPart = $responseXmlObject->xpath(
8486
"//d:prop/oc:share-types/oc:share-type[.=" . $row[0] . "]"

tests/acceptance/TestHelpers/AuthAppHelper.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public static function getAuthAppEndpoint(): string {
4242
*
4343
* @return ResponseInterface
4444
*/
45-
public static function listAllAppAuthTokensForUser(string $baseUrl, string $user, string $password): ResponseInterface {
45+
public static function listAllAppAuthTokensForUser(
46+
string $baseUrl,
47+
string $user,
48+
string $password
49+
): ResponseInterface {
4650
$url = $baseUrl . self::getAuthAppEndpoint();
4751
return HttpRequestHelper::sendRequest(
4852
$url,
@@ -61,7 +65,12 @@ public static function listAllAppAuthTokensForUser(string $baseUrl, string $user
6165
*
6266
* @return ResponseInterface
6367
*/
64-
public static function createAppAuthToken(string $baseUrl, string $user, string $password, string $expiration): ResponseInterface {
68+
public static function createAppAuthToken(
69+
string $baseUrl,
70+
string $user,
71+
string $password,
72+
string $expiration
73+
): ResponseInterface {
6574
$url = $baseUrl . self::getAuthAppEndpoint() . "?expiry=$expiration";
6675
return HttpRequestHelper::sendRequest(
6776
$url,
@@ -80,7 +89,12 @@ public static function createAppAuthToken(string $baseUrl, string $user, string
8089
*
8190
* @return ResponseInterface
8291
*/
83-
public static function deleteAppAuthToken(string $baseUrl, string $user, string $password, string $token): ResponseInterface {
92+
public static function deleteAppAuthToken(
93+
string $baseUrl,
94+
string $user,
95+
string $password,
96+
string $token
97+
): ResponseInterface {
8498
$url = $baseUrl . self::getAuthAppEndpoint() . "?token=$token";
8599
return HttpRequestHelper::sendRequest(
86100
$url,

tests/acceptance/TestHelpers/BehatHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class BehatHelper {
3838
*
3939
* @return Context
4040
*/
41-
public static function getContext(ScenarioScope $scope, InitializedContextEnvironment $environment, string $class): Context {
41+
public static function getContext(
42+
ScenarioScope $scope,
43+
InitializedContextEnvironment $environment,
44+
string $class
45+
): Context {
4246
try {
4347
return $environment->getContext($class);
4448
} catch (ContextNotFoundException $e) {

tests/acceptance/TestHelpers/EmailHelper.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EmailHelper {
3535
*
3636
* @return string
3737
*/
38-
public static function getMailBoxFromEmail(string $emailAddress):string {
38+
public static function getMailBoxFromEmail(string $emailAddress): string {
3939
return explode("@", $emailAddress)[0];
4040
}
4141

@@ -45,7 +45,7 @@ public static function getMailBoxFromEmail(string $emailAddress):string {
4545
*
4646
* @return string
4747
*/
48-
public static function getLocalEmailUrl():string {
48+
public static function getLocalEmailUrl(): string {
4949
$localEmailHost = self::getLocalEmailHost();
5050
$emailPort = \getenv('EMAIL_PORT');
5151
if ($emailPort === false) {
@@ -60,7 +60,7 @@ public static function getLocalEmailUrl():string {
6060
*
6161
* @return string
6262
*/
63-
public static function getEmailHost():string {
63+
public static function getEmailHost(): string {
6464
$emailHost = \getenv('EMAIL_HOST');
6565
if ($emailHost === false) {
6666
$emailHost = "127.0.0.1";
@@ -74,7 +74,7 @@ public static function getEmailHost():string {
7474
*
7575
* @return string
7676
*/
77-
public static function getLocalEmailHost():string {
77+
public static function getLocalEmailHost(): string {
7878
$localEmailHost = \getenv('LOCAL_EMAIL_HOST');
7979
if ($localEmailHost === false) {
8080
$localEmailHost = self::getEmailHost();
@@ -92,7 +92,7 @@ public static function getLocalEmailHost():string {
9292
* @return array
9393
* @throws GuzzleException
9494
*/
95-
public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null):array {
95+
public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null): array {
9696
$response = HttpRequestHelper::get(
9797
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox,
9898
$xRequestId,
@@ -113,7 +113,11 @@ public static function getMailBoxInformation(string $mailBox, ?string $xRequestI
113113
* @return object
114114
* @throws GuzzleException
115115
*/
116-
public static function getBodyOfAnEmailById(string $mailBox, string $mailboxId, ?string $xRequestId = null):object {
116+
public static function getBodyOfAnEmailById(
117+
string $mailBox,
118+
string $mailboxId,
119+
?string $xRequestId = null
120+
): object {
117121
$response = HttpRequestHelper::get(
118122
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId,
119123
$xRequestId,
@@ -142,7 +146,7 @@ public static function getBodyOfLastEmail(
142146
string $xRequestId,
143147
?int $emailNumber = 1,
144148
?int $waitTimeSec = EMAIL_WAIT_TIMEOUT_SEC
145-
):string {
149+
): string {
146150
$currentTime = \time();
147151
$endTime = $currentTime + $waitTimeSec;
148152
$mailBox = self::getMailBoxFromEmail($emailAddress);
@@ -178,7 +182,7 @@ public static function deleteAllEmailsForAMailbox(
178182
string $localInbucketUrl,
179183
?string $xRequestId,
180184
string $mailBox
181-
):ResponseInterface {
185+
): ResponseInterface {
182186
return HttpRequestHelper::delete(
183187
$localInbucketUrl . "/api/v1/mailbox/" . $mailBox,
184188
$xRequestId

tests/acceptance/TestHelpers/GraphHelper.php

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public static function getFileIdRegex(): string {
110110
* @return string
111111
*/
112112
public static function getShareIdRegex(): string {
113-
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
113+
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!'
114+
. self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
114115
}
115116

116117
/**
@@ -1387,7 +1388,11 @@ public static function getUsersOfTwoGroups(
13871388
string $password,
13881389
array $groupIdArray
13891390
): ResponseInterface {
1390-
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') " . "and memberOf/any(m:m/id eq '$groupIdArray[1]')");
1391+
$url = self::getFullUrl(
1392+
$baseUrl,
1393+
'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') "
1394+
. "and memberOf/any(m:m/id eq '$groupIdArray[1]')"
1395+
);
13911396
return HttpRequestHelper::get(
13921397
$url,
13931398
$xRequestId,
@@ -1416,7 +1421,11 @@ public static function getUsersFromOneOrOtherGroup(
14161421
string $firstGroup,
14171422
string $secondGroup
14181423
): ResponseInterface {
1419-
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')");
1424+
$url = self::getFullUrl(
1425+
$baseUrl,
1426+
'users' . '?$filter=memberOf/any(m:m/id '
1427+
. "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')"
1428+
);
14201429
return HttpRequestHelper::get(
14211430
$url,
14221431
$xRequestId,
@@ -1472,7 +1481,11 @@ public static function getUsersWithFilterRolesAssignmentAndMemberOf(
14721481
string $roleId,
14731482
string $groupId
14741483
): ResponseInterface {
1475-
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId ' . "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')");
1484+
$url = self::getFullUrl(
1485+
$baseUrl,
1486+
'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId '
1487+
. "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')"
1488+
);
14761489
return HttpRequestHelper::get(
14771490
$url,
14781491
$xRequestId,
@@ -1669,7 +1682,15 @@ public static function switchSystemLanguage(
16691682
): ResponseInterface {
16701683
$fullUrl = self::getFullUrl($baseUrl, 'me');
16711684
$payload['preferredLanguage'] = $language;
1672-
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PATCH', $user, $password, null, \json_encode($payload));
1685+
return HttpRequestHelper::sendRequest(
1686+
$fullUrl,
1687+
$xRequestId,
1688+
'PATCH',
1689+
$user,
1690+
$password,
1691+
null,
1692+
\json_encode($payload)
1693+
);
16731694
}
16741695

16751696
/**
@@ -1810,7 +1831,13 @@ public static function sendSharingInvitation(
18101831
?string $expirationDateTime
18111832
): ResponseInterface {
18121833
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
1813-
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
1834+
$body = self::createShareInviteBody(
1835+
$shareeIds,
1836+
$shareTypes,
1837+
$permissionsRole,
1838+
$permissionsAction,
1839+
$expirationDateTime
1840+
);
18141841
return HttpRequestHelper::post(
18151842
$url,
18161843
$xRequestId,
@@ -2052,7 +2079,7 @@ public static function disableShareSync(
20522079
string $password,
20532080
string $itemId,
20542081
string $shareSpaceId
2055-
):ResponseInterface {
2082+
): ResponseInterface {
20562083
$url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId");
20572084
return HttpRequestHelper::delete(
20582085
$url,
@@ -2083,7 +2110,7 @@ public static function hideOrUnhideShare(
20832110
string $itemId,
20842111
string $shareSpaceId,
20852112
array $body
2086-
):ResponseInterface {
2113+
): ResponseInterface {
20872114
$url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId");
20882115
return HttpRequestHelper::sendRequest(
20892116
$url,
@@ -2186,7 +2213,13 @@ public static function sendSharingInvitationForDrive(
21862213
?string $expirationDateTime
21872214
): ResponseInterface {
21882215
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite");
2189-
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
2216+
$body = self::createShareInviteBody(
2217+
$shareeIds,
2218+
$shareTypes,
2219+
$permissionsRole,
2220+
$permissionsAction,
2221+
$expirationDateTime
2222+
);
21902223

21912224
return HttpRequestHelper::post(
21922225
$url,

0 commit comments

Comments
 (0)