File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/Symfony/Component/Notifier/Bridge/Slack Expand file tree Collapse file tree 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
9797 */
9898 public function block (SlackBlockInterface $ block ): self
9999 {
100+ if (50 === \count ($ this ->options ['blocks ' ] ?? [])) {
101+ throw new \LogicException ('Maximum number of blocks should not exceed 50. ' );
102+ }
103+
100104 $ this ->options ['blocks ' ][] = $ block ->toArray ();
101105
102106 return $ this ;
Original file line number Diff line number Diff line change 1414use PHPUnit \Framework \TestCase ;
1515use Symfony \Bridge \PhpUnit \ExpectDeprecationTrait ;
1616use Symfony \Component \Notifier \Bridge \Slack \Block \SlackDividerBlock ;
17+ use Symfony \Component \Notifier \Bridge \Slack \Block \SlackSectionBlock ;
1718use Symfony \Component \Notifier \Bridge \Slack \SlackOptions ;
1819use Symfony \Component \Notifier \Notification \Notification ;
1920
@@ -187,4 +188,17 @@ public function fromNotificationProvider(): iterable
187188 (new Notification ($ subject ))->emoji ($ emoji )->content ($ content ),
188189 ];
189190 }
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+ }
190204}
You can’t perform that action at this time.
0 commit comments