Skip to content

Use self:: instead of static:: #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions test/CliMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public function setUp()
public function testGetMenuStyle() : void
{
$menu = new CliMenu('PHP School FTW', []);
static::assertInstanceOf(MenuStyle::class, $menu->getStyle());
self::assertInstanceOf(MenuStyle::class, $menu->getStyle());

$style = new MenuStyle();
$menu = new CliMenu('PHP School FTW', [], null, $style);
static::assertSame($style, $menu->getStyle());
self::assertSame($style, $menu->getStyle());
}

public function testReDrawThrowsExceptionIfMenuNotOpen() : void
Expand All @@ -81,7 +81,7 @@ public function testSimpleOpenClose() : void
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithBorders() : void
Expand All @@ -100,7 +100,7 @@ public function testSimpleOpenCloseWithBorders() : void
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithLeftAndRightBorders() : void
Expand All @@ -121,7 +121,7 @@ public function testSimpleOpenCloseWithLeftAndRightBorders() : void
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithMarginAutoAndBorders() : void
Expand All @@ -142,7 +142,7 @@ public function testSimpleOpenCloseWithMarginAutoAndBorders() : void
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testReDrawReDrawsImmediately() : void
Expand All @@ -162,7 +162,7 @@ public function testReDrawReDrawsImmediately() : void
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testGetItems() : void
Expand All @@ -184,7 +184,7 @@ public function testGetItems() : void
$style
);

static::assertSame([$item1, $item2], $menu->getItems());
self::assertSame([$item1, $item2], $menu->getItems());
}

public function testRemoveItem() : void
Expand All @@ -205,12 +205,12 @@ public function testRemoveItem() : void
$style
);

static::assertEquals([$item1, $item2], $menu->getItems());
self::assertEquals([$item1, $item2], $menu->getItems());

$menu->removeItem($item1);

static::assertCount(1, $menu->getItems());
static::assertContains($item2, $menu->getItems());
self::assertCount(1, $menu->getItems());
self::assertContains($item2, $menu->getItems());
}

public function testRemoveItemThrowsExceptionWhenItemDoesntExistInMenu() : void
Expand Down Expand Up @@ -255,7 +255,7 @@ public function testThrowsExceptionIfTerminalIsNotValidTTY() : void
public function testGetTerminal() : void
{
$menu = new CliMenu('PHP School FTW', []);
static::assertInstanceOf(UnixTerminal::class, $menu->getTerminal());
self::assertInstanceOf(UnixTerminal::class, $menu->getTerminal());
}

public function testAddItem() : void
Expand Down Expand Up @@ -328,7 +328,7 @@ public function testAskNumberThrowsExceptionIfMenuNotOpen() : void
{
$menu = new CliMenu('PHP School FTW', []);

static::expectException(MenuNotOpenException::class);
self::expectException(MenuNotOpenException::class);

$menu->askNumber();
}
Expand Down Expand Up @@ -358,15 +358,15 @@ public function testAskNumberStyle() : void
}));
$menu->open();

static::assertEquals('yellow', $number->getStyle()->getBg());
static::assertEquals('red', $number->getStyle()->getFg());
self::assertEquals('yellow', $number->getStyle()->getBg());
self::assertEquals('red', $number->getStyle()->getFg());
}

public function testAskTextThrowsExceptionIfMenuNotOpen() : void
{
$menu = new CliMenu('PHP School FTW', []);

static::expectException(MenuNotOpenException::class);
self::expectException(MenuNotOpenException::class);

$menu->askText();
}
Expand Down Expand Up @@ -396,15 +396,15 @@ public function testAskTextStyle() : void
}));
$menu->open();

static::assertEquals('yellow', $text->getStyle()->getBg());
static::assertEquals('red', $text->getStyle()->getFg());
self::assertEquals('yellow', $text->getStyle()->getBg());
self::assertEquals('red', $text->getStyle()->getFg());
}

public function testAskPasswordThrowsExceptionIfMenuNotOpen() : void
{
$menu = new CliMenu('PHP School FTW', []);

static::expectException(MenuNotOpenException::class);
self::expectException(MenuNotOpenException::class);

$menu->askPassword();
}
Expand Down Expand Up @@ -434,8 +434,8 @@ public function testAskPasswordStyle() : void
}));
$menu->open();

static::assertEquals('yellow', $password->getStyle()->getBg());
static::assertEquals('red', $password->getStyle()->getFg());
self::assertEquals('yellow', $password->getStyle()->getBg());
self::assertEquals('red', $password->getStyle()->getFg());
}

public function testAddCustomControlMappingThrowsExceptionWhenOverwritingExistingDefaultControls() : void
Expand Down Expand Up @@ -477,7 +477,7 @@ public function testAddCustomControlMapping() : void
$menu->addCustomControlMapping('c', $action);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testAddCustomControlMappingsThrowsExceptionWhenOverwritingExistingDefaultControls() : void
Expand Down Expand Up @@ -528,10 +528,10 @@ public function testAddCustomControlMappings() : void
]);

$menu->open();
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());

$menu->open();
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
self::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testRemoveCustomControlMappingThrowsExceptionIfNoSuchMappingExists() : void
Expand Down
150 changes: 75 additions & 75 deletions test/MenuStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ private function getMockTerminal(int $colours = 8) : MockObject
->getMock();

$terminal
->expects(static::any())
->expects(self::any())
->method('getWidth')
->will(static::returnValue(500));
->will(self::returnValue(500));

$terminal
->expects(static::any())
->expects(self::any())
->method('getColourSupport')
->will(static::returnValue($colours));
->will(self::returnValue($colours));

return $terminal;
}
Expand All @@ -65,54 +65,54 @@ public function testMenuStyleCanBeInstantiatedByCliMenuBuilder() : void
$menu = $builder->build();

$reflectionMenu = new \ReflectionObject($menu);
static::assertTrue($reflectionMenu->hasProperty('style'));
self::assertTrue($reflectionMenu->hasProperty('style'));

$styleProperty = $reflectionMenu->getProperty('style');
$styleProperty->setAccessible(true);
$style = $styleProperty->getValue($menu);

static::assertSame(MenuStyle::class, get_class($style));
self::assertSame(MenuStyle::class, get_class($style));
}

public function testGetColoursSetCode() : void
{
static::assertSame("\e[37;44m", $this->getMenuStyle()->getColoursSetCode());
self::assertSame("\e[37;44m", $this->getMenuStyle()->getColoursSetCode());
}

public function testGetColoursResetCode() : void
{
static::assertSame("\e[0m", $this->getMenuStyle()->getColoursResetCode());
self::assertSame("\e[0m", $this->getMenuStyle()->getColoursResetCode());
}

public function testGetInvertedColoursSetCode() : void
{
static::assertSame("\e[7m", $this->getMenuStyle()->getInvertedColoursSetCode());
self::assertSame("\e[7m", $this->getMenuStyle()->getInvertedColoursSetCode());
}

public function testGetInvertedColoursUnsetCode() : void
{
static::assertSame("\e[27m", $this->getMenuStyle()->getInvertedColoursUnsetCode());
self::assertSame("\e[27m", $this->getMenuStyle()->getInvertedColoursUnsetCode());
}

public function testGetterAndSetters() : void
{
$style = $this->getMenuStyle();

static::assertSame('blue', $style->getBg());
static::assertSame('white', $style->getFg());
static::assertSame('○', $style->getUnselectedMarker());
static::assertSame('●', $style->getSelectedMarker());
static::assertSame('✔', $style->getItemExtra());
static::assertFalse($style->getDisplaysExtra());
static::assertSame('=', $style->getTitleSeparator());
static::assertSame(100, $style->getWidth());
static::assertSame(2, $style->getMargin());
static::assertSame(2, $style->getPadding());
static::assertSame(0, $style->getBorderTopWidth());
static::assertSame(0, $style->getBorderRightWidth());
static::assertSame(0, $style->getBorderBottomWidth());
static::assertSame(0, $style->getBorderLeftWidth());
static::assertSame('white', $style->getBorderColour());
self::assertSame('blue', $style->getBg());
self::assertSame('white', $style->getFg());
self::assertSame('○', $style->getUnselectedMarker());
self::assertSame('●', $style->getSelectedMarker());
self::assertSame('✔', $style->getItemExtra());
self::assertFalse($style->getDisplaysExtra());
self::assertSame('=', $style->getTitleSeparator());
self::assertSame(100, $style->getWidth());
self::assertSame(2, $style->getMargin());
self::assertSame(2, $style->getPadding());
self::assertSame(0, $style->getBorderTopWidth());
self::assertSame(0, $style->getBorderRightWidth());
self::assertSame(0, $style->getBorderBottomWidth());
self::assertSame(0, $style->getBorderLeftWidth());
self::assertSame('white', $style->getBorderColour());

$style->setBg('red');
$style->setFg('yellow');
Expand All @@ -130,80 +130,80 @@ public function testGetterAndSetters() : void
$style->setBorderLeftWidth(4);
$style->setBorderColour('green');

static::assertSame('red', $style->getBg());
static::assertSame('yellow', $style->getFg());
static::assertSame('-', $style->getUnselectedMarker());
static::assertSame('>', $style->getSelectedMarker());
static::assertSame('EXTRA!', $style->getItemExtra());
static::assertTrue($style->getDisplaysExtra());
static::assertSame('+', $style->getTitleSeparator());
static::assertSame(200, $style->getWidth());
static::assertSame(10, $style->getMargin());
static::assertSame(10, $style->getPadding());
static::assertSame(1, $style->getBorderTopWidth());
static::assertSame(2, $style->getBorderRightWidth());
static::assertSame(3, $style->getBorderBottomWidth());
static::assertSame(4, $style->getBorderLeftWidth());
static::assertSame('green', $style->getBorderColour());
self::assertSame('red', $style->getBg());
self::assertSame('yellow', $style->getFg());
self::assertSame('-', $style->getUnselectedMarker());
self::assertSame('>', $style->getSelectedMarker());
self::assertSame('EXTRA!', $style->getItemExtra());
self::assertTrue($style->getDisplaysExtra());
self::assertSame('+', $style->getTitleSeparator());
self::assertSame(200, $style->getWidth());
self::assertSame(10, $style->getMargin());
self::assertSame(10, $style->getPadding());
self::assertSame(1, $style->getBorderTopWidth());
self::assertSame(2, $style->getBorderRightWidth());
self::assertSame(3, $style->getBorderBottomWidth());
self::assertSame(4, $style->getBorderLeftWidth());
self::assertSame('green', $style->getBorderColour());
}

public function testSetBorderShorthandFunction() : void
{
$style = $this->getMenuStyle();
$style->setBorder(3);
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(3, $style->getBorderRightWidth());
static::assertSame(3, $style->getBorderBottomWidth());
static::assertSame(3, $style->getBorderLeftWidth());
static::assertSame('white', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(3, $style->getBorderRightWidth());
self::assertSame(3, $style->getBorderBottomWidth());
self::assertSame(3, $style->getBorderLeftWidth());
self::assertSame('white', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4);
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(3, $style->getBorderBottomWidth());
static::assertSame(4, $style->getBorderLeftWidth());
static::assertSame('white', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(3, $style->getBorderBottomWidth());
self::assertSame(4, $style->getBorderLeftWidth());
self::assertSame('white', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4, 5);
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(5, $style->getBorderBottomWidth());
static::assertSame(4, $style->getBorderLeftWidth());
static::assertSame('white', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(5, $style->getBorderBottomWidth());
self::assertSame(4, $style->getBorderLeftWidth());
self::assertSame('white', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4, 5, 6);
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(5, $style->getBorderBottomWidth());
static::assertSame(6, $style->getBorderLeftWidth());
static::assertSame('white', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(5, $style->getBorderBottomWidth());
self::assertSame(6, $style->getBorderLeftWidth());
self::assertSame('white', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4, 5, 6, 'red');
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(5, $style->getBorderBottomWidth());
static::assertSame(6, $style->getBorderLeftWidth());
static::assertSame('red', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(5, $style->getBorderBottomWidth());
self::assertSame(6, $style->getBorderLeftWidth());
self::assertSame('red', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4, 5, 'red');
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(5, $style->getBorderBottomWidth());
static::assertSame(4, $style->getBorderLeftWidth());
static::assertSame('red', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(5, $style->getBorderBottomWidth());
self::assertSame(4, $style->getBorderLeftWidth());
self::assertSame('red', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 4, 'red');
static::assertSame(3, $style->getBorderTopWidth());
static::assertSame(4, $style->getBorderRightWidth());
static::assertSame(3, $style->getBorderBottomWidth());
static::assertSame(4, $style->getBorderLeftWidth());
static::assertSame('red', $style->getBorderColour());
self::assertSame(3, $style->getBorderTopWidth());
self::assertSame(4, $style->getBorderRightWidth());
self::assertSame(3, $style->getBorderBottomWidth());
self::assertSame(4, $style->getBorderLeftWidth());
self::assertSame('red', $style->getBorderColour());

$style = $this->getMenuStyle();
$style->setBorder(3, 'red');
Expand Down