File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -409,7 +409,13 @@ public function getContentWidth() : int
409
409
*/
410
410
public function getRightHandPadding (int $ contentLength ) : int
411
411
{
412
- return $ this ->getContentWidth () - $ contentLength + $ this ->getPadding ();
412
+ $ rightPadding = $ this ->getContentWidth () - $ contentLength + $ this ->getPadding ();
413
+
414
+ if ($ rightPadding < 0 ) {
415
+ $ rightPadding = 0 ;
416
+ }
417
+
418
+ return $ rightPadding ;
413
419
}
414
420
415
421
public function getSelectedMarker () : string
Original file line number Diff line number Diff line change @@ -301,6 +301,35 @@ public function testRightHandPaddingCalculation() : void
301
301
static ::assertSame (241 , $ style ->getRightHandPadding (50 ));
302
302
}
303
303
304
+ public function testRightHandPaddingReturnsZeroWhenContentLengthTooLong () : void
305
+ {
306
+ $ style = $ this ->getMenuStyle ();
307
+ $ style ->setPadding (0 );
308
+ $ style ->setMargin (0 );
309
+ $ style ->setBorder (0 );
310
+
311
+ $ style ->setWidth (100 );
312
+
313
+ self ::assertEquals (0 , $ style ->getRightHandPadding (100 ));
314
+ self ::assertEquals (0 , $ style ->getRightHandPadding (150 ));
315
+ }
316
+
317
+ public function testRightHandPaddingReturnsZeroWhenContentLengthTooLongBecauseOfBorder () : void
318
+ {
319
+ $ style = $ this ->getMenuStyle ();
320
+ $ style ->setPadding (10 );
321
+ $ style ->setMargin (0 );
322
+ $ style ->setBorder (10 );
323
+
324
+ $ style ->setWidth (100 );
325
+
326
+ self ::assertEquals (11 , $ style ->getRightHandPadding (59 ));
327
+ self ::assertEquals (10 , $ style ->getRightHandPadding (60 ));
328
+ self ::assertEquals (0 , $ style ->getRightHandPadding (70 ));
329
+ self ::assertEquals (0 , $ style ->getRightHandPadding (71 ));
330
+ self ::assertEquals (0 , $ style ->getRightHandPadding (100 ));
331
+ }
332
+
304
333
public function testMargin () : void
305
334
{
306
335
$ style = $ this ->getMenuStyle ();
You can’t perform that action at this time.
0 commit comments