Skip to content

Commit 3061311

Browse files
authored
Merge pull request #152 from php-school/setgutter-tests
Add tests for setGutter
2 parents 9ac14b7 + e689fac commit 3061311

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/MenuItem/SplitItemTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,38 @@ public function testGetRowsWithStaticItems() : void
148148
self::assertEquals(['One Two '], $item->getRows($menuStyle));
149149
}
150150

151+
public function testSetGutter() : void
152+
{
153+
$menuStyle = $this->createMock(MenuStyle::class);
154+
155+
$menuStyle
156+
->expects($this->any())
157+
->method('getContentWidth')
158+
->will($this->returnValue(20));
159+
160+
$item = new SplitItem([new StaticItem('One Two'), new StaticItem('Three')]);
161+
162+
self::assertEquals(['One Two Three '], $item->getRows($menuStyle));
163+
164+
$item->setGutter(5);
165+
166+
self::assertEquals(['One Three ', 'Two '], $item->getRows($menuStyle));
167+
}
168+
169+
/**
170+
* @dataProvider belowZeroProvider
171+
*/
172+
public function testSetGutterThrowsExceptionIfValueIsNotZeroOrAbove(int $value) : void
173+
{
174+
self::expectException(\Assert\InvalidArgumentException::class);
175+
$item = new SplitItem();
176+
$item->setGutter($value);
177+
}
178+
public function belowZeroProvider() : array
179+
{
180+
return [[-1], [-2], [-10]];
181+
}
182+
151183
public function testGetRowsWithOneItemSelected() : void
152184
{
153185
$menuStyle = $this->createMock(MenuStyle::class);

0 commit comments

Comments
 (0)