summaryrefslogtreecommitdiffstats
path: root/tests/integration
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-07-11 15:42:24 -0300
committerVitor Mattos <vitor@php.rio>2022-07-11 17:48:35 -0300
commitc88dad0ef92e5fa348601fcb957e8eb1735133ea (patch)
tree2a15c2aa957149fd4050c83865310982f5d8cc49 /tests/integration
parent03e1cec91d1bc4d36ded77e8cd9f6704c9eaab4b (diff)
Make the room_id not mandatory to define the expire time
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php10
-rw-r--r--tests/integration/features/chat/message-expiration.feature2
-rw-r--r--tests/integration/spreedcheats/appinfo/routes.php2
-rw-r--r--tests/integration/spreedcheats/lib/Controller/ApiController.php24
4 files changed, 9 insertions, 29 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 9392c1685..5aec92abc 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -2589,15 +2589,15 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @When apply message expiration job to room :identifier
+ * @When apply message expiration job
*/
- public function applyMessageExpirationJobToRoom($identifier): void {
+ public function applyMessageExpirationJob(): void {
$currentUser = $this->currentUser;
$this->setCurrentUser('admin');
- $this->sendRequest('GET', '/apps/spreedcheats/get_message_expiration_job/' . self::$identifierToToken[$identifier]);
+ $this->sendRequest('GET', '/apps/spreedcheats/get_message_expiration_job');
$response = $this->getDataFromResponse($this->response);
- Assert::assertIsArray($response, 'Room ' . $identifier . 'not found');
- Assert::assertArrayHasKey('id', $response, 'Job not found by identifier "' . $identifier . '"');
+ Assert::assertIsArray($response, 'Job not found');
+ Assert::assertArrayHasKey('id', $response, 'Job not found');
$this->runOcc(['background-job:execute', $response['id']]);
$this->setCurrentUser($currentUser);
}
diff --git a/tests/integration/features/chat/message-expiration.feature b/tests/integration/features/chat/message-expiration.feature
index 3a4b7d9c8..97aff7e2c 100644
--- a/tests/integration/features/chat/message-expiration.feature
+++ b/tests/integration/features/chat/message-expiration.feature
@@ -19,7 +19,7 @@ Feature: room/message-expiration
| id | type | messageExpiration |
| room | 3 | 3 |
And wait for 3 seconds
- And apply message expiration job to room "room"
+ And apply message expiration job
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant1 | participant1-displayname | Message 1 | [] | |
diff --git a/tests/integration/spreedcheats/appinfo/routes.php b/tests/integration/spreedcheats/appinfo/routes.php
index a1109066d..57798148f 100644
--- a/tests/integration/spreedcheats/appinfo/routes.php
+++ b/tests/integration/spreedcheats/appinfo/routes.php
@@ -26,6 +26,6 @@ declare(strict_types=1);
return [
'ocs' => [
['name' => 'Api#resetSpreed', 'url' => '/', 'verb' => 'DELETE'],
- ['name' => 'Api#getMessageExpirationJob', 'url' => '/get_message_expiration_job/{token}', 'verb' => 'GET'],
+ ['name' => 'Api#getMessageExpirationJob', 'url' => '/get_message_expiration_job', 'verb' => 'GET'],
],
];
diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php
index ff4d6c9de..73ee8d909 100644
--- a/tests/integration/spreedcheats/lib/Controller/ApiController.php
+++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php
@@ -110,19 +110,12 @@ class ApiController extends OCSController {
*
* @return DataResponse
*/
- public function getMessageExpirationJob($token): DataResponse {
- $roomId = $this->getRoomIdByToken($token);
- if (!$roomId) {
- return new DataResponse([], Http::STATUS_NOT_FOUND);
- }
+ public function getMessageExpirationJob(): DataResponse {
$query = $this->db->getQueryBuilder();
$query->select('id')
->from('jobs')
->where(
- $query->expr()->andX(
- $query->expr()->eq('class', $query->createNamedParameter(ExpireChatMessages::class)),
- $query->expr()->eq('argument', $query->createNamedParameter(json_encode(['room_id' => $roomId])))
- )
+ $query->expr()->eq('class', $query->createNamedParameter(ExpireChatMessages::class))
);
$result = $query->executeQuery();
$job = $result->fetchOne();
@@ -131,17 +124,4 @@ class ApiController extends OCSController {
}
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
-
- private function getRoomIdByToken(string $token): ?int {
- $query = $this->db->getQueryBuilder();
- $query->select('id')
- ->from('talk_rooms')
- ->where($query->expr()->eq('token', $query->createNamedParameter($token)));
-
- $result = $query->executeQuery();
- $roomId = (int) $result->fetchOne();
- $result->closeCursor();
-
- return $roomId;
- }
}