Skip to content

Commit de35d43

Browse files
committed
Let assertEquals be strict assertSame
1 parent 33c229c commit de35d43

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

tests/Linna/Http/Message/ResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public function testNewInstanceWithAllStatusCodes(int $code, string $reasonPhras
141141
{
142142
$response = new Response($code);
143143
$this->assertInstanceOf(Response::class, $response);
144-
$this->assertEquals($code, $response->getStatusCode());
145-
$this->assertEquals($reasonPhrase, $response->getReasonPhrase());
144+
$this->assertSame($code, $response->getStatusCode());
145+
$this->assertSame($reasonPhrase, $response->getReasonPhrase());
146146
}
147147

148148
/**
@@ -169,8 +169,8 @@ public function testWithStatus(): void
169169

170170
$this->assertNotEquals($response->getStatusCode(), self::$response->getStatusCode());
171171
$this->assertNotEquals($response->getReasonPhrase(), self::$response->getReasonPhrase());
172-
$this->assertEquals(Response::STATUS_FORBIDDEN, $response->getStatusCode());
173-
$this->assertEquals('Forbidden', $response->getReasonPhrase());
172+
$this->assertSame(Response::STATUS_FORBIDDEN, $response->getStatusCode());
173+
$this->assertSame('Forbidden', $response->getReasonPhrase());
174174
}
175175

176176
/**

tests/Linna/Http/Message/StreamTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function testGetSize(): void
169169

170170
$stream->write('abcdefghijklmnopqrstuwxyz');
171171

172-
$this->assertEquals(25, $stream->getSize());
172+
$this->assertSame(25, $stream->getSize());
173173

174174
$stream->close();
175175
}
@@ -187,7 +187,7 @@ public function testGetSizeWithNoResource(): void
187187
$stream->write('abcdefghijklmnopqrstuwxyz');
188188
$stream->close();
189189

190-
$this->assertEquals(0, $stream->getSize());
190+
$this->assertSame(0, $stream->getSize());
191191
}
192192

193193
/**
@@ -204,13 +204,13 @@ public function testTell(): void
204204
$stream->write('abcdefghijklmnopqrstuwxyz');
205205
$stream->rewind();
206206

207-
$this->assertEquals(0, $stream->tell());
207+
$this->assertSame(0, $stream->tell());
208208

209209
$stream->seek(2);
210-
$this->assertEquals(2, $stream->tell());
210+
$this->assertSame(2, $stream->tell());
211211

212212
$stream->rewind();
213-
$this->assertEquals(0, $stream->tell());
213+
$this->assertSame(0, $stream->tell());
214214

215215
$stream->close();
216216
}
@@ -248,17 +248,17 @@ public function testEof(): void
248248
$stream->rewind();
249249

250250
//not at the end of the file
251-
$this->assertEquals(0, $stream->tell());
251+
$this->assertSame(0, $stream->tell());
252252
$this->assertFalse($stream->eof());
253253

254254
//not at the end of the file
255255
$stream->read(25);
256-
$this->assertEquals(25, $stream->tell());
256+
$this->assertSame(25, $stream->tell());
257257
$this->assertFalse($stream->eof());
258258

259259
//at the end of the file
260260
$stream->read(1);
261-
$this->assertEquals(25, $stream->tell());
261+
$this->assertSame(25, $stream->tell());
262262
$this->assertTrue($stream->eof());
263263

264264
//true with stream closed
@@ -310,16 +310,16 @@ public function testRewind(): void
310310

311311
$stream->write('abcdefghijklmnopqrstuwxyz');
312312

313-
$this->assertEquals(25, $stream->tell());
313+
$this->assertSame(25, $stream->tell());
314314

315315
$stream->rewind();
316-
$this->assertEquals(0, $stream->tell());
316+
$this->assertSame(0, $stream->tell());
317317

318318
$stream->read(25);
319-
$this->assertEquals(25, $stream->tell());
319+
$this->assertSame(25, $stream->tell());
320320

321321
$stream->rewind();
322-
$this->assertEquals(0, $stream->tell());
322+
$this->assertSame(0, $stream->tell());
323323
}
324324

325325
/**
@@ -389,7 +389,7 @@ public function testIsWritable(string $mode, bool $result): void
389389

390390
$stream = new Stream(\fopen($file, $mode));
391391

392-
$this->assertEquals($result, $stream->isWritable());
392+
$this->assertSame($result, $stream->isWritable());
393393
}
394394

395395
/**
@@ -421,7 +421,7 @@ public function testWrite(): void
421421
$stream->write('abcdefghijklmnopqrstuwxyz');
422422
$stream->rewind();
423423

424-
$this->assertEquals('abcdefghijklmnopqrstuwxyz', $stream->read(25));
424+
$this->assertSame('abcdefghijklmnopqrstuwxyz', $stream->read(25));
425425
}
426426

427427
/**
@@ -512,7 +512,7 @@ public function testIsReadable(string $mode, bool $result): void
512512

513513
$stream = new Stream(\fopen($file, $mode));
514514

515-
$this->assertEquals($result, $stream->isReadable());
515+
$this->assertSame($result, $stream->isReadable());
516516
}
517517

518518
/**
@@ -529,7 +529,7 @@ public function testRead(): void
529529
$stream->write('abcdefghijklmnopqrstuwxyz');
530530
$stream->rewind();
531531

532-
$this->assertEquals('abcdefghijklmnopqrstuwxyz', $stream->read(25));
532+
$this->assertSame('abcdefghijklmnopqrstuwxyz', $stream->read(25));
533533
}
534534

535535
/**
@@ -582,8 +582,8 @@ public function testGetContents(): void
582582
$stream->write('abcdefghijklmnopqrstuwxyz');
583583
$stream->rewind();
584584

585-
$this->assertEquals('abcdefghijklmnopqrst', $stream->read(20));
586-
$this->assertEquals('uwxyz', $stream->getContents());
585+
$this->assertSame('abcdefghijklmnopqrst', $stream->read(20));
586+
$this->assertSame('uwxyz', $stream->getContents());
587587
}
588588

589589
/**

tests/Linna/Http/Message/UriTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public function testNewInstance(): void
3636
$uri = new Uri(self::$uri);
3737

3838
$this->assertInstanceOf(Uri::class, $uri);
39-
$this->assertEquals('http', $uri->getScheme());
40-
$this->assertEquals('username:password', $uri->getUserInfo());
41-
$this->assertEquals('hostname.com', $uri->getHost());
42-
$this->assertEquals(9090, $uri->getPort());
43-
$this->assertEquals('username:password@hostname.com:9090', $uri->getAuthority());
44-
$this->assertEquals('/path', $uri->getPath());
45-
$this->assertEquals('arg=value', $uri->getQuery());
46-
$this->assertEquals('anchor', $uri->getFragment());
39+
$this->assertSame('http', $uri->getScheme());
40+
$this->assertSame('username:password', $uri->getUserInfo());
41+
$this->assertSame('hostname.com', $uri->getHost());
42+
$this->assertSame(9090, $uri->getPort());
43+
$this->assertSame('username:password@hostname.com:9090', $uri->getAuthority());
44+
$this->assertSame('/path', $uri->getPath());
45+
$this->assertSame('arg=value', $uri->getQuery());
46+
$this->assertSame('anchor', $uri->getFragment());
4747
}
4848

4949
/**
@@ -118,7 +118,7 @@ public function authorityProvider(): array
118118
*/
119119
public function testGetAuthority(string $autority, string $expected): void
120120
{
121-
$this->assertEquals($expected, (new Uri("{$autority}/path?arg=value#anchor"))->getAuthority());
121+
$this->assertSame($expected, (new Uri("{$autority}/path?arg=value#anchor"))->getAuthority());
122122
}
123123

124124
/**
@@ -146,7 +146,7 @@ public function portProvider(): array
146146
*/
147147
public function testGetPort(string $scheme, string $port, int $expected): void
148148
{
149-
$this->assertEquals($expected, (new Uri("{$scheme}://username:password@hostname.com{$port}/path?arg=value#anchor"))->getPort());
149+
$this->assertSame($expected, (int)(new Uri("{$scheme}://username:password@hostname.com{$port}/path?arg=value#anchor"))->getPort());
150150
}
151151

152152
/**
@@ -158,7 +158,7 @@ public function testWithScheme(): void
158158
{
159159
$uri = (new Uri(self::$uri))->withScheme('https');
160160

161-
$this->assertEquals('https', $uri->getScheme());
161+
$this->assertSame('https', $uri->getScheme());
162162
}
163163

164164
/**
@@ -196,7 +196,7 @@ public function testWithUserInfo(): void
196196
{
197197
$uri = (new Uri(self::$uri))->withUserInfo('testUser', 'password');
198198

199-
$this->assertEquals('testUser:password', $uri->getUserInfo());
199+
$this->assertSame('testUser:password', $uri->getUserInfo());
200200
}
201201

202202
/**
@@ -208,7 +208,7 @@ public function testWithUserInfoWithoutPassword(): void
208208
{
209209
$uri = (new Uri(self::$uri))->withUserInfo('testUser');
210210

211-
$this->assertEquals('testUser', $uri->getUserInfo());
211+
$this->assertSame('testUser', $uri->getUserInfo());
212212
}
213213

214214
/**
@@ -220,7 +220,7 @@ public function testWithUserInfoWithoutUserAndPassword(): void
220220
{
221221
$uri = (new Uri(self::$uri))->withUserInfo('');
222222

223-
$this->assertEquals('', $uri->getUserInfo());
223+
$this->assertSame('', $uri->getUserInfo());
224224
}
225225

226226
/**
@@ -232,7 +232,7 @@ public function testWithHost(): void
232232
{
233233
$uri = (new Uri(self::$uri))->withHost('example.com');
234234

235-
$this->assertEquals('example.com', $uri->getHost());
235+
$this->assertSame('example.com', $uri->getHost());
236236
}
237237

238238
/**
@@ -270,7 +270,7 @@ public function testWithPort(): void
270270
{
271271
$uri = (new Uri(self::$uri))->withPort(8080);
272272

273-
$this->assertEquals(8080, $uri->getPort());
273+
$this->assertSame(8080, $uri->getPort());
274274
}
275275

276276
/**
@@ -356,8 +356,8 @@ public function testWithPath(): void
356356
{
357357
$uri = (new Uri(self::$uri))->withPath('/otherpath');
358358

359-
$this->assertEquals('/otherpath', $uri->getPath());
360-
$this->assertEquals('http://username:password@hostname.com:9090/otherpath?arg=value#anchor', (string) $uri);
359+
$this->assertSame('/otherpath', $uri->getPath());
360+
$this->assertSame('http://username:password@hostname.com:9090/otherpath?arg=value#anchor', (string) $uri);
361361
}
362362

363363
/**
@@ -432,7 +432,7 @@ public function uriProvider(): array
432432
*/
433433
public function testUriToString(string $testUri): void
434434
{
435-
$this->assertEquals($testUri, (string) (new Uri($testUri)));
435+
$this->assertSame($testUri, (string) (new Uri($testUri)));
436436
}
437437

438438
/**
@@ -464,8 +464,8 @@ public function testWithQuery(string $withQuery, string $expectedQuery, string $
464464
{
465465
$uri = (new Uri(self::$uri))->withQuery($withQuery);
466466

467-
$this->assertEquals($expectedQuery, $uri->getQuery());
468-
$this->assertEquals($expectedUri, (string) $uri);
467+
$this->assertSame($expectedQuery, $uri->getQuery());
468+
$this->assertSame($expectedUri, (string) $uri);
469469
}
470470

471471
/**
@@ -523,8 +523,8 @@ public function testWithFragment(string $withFragment, string $expectedFragment,
523523
{
524524
$uri = (new Uri(self::$uri))->withFragment($withFragment);
525525

526-
$this->assertEquals($expectedFragment, $uri->getFragment());
527-
$this->assertEquals($expectedUri, (string) $uri);
526+
$this->assertSame($expectedFragment, $uri->getFragment());
527+
$this->assertSame($expectedUri, (string) $uri);
528528
}
529529

530530
/**

0 commit comments

Comments
 (0)