ILIAS  release_8 Revision v8.24
PostingReplySubjectBuilderTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
23class PostingReplySubjectBuilderTest extends TestCase
24{
28 public function postingSubjectProvider(): Generator
29 {
30 yield 'Subject without reply prefix' => [
31 'subject' => 'This is a subject',
32 'prefix' => 'Re:',
33 'repetition_prefix' => 'Re (%s):',
34 'expected' => 'Re: This is a subject'
35 ];
36
37 yield 'Subject without reply prefix and prefix without expected end character' => [
38 'subject' => 'This is a subject',
39 'prefix' => 'Re',
40 'repetition_prefix' => 'Re (%s):',
41 'expected' => 'Re: This is a subject'
42 ];
43
44 yield 'Subject with repeated reply prefix' => [
45 'subject' => 'Re: Re: Re: This is a subject',
46 'prefix' => 'Re:',
47 'repetition_prefix' => 'Re (%s):',
48 'expected' => 'Re (4): This is a subject'
49 ];
50
51 yield 'Subject with optimized repeated reply prefix' => [
52 'subject' => 'Re (3): This is a subject',
53 'prefix' => 'Re:',
54 'repetition_prefix' => 'Re (%s):',
55 'expected' => 'Re (4): This is a subject'
56 ];
57
58 yield 'Subject with optimized repeated reply prefix (without spaces)' => [
59 'subject' => 'Re(3): This is a subject',
60 'prefix' => 'Re:',
61 'repetition_prefix' => 'Re (%s):',
62 'expected' => 'Re(4): This is a subject'
63 ];
64
65 yield 'Subject with repeated reply prefix and repetition-prefix without expected end character' => [
66 'subject' => 'Re: Re: Re: This is a subject',
67 'prefix' => 'Re:',
68 'repetition_prefix' => 'Re (%s)',
69 'expected' => 'Re (4): This is a subject'
70 ];
71
72 yield 'Subject with optimized repeated reply prefix and repetition-prefix without expected end character' => [
73 'subject' => 'Re (3): This is a subject',
74 'prefix' => 'Re:',
75 'repetition_prefix' => 'Re (%s)',
76 'expected' => 'Re (4): This is a subject'
77 ];
78
79 yield 'Subject with optimized repeated reply prefix (without spaces) and repetition-prefix without expected end character' => [
80 'subject' => 'Re(3): This is a subject',
81 'prefix' => 'Re:',
82 'repetition_prefix' => 'Re (%s)',
83 'expected' => 'Re(4): This is a subject'
84 ];
85 }
86
91 string $subject,
92 string $reply_prefix,
93 string $optimized_repeated_reply_prefix,
94 string $expected_result
95 ): void {
96 $posting_subject_builder = new PostingReplySubjectBuilder($reply_prefix, $optimized_repeated_reply_prefix);
97 $result = $posting_subject_builder->build($subject);
98
99 $this->assertSame($expected_result, $result);
100 }
101}
testPostingSubjectBuilder(string $subject, string $reply_prefix, string $optimized_repeated_reply_prefix, string $expected_result)
@dataProvider postingSubjectProvider
build(string $subject_of_parent_posting)