Skip to content

Commit

Permalink
[test-only] ApiTest. create tag (#5391)
Browse files Browse the repository at this point in the history
* create tag

* split method

* fix after review
  • Loading branch information
ScharfViktor authored and saw-jan committed Feb 28, 2023
1 parent 33aa2c5 commit feae4da
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 2,441 deletions.
92 changes: 92 additions & 0 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,96 @@ public static function changeOwnPassword(
\json_encode($payload)
);
}

/**
* @param string $baseUrl
* @param string $user
* @param string $password
* @param string $xRequestId
* @param array $body
* @param array $headers
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getTags(
string $baseUrl,
string $user,
string $password,
string $xRequestId = '',
array $body = [],
array $headers = []
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');

return HttpRequestHelper::get($url, $xRequestId, $user, $password, $headers, $body);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $resourceId
* @param array $tagName
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function createTags(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $resourceId,
array $tagName
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');
$payload['resourceId'] = $resourceId;
$payload['tags'] = $tagName;

return HttpRequestHelper::sendRequest(
$url,
$xRequestId,
"PUT",
$user,
$password,
self::getRequestHeaders(),
\json_encode($payload)
);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $resourceId
* @param array $tagName
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function deleteTags(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $resourceId,
array $tagName
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');
$payload['resourceId'] = $resourceId;
$payload['tags'] = $tagName;

return HttpRequestHelper::sendRequest(
$url,
$xRequestId,
"DELETE",
$user,
$password,
self::getRequestHeaders(),
\json_encode($payload)
);
}
}
Loading

0 comments on commit feae4da

Please sign in to comment.