ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PostingReplySubjectBuilderTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22use PHPUnit\Framework\Attributes\DataProvider;
23
24class PostingReplySubjectBuilderTest extends TestCase
25{
29 public static function postingSubjectProvider(): Generator
30 {
31 yield 'Subject without reply prefix' => [
32 'subject' => 'This is a subject',
33 'reply_prefix' => 'Re:',
34 'optimized_repeated_reply_prefix' => 'Re (%s):',
35 'expected_result' => 'Re: This is a subject'
36 ];
37
38 yield 'Subject without reply prefix and prefix without expected end character' => [
39 'subject' => 'This is a subject',
40 'reply_prefix' => 'Re',
41 'optimized_repeated_reply_prefix' => 'Re (%s):',
42 'expected_result' => 'Re: This is a subject'
43 ];
44
45 yield 'Subject with repeated reply prefix' => [
46 'subject' => 'Re: Re: Re: This is a subject',
47 'reply_prefix' => 'Re:',
48 'optimized_repeated_reply_prefix' => 'Re (%s):',
49 'expected_result' => 'Re (4): This is a subject'
50 ];
51
52 yield 'Subject with optimized repeated reply prefix' => [
53 'subject' => 'Re (3): This is a subject',
54 'reply_prefix' => 'Re:',
55 'optimized_repeated_reply_prefix' => 'Re (%s):',
56 'expected_result' => 'Re (4): This is a subject'
57 ];
58
59 yield 'Subject with optimized repeated reply prefix (without spaces)' => [
60 'subject' => 'Re(3): This is a subject',
61 'reply_prefix' => 'Re:',
62 'optimized_repeated_reply_prefix' => 'Re (%s):',
63 'expected_result' => 'Re(4): This is a subject'
64 ];
65
66 yield 'Subject with repeated reply prefix and repetition-prefix without expected end character' => [
67 'subject' => 'Re: Re: Re: This is a subject',
68 'reply_prefix' => 'Re:',
69 'optimized_repeated_reply_prefix' => 'Re (%s)',
70 'expected_result' => 'Re (4): This is a subject'
71 ];
72
73 yield 'Subject with optimized repeated reply prefix and repetition-prefix without expected end character' => [
74 'subject' => 'Re (3): This is a subject',
75 'reply_prefix' => 'Re:',
76 'optimized_repeated_reply_prefix' => 'Re (%s)',
77 'expected_result' => 'Re (4): This is a subject'
78 ];
79
80 yield 'Subject with optimized repeated reply prefix (without spaces) and repetition-prefix without expected end character' => [
81 'subject' => 'Re(3): This is a subject',
82 'reply_prefix' => 'Re:',
83 'optimized_repeated_reply_prefix' => 'Re (%s)',
84 'expected_result' => 'Re(4): This is a subject'
85 ];
86 }
87
88 #[DataProvider('postingSubjectProvider')]
90 string $subject,
91 string $reply_prefix,
92 string $optimized_repeated_reply_prefix,
93 string $expected_result
94 ): void {
95 $posting_subject_builder = new \ILIAS\components\Forum\Subject\PostingReplySubjectBuilder(
96 $reply_prefix,
97 $optimized_repeated_reply_prefix
98 );
99 $result = $posting_subject_builder->build($subject);
100
101 $this->assertSame($expected_result, $result);
102 }
103}
testPostingSubjectBuilder(string $subject, string $reply_prefix, string $optimized_repeated_reply_prefix, string $expected_result)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.