@@ -91,17 +91,8 @@ public function testGetRowsCenterAligned() : void
91
91
$ item = new AsciiArtItem ("// \n// " , AsciiArtItem::POSITION_CENTER );
92
92
$ this ->assertEquals (
93
93
[
94
- " // " ,
95
- " // " ,
96
- ],
97
- $ item ->getRows ($ menuStyle )
98
- );
99
-
100
- $ item = new AsciiArtItem (" // \n////////// " , AsciiArtItem::POSITION_CENTER );
101
- $ this ->assertEquals (
102
- [
103
- " // " ,
104
- "////////// " ,
94
+ " // " ,
95
+ " // " ,
105
96
],
106
97
$ item ->getRows ($ menuStyle )
107
98
);
@@ -119,17 +110,8 @@ public function testGetRowsCenterAlignedWithOddWidth() : void
119
110
$ item = new AsciiArtItem ("// \n// " , AsciiArtItem::POSITION_CENTER );
120
111
$ this ->assertEquals (
121
112
[
122
- " // " ,
123
- " // " ,
124
- ],
125
- $ item ->getRows ($ menuStyle )
126
- );
127
-
128
- $ item = new AsciiArtItem (" // \n////////// " , AsciiArtItem::POSITION_CENTER );
129
- $ this ->assertEquals (
130
- [
131
- " // " ,
132
- " ////////// " ,
113
+ " // " ,
114
+ " // " ,
133
115
],
134
116
$ item ->getRows ($ menuStyle )
135
117
);
@@ -146,7 +128,7 @@ public function testHideAndShowItemExtraHasNoEffect() : void
146
128
$ this ->assertFalse ($ item ->showsItemExtra ());
147
129
}
148
130
149
- public function testGetRowsReturnsStaticAltItemWhenWidthIsTooSmall ()
131
+ public function testGetRowsReturnsStaticAltItemWhenWidthIsTooSmall () : void
150
132
{
151
133
$ menuStyle = $ this ->createMock (MenuStyle::class);
152
134
@@ -159,4 +141,99 @@ public function testGetRowsReturnsStaticAltItemWhenWidthIsTooSmall()
159
141
160
142
self ::assertSame (['my alt ' ], $ item ->getRows ($ menuStyle ));
161
143
}
144
+
145
+ public function testWithRealAsciiArtCenterAligned () : void
146
+ {
147
+ $ menuStyle = $ this ->createMock (MenuStyle::class);
148
+
149
+ $ menuStyle
150
+ ->expects ($ this ->any ())
151
+ ->method ('getContentWidth ' )
152
+ ->will ($ this ->returnValue (30 ));
153
+
154
+ $ art = <<<ART
155
+ _ __ _
156
+ / |..| \
157
+ \/ || \/
158
+ |_''_|
159
+ PHP SCHOOL
160
+ LEARNING FOR ELEPHANTS
161
+ ART ;
162
+
163
+ $ item = new AsciiArtItem ($ art , AsciiArtItem::POSITION_CENTER );
164
+ $ this ->assertEquals (
165
+ [
166
+ ' _ __ _ ' ,
167
+ ' / |..| \\' ,
168
+ ' \/ || \/ ' ,
169
+ " |_''_| " ,
170
+ ' PHP SCHOOL ' ,
171
+ ' LEARNING FOR ELEPHANTS '
172
+ ],
173
+ $ item ->getRows ($ menuStyle )
174
+ );
175
+ }
176
+
177
+ public function testWithRealAsciiArtRightAligned () : void
178
+ {
179
+ $ menuStyle = $ this ->createMock (MenuStyle::class);
180
+
181
+ $ menuStyle
182
+ ->expects ($ this ->any ())
183
+ ->method ('getContentWidth ' )
184
+ ->will ($ this ->returnValue (30 ));
185
+
186
+ $ art = <<<ART
187
+ _ __ _
188
+ / |..| \
189
+ \/ || \/
190
+ |_''_|
191
+ PHP SCHOOL
192
+ LEARNING FOR ELEPHANTS
193
+ ART ;
194
+
195
+ $ item = new AsciiArtItem ($ art , AsciiArtItem::POSITION_RIGHT );
196
+ $ this ->assertEquals (
197
+ [
198
+ ' _ __ _ ' ,
199
+ ' / |..| \\' ,
200
+ ' \/ || \/ ' ,
201
+ " |_''_| " ,
202
+ ' PHP SCHOOL ' ,
203
+ ' LEARNING FOR ELEPHANTS '
204
+ ],
205
+ $ item ->getRows ($ menuStyle )
206
+ );
207
+ }
208
+
209
+ public function testWithRealAsciiArtCenterAlignedWithWhiteSpaceAtTheEndOfEachLine () : void
210
+ {
211
+ $ menuStyle = $ this ->createMock (MenuStyle::class);
212
+
213
+ $ menuStyle
214
+ ->expects ($ this ->any ())
215
+ ->method ('getContentWidth ' )
216
+ ->will ($ this ->returnValue (30 ));
217
+
218
+ $ art = <<<ART
219
+ _ __ _
220
+ / |..| \
221
+ \/ || \/
222
+ |_''_|
223
+ PHP SCHOOL
224
+ LEARNING FOR ELEPHANTS
225
+ ART ;
226
+ $ item = new AsciiArtItem ($ art , AsciiArtItem::POSITION_CENTER );
227
+ $ this ->assertEquals (
228
+ [
229
+ ' _ __ _ ' ,
230
+ ' / |..| \\' ,
231
+ ' \/ || \/ ' ,
232
+ " |_''_| " ,
233
+ ' PHP SCHOOL ' ,
234
+ ' LEARNING FOR ELEPHANTS '
235
+ ],
236
+ $ item ->getRows ($ menuStyle )
237
+ );
238
+ }
162
239
}
0 commit comments