diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-03-01 21:45:23 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-03-01 21:47:43 +0300 |
commit | 0b249c188181110a4f2ecb6ec4a9d91fef041579 (patch) | |
tree | 03815667318ef5ea230a1030a4dd11061b6ef80c /tests | |
parent | 73efd7dab4e3a2f202df31d38ac69b049dc02c0e (diff) |
Do now allow messages to be their own parents in threading
A message may send its own ID in the `references` header. In that case
the threading algorithm must ignore the closed loop and not set the
message as its own parent, to prevent an infinite loop later when
checking for anchestors.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/IMAP/Threading/ThreadBuilderTest.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/Unit/IMAP/Threading/ThreadBuilderTest.php b/tests/Unit/IMAP/Threading/ThreadBuilderTest.php index 23c1ed868..2e9959ee0 100644 --- a/tests/Unit/IMAP/Threading/ThreadBuilderTest.php +++ b/tests/Unit/IMAP/Threading/ThreadBuilderTest.php @@ -256,6 +256,33 @@ class ThreadBuilderTest extends TestCase { ); } + public function testBuildTwoWithLoop(): void { + // 1 (but also points to itself) + // | + // 2 + $messages = [ + new Message('s1', 'id1', ['id1']), + new Message('s2', 'id2', ['id1']), + ]; + + $result = $this->builder->build($messages, $this->logger); + + $this->assertEquals( + [ + [ + 'id' => 'id1', + 'children' => [ + [ + 'id' => 'id2', + 'children' => [], + ], + ], + ], + ], + $this->abstract($result) + ); + } + public function testBuildTree(): void { // 1 // / \ |