Browse Source

Add integration tests

Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/7327/head
Vitor Mattos 4 years ago
parent
commit
87fd76e367
No known key found for this signature in database GPG Key ID: B7AB4B76A7CA7318
  1. 27
      tests/integration/features/bootstrap/FeatureContext.php
  2. 16
      tests/integration/features/ttl/ttl.feature

27
tests/integration/features/bootstrap/FeatureContext.php

@ -2567,6 +2567,33 @@ class FeatureContext implements Context, SnippetAcceptingContext {
Assert::assertCount(count($expected), $result, 'Reaction count does not match');
}
/**
* @Given user :user set the ttl to :ttl of room :identifier with :statusCode (:apiVersion)
*/
public function userSetTheTtlToWith(string $user, int $ttl, string $identifier, int $statusCode, string $apiVersion = 'v4'): void {
$this->setCurrentUser($user);
$this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/ttl', [
'ttl' => $ttl
]);
$this->assertStatusCode($this->response, $statusCode);
}
/**
* @Given user :user check if ttl of room :identifier is :ttl (:apiVersion)
*/
public function theTtlOfRoomIsV(string $user, string $identifier, int $ttl, string $apiVersion = 'v4') {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room');
$rooms = $this->getDataFromResponse($this->response);
$rooms = array_filter($rooms, function ($room) {
return $room['type'] !== 4;
});
Assert::assertEquals($ttl, $rooms[0]['timeToLive']);
}
/*
* Requests
*/

16
tests/integration/features/ttl/ttl.feature

@ -0,0 +1,16 @@
Feature: room/ttp
Background:
Given user "participant1" exists
Given user "participant2" exists
Given user "participant3" exists
Scenario: Enable TTL and check after expire
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
And user "participant1" set the ttl to -1 of room "room" with 400 (v4)
And user "participant2" set the ttl to 3 of room "room" with 403 (v4)
And user "participant3" set the ttl to 3 of room "room" with 404 (v4)
And user "participant1" set the ttl to 3 of room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
And user "participant1" check if ttl of room "room" is 3 (v4)
Loading…
Cancel
Save