summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-07-14 20:22:19 -0300
committerVitor Mattos <vitor@php.rio>2022-07-15 09:38:52 -0300
commit380fbcfdc8f3c3565fd451468b2009e9b475ced6 (patch)
tree8ce2737a85a8d20bfc50d0ad8ef2daeaea1b5ebe /tests
parent69782e910f090a5492909f8b544e98ca1668e09a (diff)
Convert specific command to generic create and update
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/CommandLineTrait.php4
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php16
-rw-r--r--tests/integration/features/command/create.feature10
-rw-r--r--tests/integration/features/command/update.feature23
-rw-r--r--tests/psalm-baseline.xml5
5 files changed, 52 insertions, 6 deletions
diff --git a/tests/integration/features/bootstrap/CommandLineTrait.php b/tests/integration/features/bootstrap/CommandLineTrait.php
index b30904729..589e299f5 100644
--- a/tests/integration/features/bootstrap/CommandLineTrait.php
+++ b/tests/integration/features/bootstrap/CommandLineTrait.php
@@ -79,7 +79,9 @@ trait CommandLineTrait {
*/
public function invokingTheCommand($cmd) {
if (preg_match('/room-name:(?P<token>\w+)/', $cmd, $matches)) {
- $cmd = preg_replace('/room-name:(\w+)/', self::$identifierToToken[$matches['token']], $cmd);
+ if (array_key_exists($matches['token'], self::$identifierToToken)) {
+ $cmd = preg_replace('/room-name:(\w+)/', self::$identifierToToken[$matches['token']], $cmd);
+ }
}
$args = explode(' ', $cmd);
$this->runOcc($args);
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 82208d6c0..552deb7c9 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -254,6 +254,22 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @When /^user "([^"]*)" get token of room "([^"]*)" \((v4)\)$/
+ */
+ public function storeTokenOfRoom(string $user, string $room, string $apiVersion) {
+ $this->setCurrentUser($user);
+ $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room');
+ $response = $this->getDataFromResponse($this->response);
+ $result = array_filter($response, fn ($p) => $p['name'] === $room);
+ if (!count($result)) {
+ throw new \Exception('User ' . $user . ' is not participant of room ' . $room);
+ }
+ $result = current($result);
+ self::$identifierToToken[$room] = $result['token'];
+ self::$tokenToIdentifier[$result['token']] = $room;
+ }
+
+ /**
* @Then /^user "([^"]*)" is participant of the following rooms \((v4)\)$/
*
* @param string $user
diff --git a/tests/integration/features/command/create.feature b/tests/integration/features/command/create.feature
index 168be2d8d..409d97401 100644
--- a/tests/integration/features/command/create.feature
+++ b/tests/integration/features/command/create.feature
@@ -99,3 +99,13 @@ Feature: create
When invoking occ with "talk:room:create room1 --user participant1 --owner participant1 --public --description ०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८च०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८च०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८च०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८च०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८९०१२३४५६७८च०"
Then the command failed with exit code 1
And the command output contains the text "Invalid room description"
+
+ Scenario: Create a public room with message expiration time
+ Given invoking occ with "talk:room:create room1 --user participant1 --owner participant1 --public --message-expiration=3"
+ And user "participant1" get token of room "room1" (v4)
+ And the command output contains the text "Room successfully created"
+ And the command was successful
+ And user "participant1" sends message "Message 1" to room "room1" with 201
+ And wait for 3 seconds
+ And apply message expiration job manually
+ Then user "participant1" sees the following messages in room "room1" with 200
diff --git a/tests/integration/features/command/update.feature b/tests/integration/features/command/update.feature
new file mode 100644
index 000000000..e9a07795c
--- /dev/null
+++ b/tests/integration/features/command/update.feature
@@ -0,0 +1,23 @@
+Feature: update
+
+ Background:
+ Given user "participant1" exists
+
+ Scenario: Create a public room with message expiration time and update removing the expiration time
+ Given invoking occ with "talk:room:create room1 --user participant1 --owner participant1 --public --message-expiration=3"
+ And user "participant1" get token of room "room1" (v4)
+ And the command output contains the text "Room successfully created"
+ And the command was successful
+ And user "participant1" sends message "Message 1" to room "room1" with 201
+ And wait for 3 seconds
+ And apply message expiration job manually
+ And user "participant1" sees the following messages in room "room1" with 200
+ And invoking occ with "talk:room:update room-name:room1 --message-expiration=0"
+ And the command output contains the text "Room successfully updated"
+ And the command was successful
+ And user "participant1" sends message "Message 2" to room "room1" with 201
+ And wait for 3 seconds
+ And apply message expiration job manually
+ And user "participant1" sees the following messages in room "room1" with 200
+ | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
+ | room1 | users | participant1 | participant1-displayname | Message 2 | [] | |
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index 43002ad49..0b509c127 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -87,11 +87,6 @@
<code>Base</code>
</UndefinedClass>
</file>
- <file src="lib/Command/Room/MessageExpiration.php">
- <UndefinedClass occurrences="1">
- <code>Base</code>
- </UndefinedClass>
- </file>
<file src="lib/Command/Room/Promote.php">
<UndefinedClass occurrences="1">
<code>Base</code>