Browse Source
Add integration tests
Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/7327/head
Vitor Mattos
4 years ago
No known key found for this signature in database
GPG Key ID: B7AB4B76A7CA7318
2 changed files with
43 additions and
0 deletions
-
tests/integration/features/bootstrap/FeatureContext.php
-
tests/integration/features/ttl/ttl.feature
|
|
|
@ -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 |
|
|
|
*/ |
|
|
|
|
|
|
|
@ -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) |