File tree 2 files changed +18
-0
lines changed
src/Symfony/Component/Notifier/Bridge/Slack
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ public function asUser(bool $bool): self
97
97
*/
98
98
public function block (SlackBlockInterface $ block ): self
99
99
{
100
+ if (50 === \count ($ this ->options ['blocks ' ] ?? [])) {
101
+ throw new \LogicException ('Maximum number of blocks should not exceed 50. ' );
102
+ }
103
+
100
104
$ this ->options ['blocks ' ][] = $ block ->toArray ();
101
105
102
106
return $ this ;
Original file line number Diff line number Diff line change 14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Bridge \PhpUnit \ExpectDeprecationTrait ;
16
16
use Symfony \Component \Notifier \Bridge \Slack \Block \SlackDividerBlock ;
17
+ use Symfony \Component \Notifier \Bridge \Slack \Block \SlackSectionBlock ;
17
18
use Symfony \Component \Notifier \Bridge \Slack \SlackOptions ;
18
19
use Symfony \Component \Notifier \Notification \Notification ;
19
20
@@ -187,4 +188,17 @@ public function fromNotificationProvider(): iterable
187
188
(new Notification ($ subject ))->emoji ($ emoji )->content ($ content ),
188
189
];
189
190
}
191
+
192
+ public function testThrowsWhenBlocksLimitReached ()
193
+ {
194
+ $ options = new SlackOptions ();
195
+ for ($ i = 0 ; $ i < 50 ; ++$ i ) {
196
+ $ options ->block (new SlackSectionBlock ());
197
+ }
198
+
199
+ $ this ->expectException (\LogicException::class);
200
+ $ this ->expectExceptionMessage ('Maximum number of blocks should not exceed 50. ' );
201
+
202
+ $ options ->block (new SlackSectionBlock ());
203
+ }
190
204
}
You can’t perform that action at this time.
0 commit comments