File tree Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ public function addLineBreak(string $breakChar = ' ', int $lines = 1) : self
138
138
return $ this ;
139
139
}
140
140
141
- public function addAsciiArt (string $ art , string $ position = AsciiArtItem::POSITION_CENTER , string $ alt ) : self
141
+ public function addAsciiArt (string $ art , string $ position = AsciiArtItem::POSITION_CENTER , string $ alt = '' ) : self
142
142
{
143
143
$ this ->addMenuItem (new AsciiArtItem ($ art , $ position , $ alt ));
144
144
Original file line number Diff line number Diff line change @@ -245,16 +245,23 @@ public function testAsciiArtWithSpecificPosition() : void
245
245
$ this ->checkItems ($ menu , $ expected );
246
246
}
247
247
248
- public function testAddAsciiArtDetectsArtThatDoesNotFitAndSkipsIt () : void
248
+ public function testAsciiArtWithAlt () : void
249
249
{
250
250
$ builder = new CliMenuBuilder ;
251
- $ builder ->setWidth ( 1 );
252
- $ builder ->addAsciiArt ("// \n// " , AsciiArtItem::POSITION_LEFT );
251
+ $ builder ->disableDefaultItems ( );
252
+ $ builder ->addAsciiArt ("// \n// " , AsciiArtItem::POSITION_LEFT , ' Some ALT ' );
253
253
$ menu = $ builder ->build ();
254
254
255
- foreach ($ menu ->getItems () as $ menuItem ) {
256
- $ this ->assertNotInstanceOf (AsciiArtItem::class, $ menuItem );
257
- }
255
+ $ expected = [
256
+ [
257
+ 'class ' => AsciiArtItem::class,
258
+ 'text ' => "// \n// " ,
259
+ 'position ' => AsciiArtItem::POSITION_LEFT ,
260
+ 'alternateText ' => 'Some ALT '
261
+ ]
262
+ ];
263
+
264
+ $ this ->checkItems ($ menu , $ expected );
258
265
}
259
266
260
267
public function testEndThrowsExceptionIfNoParentBuilder () : void
Original file line number Diff line number Diff line change @@ -127,4 +127,18 @@ public function testHideAndShowItemExtraHasNoEffect() : void
127
127
$ item ->hideItemExtra ();
128
128
$ this ->assertFalse ($ item ->showsItemExtra ());
129
129
}
130
+
131
+ public function testGetRowsReturnsStaticAltItemWhenWidthIsTooSmall ()
132
+ {
133
+ $ menuStyle = $ this ->createMock (MenuStyle::class);
134
+
135
+ $ menuStyle
136
+ ->expects ($ this ->any ())
137
+ ->method ('getContentWidth ' )
138
+ ->will ($ this ->returnValue (10 ));
139
+
140
+ $ item = new AsciiArtItem ('TOO LONG. SO SO LONG. ' , AsciiArtItem::POSITION_CENTER , 'my alt ' );
141
+
142
+ self ::assertSame (['my alt ' ], $ item ->getRows ($ menuStyle ));
143
+ }
130
144
}
You can’t perform that action at this time.
0 commit comments