Skip to content

Commit 13251d5

Browse files
jrfnlgrogy
authored andcommitted
PHPUnit: use a type-safe assertion
`assertEquals()` is to `assertSame()` as `==` is to `===`, so always use `assertSame()` unless you _need_ a loose comparison.
1 parent a63dcb0 commit 13251d5

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/ConsoleColorTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ protected function setUp()
4141
public function testNone()
4242
{
4343
$output = $this->uut->apply('none', 'text');
44-
$this->assertEquals("text", $output);
44+
$this->assertSame("text", $output);
4545
}
4646

4747
public function testBold()
4848
{
4949
$output = $this->uut->apply('bold', 'text');
50-
$this->assertEquals("\033[1mtext\033[0m", $output);
50+
$this->assertSame("\033[1mtext\033[0m", $output);
5151
}
5252

5353
public function testBoldColorsAreNotSupported()
5454
{
5555
$this->uut->setIsSupported(false);
5656

5757
$output = $this->uut->apply('bold', 'text');
58-
$this->assertEquals("text", $output);
58+
$this->assertSame("text", $output);
5959
}
6060

6161
public function testBoldColorsAreNotSupportedButAreForced()
@@ -64,73 +64,73 @@ public function testBoldColorsAreNotSupportedButAreForced()
6464
$this->uut->setForceStyle(true);
6565

6666
$output = $this->uut->apply('bold', 'text');
67-
$this->assertEquals("\033[1mtext\033[0m", $output);
67+
$this->assertSame("\033[1mtext\033[0m", $output);
6868
}
6969

7070
public function testDark()
7171
{
7272
$output = $this->uut->apply('dark', 'text');
73-
$this->assertEquals("\033[2mtext\033[0m", $output);
73+
$this->assertSame("\033[2mtext\033[0m", $output);
7474
}
7575

7676
public function testBoldAndDark()
7777
{
7878
$output = $this->uut->apply(array('bold', 'dark'), 'text');
79-
$this->assertEquals("\033[1;2mtext\033[0m", $output);
79+
$this->assertSame("\033[1;2mtext\033[0m", $output);
8080
}
8181

8282
public function test256ColorForeground()
8383
{
8484
$output = $this->uut->apply('color_255', 'text');
85-
$this->assertEquals("\033[38;5;255mtext\033[0m", $output);
85+
$this->assertSame("\033[38;5;255mtext\033[0m", $output);
8686
}
8787

8888
public function test256ColorWithoutSupport()
8989
{
9090
$this->uut->setAre256ColorsSupported(false);
9191

9292
$output = $this->uut->apply('color_255', 'text');
93-
$this->assertEquals("text", $output);
93+
$this->assertSame("text", $output);
9494
}
9595

9696
public function test256ColorBackground()
9797
{
9898
$output = $this->uut->apply('bg_color_255', 'text');
99-
$this->assertEquals("\033[48;5;255mtext\033[0m", $output);
99+
$this->assertSame("\033[48;5;255mtext\033[0m", $output);
100100
}
101101

102102
public function test256ColorForegroundAndBackground()
103103
{
104104
$output = $this->uut->apply(array('color_200', 'bg_color_255'), 'text');
105-
$this->assertEquals("\033[38;5;200;48;5;255mtext\033[0m", $output);
105+
$this->assertSame("\033[38;5;200;48;5;255mtext\033[0m", $output);
106106
}
107107

108108
public function testSetOwnTheme()
109109
{
110110
$this->uut->setThemes(array('bold_dark' => array('bold', 'dark')));
111111
$output = $this->uut->apply(array('bold_dark'), 'text');
112-
$this->assertEquals("\033[1;2mtext\033[0m", $output);
112+
$this->assertSame("\033[1;2mtext\033[0m", $output);
113113
}
114114

115115
public function testAddOwnTheme()
116116
{
117117
$this->uut->addTheme('bold_own', 'bold');
118118
$output = $this->uut->apply(array('bold_own'), 'text');
119-
$this->assertEquals("\033[1mtext\033[0m", $output);
119+
$this->assertSame("\033[1mtext\033[0m", $output);
120120
}
121121

122122
public function testAddOwnThemeArray()
123123
{
124124
$this->uut->addTheme('bold_dark', array('bold', 'dark'));
125125
$output = $this->uut->apply(array('bold_dark'), 'text');
126-
$this->assertEquals("\033[1;2mtext\033[0m", $output);
126+
$this->assertSame("\033[1;2mtext\033[0m", $output);
127127
}
128128

129129
public function testOwnWithStyle()
130130
{
131131
$this->uut->addTheme('bold_dark', array('bold', 'dark'));
132132
$output = $this->uut->apply(array('bold_dark', 'italic'), 'text');
133-
$this->assertEquals("\033[1;2;3mtext\033[0m", $output);
133+
$this->assertSame("\033[1;2;3mtext\033[0m", $output);
134134
}
135135

136136
public function testHasAndRemoveTheme()

0 commit comments

Comments
 (0)