Skip to content

Commit

Permalink
Let assertEquals be strict assertSame
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Sep 18, 2023
1 parent 33c229c commit de35d43
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
8 changes: 4 additions & 4 deletions tests/Linna/Http/Message/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public function testNewInstanceWithAllStatusCodes(int $code, string $reasonPhras
{
$response = new Response($code);
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals($code, $response->getStatusCode());
$this->assertEquals($reasonPhrase, $response->getReasonPhrase());
$this->assertSame($code, $response->getStatusCode());
$this->assertSame($reasonPhrase, $response->getReasonPhrase());
}

/**
Expand All @@ -169,8 +169,8 @@ public function testWithStatus(): void

$this->assertNotEquals($response->getStatusCode(), self::$response->getStatusCode());
$this->assertNotEquals($response->getReasonPhrase(), self::$response->getReasonPhrase());
$this->assertEquals(Response::STATUS_FORBIDDEN, $response->getStatusCode());
$this->assertEquals('Forbidden', $response->getReasonPhrase());
$this->assertSame(Response::STATUS_FORBIDDEN, $response->getStatusCode());
$this->assertSame('Forbidden', $response->getReasonPhrase());
}

/**
Expand Down
36 changes: 18 additions & 18 deletions tests/Linna/Http/Message/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function testGetSize(): void

$stream->write('abcdefghijklmnopqrstuwxyz');

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

$stream->close();
}
Expand All @@ -187,7 +187,7 @@ public function testGetSizeWithNoResource(): void
$stream->write('abcdefghijklmnopqrstuwxyz');
$stream->close();

$this->assertEquals(0, $stream->getSize());
$this->assertSame(0, $stream->getSize());
}

/**
Expand All @@ -204,13 +204,13 @@ public function testTell(): void
$stream->write('abcdefghijklmnopqrstuwxyz');
$stream->rewind();

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

$stream->seek(2);
$this->assertEquals(2, $stream->tell());
$this->assertSame(2, $stream->tell());

$stream->rewind();
$this->assertEquals(0, $stream->tell());
$this->assertSame(0, $stream->tell());

$stream->close();
}
Expand Down Expand Up @@ -248,17 +248,17 @@ public function testEof(): void
$stream->rewind();

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

//not at the end of the file
$stream->read(25);
$this->assertEquals(25, $stream->tell());
$this->assertSame(25, $stream->tell());
$this->assertFalse($stream->eof());

//at the end of the file
$stream->read(1);
$this->assertEquals(25, $stream->tell());
$this->assertSame(25, $stream->tell());
$this->assertTrue($stream->eof());

//true with stream closed
Expand Down Expand Up @@ -310,16 +310,16 @@ public function testRewind(): void

$stream->write('abcdefghijklmnopqrstuwxyz');

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

$stream->rewind();
$this->assertEquals(0, $stream->tell());
$this->assertSame(0, $stream->tell());

$stream->read(25);
$this->assertEquals(25, $stream->tell());
$this->assertSame(25, $stream->tell());

$stream->rewind();
$this->assertEquals(0, $stream->tell());
$this->assertSame(0, $stream->tell());
}

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

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

$this->assertEquals($result, $stream->isWritable());
$this->assertSame($result, $stream->isWritable());
}

/**
Expand Down Expand Up @@ -421,7 +421,7 @@ public function testWrite(): void
$stream->write('abcdefghijklmnopqrstuwxyz');
$stream->rewind();

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

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

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

$this->assertEquals($result, $stream->isReadable());
$this->assertSame($result, $stream->isReadable());
}

/**
Expand All @@ -529,7 +529,7 @@ public function testRead(): void
$stream->write('abcdefghijklmnopqrstuwxyz');
$stream->rewind();

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

/**
Expand Down Expand Up @@ -582,8 +582,8 @@ public function testGetContents(): void
$stream->write('abcdefghijklmnopqrstuwxyz');
$stream->rewind();

$this->assertEquals('abcdefghijklmnopqrst', $stream->read(20));
$this->assertEquals('uwxyz', $stream->getContents());
$this->assertSame('abcdefghijklmnopqrst', $stream->read(20));
$this->assertSame('uwxyz', $stream->getContents());
}

/**
Expand Down
46 changes: 23 additions & 23 deletions tests/Linna/Http/Message/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public function testNewInstance(): void
$uri = new Uri(self::$uri);

$this->assertInstanceOf(Uri::class, $uri);
$this->assertEquals('http', $uri->getScheme());
$this->assertEquals('username:password', $uri->getUserInfo());
$this->assertEquals('hostname.com', $uri->getHost());
$this->assertEquals(9090, $uri->getPort());
$this->assertEquals('username:[email protected]:9090', $uri->getAuthority());
$this->assertEquals('/path', $uri->getPath());
$this->assertEquals('arg=value', $uri->getQuery());
$this->assertEquals('anchor', $uri->getFragment());
$this->assertSame('http', $uri->getScheme());
$this->assertSame('username:password', $uri->getUserInfo());
$this->assertSame('hostname.com', $uri->getHost());
$this->assertSame(9090, $uri->getPort());
$this->assertSame('username:[email protected]:9090', $uri->getAuthority());
$this->assertSame('/path', $uri->getPath());
$this->assertSame('arg=value', $uri->getQuery());
$this->assertSame('anchor', $uri->getFragment());
}

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ public function authorityProvider(): array
*/
public function testGetAuthority(string $autority, string $expected): void
{
$this->assertEquals($expected, (new Uri("{$autority}/path?arg=value#anchor"))->getAuthority());
$this->assertSame($expected, (new Uri("{$autority}/path?arg=value#anchor"))->getAuthority());
}

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ public function portProvider(): array
*/
public function testGetPort(string $scheme, string $port, int $expected): void
{
$this->assertEquals($expected, (new Uri("{$scheme}://username:[email protected]{$port}/path?arg=value#anchor"))->getPort());
$this->assertSame($expected, (int)(new Uri("{$scheme}://username:[email protected]{$port}/path?arg=value#anchor"))->getPort());
}

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

$this->assertEquals('https', $uri->getScheme());
$this->assertSame('https', $uri->getScheme());
}

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

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

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

$this->assertEquals('testUser', $uri->getUserInfo());
$this->assertSame('testUser', $uri->getUserInfo());
}

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

$this->assertEquals('', $uri->getUserInfo());
$this->assertSame('', $uri->getUserInfo());
}

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

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

/**
Expand Down Expand Up @@ -270,7 +270,7 @@ public function testWithPort(): void
{
$uri = (new Uri(self::$uri))->withPort(8080);

$this->assertEquals(8080, $uri->getPort());
$this->assertSame(8080, $uri->getPort());
}

/**
Expand Down Expand Up @@ -356,8 +356,8 @@ public function testWithPath(): void
{
$uri = (new Uri(self::$uri))->withPath('/otherpath');

$this->assertEquals('/otherpath', $uri->getPath());
$this->assertEquals('http://username:[email protected]:9090/otherpath?arg=value#anchor', (string) $uri);
$this->assertSame('/otherpath', $uri->getPath());
$this->assertSame('http://username:[email protected]:9090/otherpath?arg=value#anchor', (string) $uri);
}

/**
Expand Down Expand Up @@ -432,7 +432,7 @@ public function uriProvider(): array
*/
public function testUriToString(string $testUri): void
{
$this->assertEquals($testUri, (string) (new Uri($testUri)));
$this->assertSame($testUri, (string) (new Uri($testUri)));
}

/**
Expand Down Expand Up @@ -464,8 +464,8 @@ public function testWithQuery(string $withQuery, string $expectedQuery, string $
{
$uri = (new Uri(self::$uri))->withQuery($withQuery);

$this->assertEquals($expectedQuery, $uri->getQuery());
$this->assertEquals($expectedUri, (string) $uri);
$this->assertSame($expectedQuery, $uri->getQuery());
$this->assertSame($expectedUri, (string) $uri);
}

/**
Expand Down Expand Up @@ -523,8 +523,8 @@ public function testWithFragment(string $withFragment, string $expectedFragment,
{
$uri = (new Uri(self::$uri))->withFragment($withFragment);

$this->assertEquals($expectedFragment, $uri->getFragment());
$this->assertEquals($expectedUri, (string) $uri);
$this->assertSame($expectedFragment, $uri->getFragment());
$this->assertSame($expectedUri, (string) $uri);
}

/**
Expand Down

0 comments on commit de35d43

Please sign in to comment.