Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-05-23 21:38:52 +0300
committerVitor Mattos <vitor@php.rio>2022-06-30 21:01:27 +0300
commit5b6dc78fe6574bd6c52dd00f9c9a9804994f71dc (patch)
tree7ac7b3f173d0f61f3243ab8d590d34487ac293ff /tests
parent67f49f14b592e57cddcc3b00bdd1bc0babf287a1 (diff)
Use DataResponse and returning 404
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php3
-rw-r--r--tests/integration/spreedcheats/lib/Controller/ApiController.php12
2 files changed, 7 insertions, 8 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index b214ac704..74970dbd2 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -2603,8 +2603,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$currentUser = $this->currentUser;
$this->setCurrentUser('admin');
$this->sendRequest('GET', '/apps/spreedcheats/get_message_expire_job/' . self::$identifierToToken[$identifier]);
- $response = $this->response->getBody()->getContents();
- $response = json_decode($response, true);
+ $response = $this->getDataFromResponse($this->response);
Assert::assertIsArray($response, 'Room ' . $identifier . 'not found');
Assert::assertArrayHasKey('id', $response);
$this->runOcc(['background-job:execute', $response['id']]);
diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php
index 133b3eac5..efcc56403 100644
--- a/tests/integration/spreedcheats/lib/Controller/ApiController.php
+++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php
@@ -26,9 +26,9 @@ declare(strict_types=1);
namespace OCA\SpreedCheats\Controller;
use OCA\Talk\BackgroundJob\ApplyMessageExpire;
+use OCP\AppFramework\Http;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Http\DataResponse;
-use OCP\AppFramework\Http\JSONResponse;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\Share\IShare;
@@ -108,12 +108,12 @@ class ApiController extends OCSController {
/**
* @NoCSRFRequired
*
- * @return JSONResponse
+ * @return DataResponse
*/
- public function getMessageExpireJob($token): JSONResponse {
+ public function getMessageExpireJob($token): DataResponse {
$roomId = $this->getRoomIdByToken($token);
if (!$roomId) {
- return new JSONResponse();
+ return new DataResponse([], Http::STATUS_NOT_FOUND);
}
$query = $this->db->getQueryBuilder();
$query->select('id')
@@ -127,9 +127,9 @@ class ApiController extends OCSController {
$result = $query->executeQuery();
$job = $result->fetchOne();
if ($job) {
- return new JSONResponse(['id' => (int) $job]);
+ return new DataResponse(['id' => (int) $job]);
}
- return new JSONResponse();
+ return new DataResponse([], Http::STATUS_NOT_FOUND);
}
private function getRoomIdByToken(string $token): ?string {