delete unnecessary steps from context files

This commit is contained in:
Viktor Scharf
2025-02-05 19:43:12 +01:00
parent 46df1a041e
commit 72fd765b93
14 changed files with 295 additions and 1586 deletions

View File

@@ -37,40 +37,40 @@ require_once 'bootstrap.php';
class OCSContext implements Context {
private FeatureContext $featureContext;
/**
* @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
*
* @param string $verb
* @param string $url
*
* @return void
*/
public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url);
$this->featureContext->setResponse($response);
}
// /**
// * @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
// *
// * @param string $verb
// * @param string $url
// *
// * @return void
// */
// public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void {
// $response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url);
// $this->featureContext->setResponse($response);
// }
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" using password "([^"]*)"$/
*
* @param string $user
* @param string $verb
* @param string $url
* @param string|null $password
*
* @return void
*/
public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
$url,
null,
$password
);
$this->featureContext->setResponse($response);
}
// /**
// * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
// * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" using password "([^"]*)"$/
// *
// * @param string $user
// * @param string $verb
// * @param string $url
// * @param string|null $password
// *
// * @return void
// */
// public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void {
// $response = $this->sendRequestToOcsEndpoint(
// $user,
// $verb,
// $url,
// null,
// $password
// );
// $this->featureContext->setResponse($response);
// }
/**
* @param string $user
@@ -162,59 +162,59 @@ class OCSContext implements Context {
);
}
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
*
* @param string $user
* @param string $verb
* @param string $url
* @param TableNode|null $body
* @param string|null $password
*
* @return void
*/
public function userSendHTTPMethodToOcsApiEndpointWithBody(
string $user,
string $verb,
string $url,
?TableNode $body = null,
?string $password = null
): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
$url,
$body,
$password
);
$this->featureContext->setResponse($response);
}
// /**
// * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
// *
// * @param string $user
// * @param string $verb
// * @param string $url
// * @param TableNode|null $body
// * @param string|null $password
// *
// * @return void
// */
// public function userSendHTTPMethodToOcsApiEndpointWithBody(
// string $user,
// string $verb,
// string $url,
// ?TableNode $body = null,
// ?string $password = null
// ): void {
// $response = $this->sendRequestToOcsEndpoint(
// $user,
// $verb,
// $url,
// $body,
// $password
// );
// $this->featureContext->setResponse($response);
// }
/**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url
* @When the administrator sends HTTP method :verb to OCS API endpoint :url using password :password
*
* @param string $verb
* @param string $url
* @param string|null $password
*
* @return void
*/
public function theAdministratorSendsHttpMethodToOcsApiEndpoint(
string $verb,
string $url,
?string $password = null
): void {
$this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(),
$verb,
$url,
null,
$password
)
);
}
// /**
// * @When the administrator sends HTTP method :verb to OCS API endpoint :url
// * @When the administrator sends HTTP method :verb to OCS API endpoint :url using password :password
// *
// * @param string $verb
// * @param string $url
// * @param string|null $password
// *
// * @return void
// */
// public function theAdministratorSendsHttpMethodToOcsApiEndpoint(
// string $verb,
// string $url,
// ?string $password = null
// ): void {
// $this->featureContext->setResponse(
// $this->sendRequestToOcsEndpoint(
// $this->featureContext->getAdminUsername(),
// $verb,
// $url,
// null,
// $password
// )
// );
// }
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/
@@ -247,158 +247,158 @@ class OCSContext implements Context {
);
}
/**
* @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/
*
* @param string $verb
* @param string $url
* @param TableNode $headersTable
*
* @return void
* @throws Exception
*/
public function administratorSendsToOcsApiEndpointWithHeaders(
string $verb,
string $url,
TableNode $headersTable
): void {
$user = $this->featureContext->getAdminUsername();
$password = $this->featureContext->getPasswordForUser($user);
$this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint(
$user,
$verb,
$url,
null,
$password,
$headersTable->getRowsHash()
)
);
}
// /**
// * @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/
// *
// * @param string $verb
// * @param string $url
// * @param TableNode $headersTable
// *
// * @return void
// * @throws Exception
// */
// public function administratorSendsToOcsApiEndpointWithHeaders(
// string $verb,
// string $url,
// TableNode $headersTable
// ): void {
// $user = $this->featureContext->getAdminUsername();
// $password = $this->featureContext->getPasswordForUser($user);
// $this->featureContext->setResponse(
// $this->sendRequestToOcsEndpoint(
// $user,
// $verb,
// $url,
// null,
// $password,
// $headersTable->getRowsHash()
// )
// );
// }
/**
* @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers using password "([^"]*)"$/
*
* @param string $verb
* @param string $url
* @param string $password
* @param TableNode $headersTable
*
* @return void
* @throws Exception
*/
public function administratorSendsToOcsApiEndpointWithHeadersAndPassword(
string $verb,
string $url,
string $password,
TableNode $headersTable
): void {
$this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(),
$verb,
$url,
null,
$password,
$headersTable->getRowsHash()
)
);
}
// /**
// * @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers using password "([^"]*)"$/
// *
// * @param string $verb
// * @param string $url
// * @param string $password
// * @param TableNode $headersTable
// *
// * @return void
// * @throws Exception
// */
// public function administratorSendsToOcsApiEndpointWithHeadersAndPassword(
// string $verb,
// string $url,
// string $password,
// TableNode $headersTable
// ): void {
// $this->featureContext->setResponse(
// $this->sendRequestToOcsEndpoint(
// $this->featureContext->getAdminUsername(),
// $verb,
// $url,
// null,
// $password,
// $headersTable->getRowsHash()
// )
// );
// }
/**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url with body
*
* @param string $verb
* @param string $url
* @param TableNode|null $body
*
* @return void
*/
public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody(
string $verb,
string $url,
?TableNode $body
): void {
$response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody(
$verb,
$url,
$body
);
$this->featureContext->setResponse($response);
}
// /**
// * @When the administrator sends HTTP method :verb to OCS API endpoint :url with body
// *
// * @param string $verb
// * @param string $url
// * @param TableNode|null $body
// *
// * @return void
// */
// public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody(
// string $verb,
// string $url,
// ?TableNode $body
// ): void {
// $response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody(
// $verb,
// $url,
// $body
// );
// $this->featureContext->setResponse($response);
// }
/**
* @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
*
* @param string $verb
* @param string $url
* @param TableNode $body
*
* @return void
*/
public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody(
$verb,
$url,
$body
);
$this->featureContext->setResponse($response);
}
// /**
// * @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
// *
// * @param string $verb
// * @param string $url
// * @param TableNode $body
// *
// * @return void
// */
// public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void {
// $response = $this->theUserSendsToOcsApiEndpointWithBody(
// $verb,
// $url,
// $body
// );
// $this->featureContext->setResponse($response);
// }
/**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url with body using password :password
*
* @param string $verb
* @param string $url
* @param string $password
* @param TableNode $body
*
* @return void
*/
public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword(
string $verb,
string $url,
string $password,
TableNode $body
): void {
$admin = $this->featureContext->getAdminUsername();
$response = $this->sendRequestToOcsEndpoint(
$admin,
$verb,
$url,
$body,
$password
);
$this->featureContext->setResponse($response);
}
// /**
// * @When the administrator sends HTTP method :verb to OCS API endpoint :url with body using password :password
// *
// * @param string $verb
// * @param string $url
// * @param string $password
// * @param TableNode $body
// *
// * @return void
// */
// public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword(
// string $verb,
// string $url,
// string $password,
// TableNode $body
// ): void {
// $admin = $this->featureContext->getAdminUsername();
// $response = $this->sendRequestToOcsEndpoint(
// $admin,
// $verb,
// $url,
// $body,
// $password
// );
// $this->featureContext->setResponse($response);
// }
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body using password "([^"]*)"$/
*
* @param string $user
* @param string $verb
* @param string $url
* @param string $password
* @param TableNode $body
*
* @return void
*/
public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword(
string $user,
string $verb,
string $url,
string $password,
TableNode $body
): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
$url,
$body,
$password
);
$this->featureContext->setResponse($response);
}
// /**
// * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body using password "([^"]*)"$/
// *
// * @param string $user
// * @param string $verb
// * @param string $url
// * @param string $password
// * @param TableNode $body
// *
// * @return void
// */
// public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword(
// string $user,
// string $verb,
// string $url,
// string $password,
// TableNode $body
// ): void {
// $response = $this->sendRequestToOcsEndpoint(
// $user,
// $verb,
// $url,
// $body,
// $password
// );
// $this->featureContext->setResponse($response);
// }
/**
* @Then /^the OCS status code should be "([^"]*)"$/
@@ -494,64 +494,64 @@ class OCSContext implements Context {
);
}
/**
* Check the text in an OCS status message
*
* @Then /^the OCS status message about user "([^"]*)" should be "([^"]*)"$/
*
* @param string $user
* @param string $statusMessage
*
* @return void
*/
public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void {
$user = \strtolower($this->featureContext->getActualUsername($user));
$statusMessage = $this->featureContext->substituteInLineCodes(
$statusMessage,
$user
);
Assert::assertEquals(
$statusMessage,
$this->getOCSResponseStatusMessage(
$this->featureContext->getResponse()
),
'Unexpected OCS status message :"' . $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse()
) . '" in response'
);
}
// /**
// * Check the text in an OCS status message
// *
// * @Then /^the OCS status message about user "([^"]*)" should be "([^"]*)"$/
// *
// * @param string $user
// * @param string $statusMessage
// *
// * @return void
// */
// public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void {
// $user = \strtolower($this->featureContext->getActualUsername($user));
// $statusMessage = $this->featureContext->substituteInLineCodes(
// $statusMessage,
// $user
// );
// Assert::assertEquals(
// $statusMessage,
// $this->getOCSResponseStatusMessage(
// $this->featureContext->getResponse()
// ),
// 'Unexpected OCS status message :"' . $this->getOCSResponseStatusMessage(
// $this->featureContext->getResponse()
// ) . '" in response'
// );
// }
/**
* Check the text in an OCS status message.
* Use this step form if the expected text contains double quotes,
* single quotes and other content that theOCSStatusMessageShouldBe()
* cannot handle.
*
* After the step, write the expected text in PyString form like:
*
* """
* File "abc.txt" can't be shared due to reason "xyz"
* """
*
* @Then /^the OCS status message should be:$/
*
* @param PyStringNode $statusMessage
*
* @return void
*/
public function theOCSStatusMessageShouldBePyString(
PyStringNode $statusMessage
): void {
Assert::assertEquals(
$statusMessage->getRaw(),
$this->getOCSResponseStatusMessage(
$this->featureContext->getResponse()
),
'Unexpected OCS status message: "' . $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse()
) . '" in response'
);
}
// /**
// * Check the text in an OCS status message.
// * Use this step form if the expected text contains double quotes,
// * single quotes and other content that theOCSStatusMessageShouldBe()
// * cannot handle.
// *
// * After the step, write the expected text in PyString form like:
// *
// * """
// * File "abc.txt" can't be shared due to reason "xyz"
// * """
// *
// * @Then /^the OCS status message should be:$/
// *
// * @param PyStringNode $statusMessage
// *
// * @return void
// */
// public function theOCSStatusMessageShouldBePyString(
// PyStringNode $statusMessage
// ): void {
// Assert::assertEquals(
// $statusMessage->getRaw(),
// $this->getOCSResponseStatusMessage(
// $this->featureContext->getResponse()
// ),
// 'Unexpected OCS status message: "' . $this->getOCSResponseStatusMessage(
// $this->featureContext->getResponse()
// ) . '" in response'
// );
// }
/**
* Parses the xml answer to get ocs response which doesn't match with