diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-30 16:36:50 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-12-08 11:36:55 +0300 |
commit | 6206ca7b9aefd7de09637530ac0f8d44cc3e238c (patch) | |
tree | 372100ccaef9dc0882a926ed2977ac11f5ef1f72 /tests | |
parent | 1700f7750ec56f5b2e9a61f15be9f812ec7ae8b4 (diff) |
Make sure participant names are optional (required for v3)
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 29bceef16..24d815174 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -155,30 +155,6 @@ class FeatureContext implements Context, SnippetAcceptingContext { private function assertRooms($rooms, TableNode $formData) { Assert::assertCount(count($formData->getHash()), $rooms, 'Room count does not match'); Assert::assertEquals($formData->getHash(), array_map(function ($room, $expectedRoom) { - $participantNames = array_map(function ($participant) { - return $participant['name']; - }, $room['participants']); - - // When participants have the same last ping the order in which they - // are returned from the server is undefined. That is the most - // common case during the tests, so by default the list of - // participants returned by the server is sorted alphabetically. In - // order to check the exact order of participants returned by the - // server " [exact order]" can be appended in the test definition to - // the list of expected participants of the room. - if (strpos($expectedRoom['participants'], ' [exact order]') === false) { - sort($participantNames); - } else { - // "end(array_keys(..." would generate the Strict Standards - // error "Only variables should be passed by reference". - $participantNamesKeys = array_keys($participantNames); - $lastParticipantKey = end($participantNamesKeys); - - // Append " [exact order]" to the last participant so the - // imploded string is the same as the expected one. - $participantNames[$lastParticipantKey] .= ' [exact order]'; - } - $data = []; if (isset($expectedRoom['id'])) { $data['id'] = self::$tokenToIdentifier[$room['token']]; @@ -199,6 +175,29 @@ class FeatureContext implements Context, SnippetAcceptingContext { $data['participantType'] = (string) $room['participantType']; } if (isset($expectedRoom['participants'])) { + $participantNames = array_map(function ($participant) { + return $participant['name']; + }, $room['participants']); + + // When participants have the same last ping the order in which they + // are returned from the server is undefined. That is the most + // common case during the tests, so by default the list of + // participants returned by the server is sorted alphabetically. In + // order to check the exact order of participants returned by the + // server " [exact order]" can be appended in the test definition to + // the list of expected participants of the room. + if (strpos($expectedRoom['participants'], ' [exact order]') === false) { + sort($participantNames); + } else { + // "end(array_keys(..." would generate the Strict Standards + // error "Only variables should be passed by reference". + $participantNamesKeys = array_keys($participantNames); + $lastParticipantKey = end($participantNamesKeys); + + // Append " [exact order]" to the last participant so the + // imploded string is the same as the expected one. + $participantNames[$lastParticipantKey] .= ' [exact order]'; + } $data['participants'] = implode(', ', $participantNames); } |