From c12658e1c1a7068a794f039374e384eefaf1a2bb Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Wed, 6 Sep 2017 01:04:11 +0200 Subject: [PATCH] PHPUnit: use better assertions --- test/CallbackStreamTest.php | 8 +- test/HeaderSecurityTest.php | 2 +- test/MessageTraitTest.php | 24 ++--- test/PhpInputStreamTest.php | 4 +- test/RelativeStreamTest.php | 28 +++--- test/Request/SerializerTest.php | 34 +++---- test/RequestTest.php | 36 +++---- test/Response/EmptyResponseTest.php | 10 +- test/Response/HtmlResponseTest.php | 12 +-- test/Response/JsonResponseTest.php | 22 ++--- test/Response/RedirectResponseTest.php | 18 ++-- test/Response/SapiEmitterTest.php | 6 +- test/Response/SapiStreamEmitterTest.php | 28 +++--- test/Response/SerializerTest.php | 24 ++--- test/Response/TextResponseTest.php | 12 +-- test/ResponseTest.php | 16 ++-- test/ServerRequestFactoryTest.php | 68 ++++++------- test/ServerRequestTest.php | 10 +- test/ServerTest.php | 4 +- test/StreamTest.php | 30 +++--- test/UploadedFileTest.php | 4 +- test/UriTest.php | 122 ++++++++++++------------ 22 files changed, 261 insertions(+), 261 deletions(-) diff --git a/test/CallbackStreamTest.php b/test/CallbackStreamTest.php index dc8dc503..c863b61a 100644 --- a/test/CallbackStreamTest.php +++ b/test/CallbackStreamTest.php @@ -45,7 +45,7 @@ public function testToString() }); $ret = $stream->__toString(); - $this->assertEquals('foobarbaz', $ret); + $this->assertSame('foobarbaz', $ret); } public function testClose() @@ -170,7 +170,7 @@ public function testGetContents() }); $ret = $stream->getContents(); - $this->assertEquals('foobarbaz', $ret); + $this->assertSame('foobarbaz', $ret); } public function testGetMetadata() @@ -179,7 +179,7 @@ public function testGetMetadata() }); $ret = $stream->getMetadata('stream_type'); - $this->assertEquals('callback', $ret); + $this->assertSame('callback', $ret); $ret = $stream->getMetadata('seekable'); $this->assertFalse($ret); @@ -217,6 +217,6 @@ public function testAllowsArbitraryPhpCallbacks($callback, $expected) { $stream = new CallbackStream($callback); $contents = $stream->getContents(); - $this->assertEquals($expected, $contents); + $this->assertSame($expected, $contents); } } diff --git a/test/HeaderSecurityTest.php b/test/HeaderSecurityTest.php index 9856fd74..582f4ef9 100644 --- a/test/HeaderSecurityTest.php +++ b/test/HeaderSecurityTest.php @@ -50,7 +50,7 @@ public function getFilterValues() */ public function testFiltersValuesPerRfc7230($value, $expected) { - $this->assertEquals($expected, HeaderSecurity::filter($value)); + $this->assertSame($expected, HeaderSecurity::filter($value)); } public function validateValues() diff --git a/test/MessageTraitTest.php b/test/MessageTraitTest.php index 23e468ce..7d983549 100644 --- a/test/MessageTraitTest.php +++ b/test/MessageTraitTest.php @@ -30,14 +30,14 @@ public function setUp() public function testProtocolHasAcceptableDefault() { - $this->assertEquals('1.1', $this->message->getProtocolVersion()); + $this->assertSame('1.1', $this->message->getProtocolVersion()); } public function testProtocolMutatorReturnsCloneWithChanges() { $message = $this->message->withProtocolVersion('1.0'); $this->assertNotSame($this->message, $message); - $this->assertEquals('1.0', $message->getProtocolVersion()); + $this->assertSame('1.0', $message->getProtocolVersion()); } @@ -89,21 +89,21 @@ public function testGetHeaderReturnsHeaderValueAsArray() { $message = $this->message->withHeader('X-Foo', ['Foo', 'Bar']); $this->assertNotSame($this->message, $message); - $this->assertEquals(['Foo', 'Bar'], $message->getHeader('X-Foo')); + $this->assertSame(['Foo', 'Bar'], $message->getHeader('X-Foo')); } public function testGetHeaderLineReturnsHeaderValueAsCommaConcatenatedString() { $message = $this->message->withHeader('X-Foo', ['Foo', 'Bar']); $this->assertNotSame($this->message, $message); - $this->assertEquals('Foo,Bar', $message->getHeaderLine('X-Foo')); + $this->assertSame('Foo,Bar', $message->getHeaderLine('X-Foo')); } public function testGetHeadersKeepsHeaderCaseSensitivity() { $message = $this->message->withHeader('X-Foo', ['Foo', 'Bar']); $this->assertNotSame($this->message, $message); - $this->assertEquals([ 'X-Foo' => [ 'Foo', 'Bar' ] ], $message->getHeaders()); + $this->assertSame([ 'X-Foo' => [ 'Foo', 'Bar' ] ], $message->getHeaders()); } public function testGetHeadersReturnsCaseWithWhichHeaderFirstRegistered() @@ -112,7 +112,7 @@ public function testGetHeadersReturnsCaseWithWhichHeaderFirstRegistered() ->withHeader('X-Foo', 'Foo') ->withAddedHeader('x-foo', 'Bar'); $this->assertNotSame($this->message, $message); - $this->assertEquals([ 'X-Foo' => [ 'Foo', 'Bar' ] ], $message->getHeaders()); + $this->assertSame([ 'X-Foo' => [ 'Foo', 'Bar' ] ], $message->getHeaders()); } public function testHasHeaderReturnsFalseIfHeaderIsNotPresent() @@ -133,7 +133,7 @@ public function testAddHeaderAppendsToExistingHeader() $this->assertNotSame($this->message, $message); $message2 = $message->withAddedHeader('X-Foo', 'Bar'); $this->assertNotSame($message, $message2); - $this->assertEquals('Foo,Bar', $message2->getHeaderLine('X-Foo')); + $this->assertSame('Foo,Bar', $message2->getHeaderLine('X-Foo')); } public function testHeaderExistsIfWithNoValues() @@ -178,7 +178,7 @@ public function testHeaderRemovalIsCaseInsensitive() $this->assertFalse($message2->hasHeader('X-Foo')); $headers = $message2->getHeaders(); - $this->assertEquals(0, count($headers)); + $this->assertSame(0, count($headers)); } public function invalidGeneralHeaderValues() @@ -228,8 +228,8 @@ public function testWithHeaderReplacesDifferentCapitalization() { $this->message = $this->message->withHeader('X-Foo', ['foo']); $new = $this->message->withHeader('X-foo', ['bar']); - $this->assertEquals(['bar'], $new->getHeader('x-foo')); - $this->assertEquals(['X-foo' => ['bar']], $new->getHeaders()); + $this->assertSame(['bar'], $new->getHeader('x-foo')); + $this->assertSame(['X-foo' => ['bar']], $new->getHeaders()); } /** @@ -311,13 +311,13 @@ public function testDoesNotAllowCRLFInjectionWhenCallingWithAddedHeader($name, $ public function testWithHeaderAllowsHeaderContinuations() { $message = $this->message->withHeader('X-Foo-Bar', "value,\r\n second value"); - $this->assertEquals("value,\r\n second value", $message->getHeaderLine('X-Foo-Bar')); + $this->assertSame("value,\r\n second value", $message->getHeaderLine('X-Foo-Bar')); } public function testWithAddedHeaderAllowsHeaderContinuations() { $message = $this->message->withAddedHeader('X-Foo-Bar', "value,\r\n second value"); - $this->assertEquals("value,\r\n second value", $message->getHeaderLine('X-Foo-Bar')); + $this->assertSame("value,\r\n second value", $message->getHeaderLine('X-Foo-Bar')); } public function numericHeaderValuesProvider() diff --git a/test/PhpInputStreamTest.php b/test/PhpInputStreamTest.php index b2990b5f..32f8e7d4 100644 --- a/test/PhpInputStreamTest.php +++ b/test/PhpInputStreamTest.php @@ -38,7 +38,7 @@ public function getFileContents() public function assertStreamContents($test, $message = null) { $content = $this->getFileContents(); - $this->assertEquals($content, $test, $message); + $this->assertSame($content, $test, $message); } public function testStreamIsNeverWritable() @@ -61,7 +61,7 @@ public function testGetContentsReturnsRemainingContentsOfStream() $remainder = $this->stream->getContents(); $contents = $this->getFileContents(); - $this->assertEquals(substr($contents, 128), $remainder); + $this->assertSame(substr($contents, 128), $remainder); } public function testGetContentsReturnCacheWhenReachedEof() diff --git a/test/RelativeStreamTest.php b/test/RelativeStreamTest.php index 1bc65523..8d34f4c6 100644 --- a/test/RelativeStreamTest.php +++ b/test/RelativeStreamTest.php @@ -30,7 +30,7 @@ public function testToString() $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->__toString(); - $this->assertEquals('foobarbaz', $ret); + $this->assertSame('foobarbaz', $ret); } public function testClose() @@ -47,7 +47,7 @@ public function testDetach() $decorated->detach()->shouldBeCalled()->willReturn(250); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->detach(); - $this->assertEquals(250, $ret); + $this->assertSame(250, $ret); } public function testGetSize() @@ -56,7 +56,7 @@ public function testGetSize() $decorated->getSize()->shouldBeCalled()->willReturn(250); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->getSize(); - $this->assertEquals(150, $ret); + $this->assertSame(150, $ret); } public function testTell() @@ -65,7 +65,7 @@ public function testTell() $decorated->tell()->shouldBeCalled()->willReturn(188); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->tell(); - $this->assertEquals(88, $ret); + $this->assertSame(88, $ret); } public function testIsSeekable() @@ -74,7 +74,7 @@ public function testIsSeekable() $decorated->isSeekable()->shouldBeCalled()->willReturn(true); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->isSeekable(); - $this->assertEquals(true, $ret); + $this->assertSame(true, $ret); } public function testIsWritable() @@ -83,7 +83,7 @@ public function testIsWritable() $decorated->isWritable()->shouldBeCalled()->willReturn(true); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->isWritable(); - $this->assertEquals(true, $ret); + $this->assertSame(true, $ret); } public function testIsReadable() @@ -92,7 +92,7 @@ public function testIsReadable() $decorated->isReadable()->shouldBeCalled()->willReturn(false); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->isReadable(); - $this->assertEquals(false, $ret); + $this->assertSame(false, $ret); } public function testSeek() @@ -101,7 +101,7 @@ public function testSeek() $decorated->seek(126, SEEK_SET)->shouldBeCalled()->willReturn(0); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->seek(26); - $this->assertEquals(0, $ret); + $this->assertSame(0, $ret); } public function testRewind() @@ -110,7 +110,7 @@ public function testRewind() $decorated->seek(100, SEEK_SET)->shouldBeCalled()->willReturn(0); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->rewind(); - $this->assertEquals(0, $ret); + $this->assertSame(0, $ret); } public function testWrite() @@ -120,7 +120,7 @@ public function testWrite() $decorated->write("foobaz")->shouldBeCalled()->willReturn(6); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->write("foobaz"); - $this->assertEquals(6, $ret); + $this->assertSame(6, $ret); } public function testRead() @@ -130,7 +130,7 @@ public function testRead() $decorated->read(3)->shouldBeCalled()->willReturn("foo"); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->read(3); - $this->assertEquals("foo", $ret); + $this->assertSame("foo", $ret); } public function testGetContents() @@ -140,7 +140,7 @@ public function testGetContents() $decorated->getContents()->shouldBeCalled()->willReturn("foo"); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->getContents(); - $this->assertEquals("foo", $ret); + $this->assertSame("foo", $ret); } public function testGetMetadata() @@ -149,7 +149,7 @@ public function testGetMetadata() $decorated->getMetadata("bar")->shouldBeCalled()->willReturn("foo"); $stream = new RelativeStream($decorated->reveal(), 100); $ret = $stream->getMetadata("bar"); - $this->assertEquals("foo", $ret); + $this->assertSame("foo", $ret); } public function testWriteRaisesExceptionWhenPointerIsBehindOffset() @@ -200,6 +200,6 @@ public function testCanReadContentFromNotSeekableResource() $decorated->getContents()->willReturn('CONTENTS'); $stream = new RelativeStream($decorated->reveal(), 3); - $this->assertEquals('CONTENTS', $stream->__toString()); + $this->assertSame('CONTENTS', $stream->__toString()); } } diff --git a/test/Request/SerializerTest.php b/test/Request/SerializerTest.php index 57d2195a..1d6bc455 100644 --- a/test/Request/SerializerTest.php +++ b/test/Request/SerializerTest.php @@ -30,7 +30,7 @@ public function testSerializesBasicRequest() ->withAddedHeader('Accept', 'text/html'); $message = Serializer::toString($request); - $this->assertEquals( + $this->assertSame( "GET /foo/bar?baz=bat HTTP/1.1\r\nHost: example.com\r\nAccept: text/html", $message ); @@ -91,12 +91,12 @@ public function testCanDeserializeRequestWithOriginForm($line, $requestTarget, $ $message = $line . "\r\nX-Foo-Bar: Baz\r\n\r\nContent"; $request = Serializer::fromString($message); - $this->assertEquals('GET', $request->getMethod()); - $this->assertEquals($requestTarget, $request->getRequestTarget()); + $this->assertSame('GET', $request->getMethod()); + $this->assertSame($requestTarget, $request->getRequestTarget()); $uri = $request->getUri(); foreach ($expectations as $method => $expect) { - $this->assertEquals($expect, $uri->{$method}()); + $this->assertSame($expect, $uri->{$method}()); } } @@ -156,13 +156,13 @@ public function testCanDeserializeRequestWithAbsoluteForm($line, $requestTarget, $message = $line . "\r\nX-Foo-Bar: Baz\r\n\r\nContent"; $request = Serializer::fromString($message); - $this->assertEquals('GET', $request->getMethod()); + $this->assertSame('GET', $request->getMethod()); - $this->assertEquals($requestTarget, $request->getRequestTarget()); + $this->assertSame($requestTarget, $request->getRequestTarget()); $uri = $request->getUri(); foreach ($expectations as $method => $expect) { - $this->assertEquals($expect, $uri->{$method}()); + $this->assertSame($expect, $uri->{$method}()); } } @@ -170,26 +170,26 @@ public function testCanDeserializeRequestWithAuthorityForm() { $message = "CONNECT www.example.com:80 HTTP/1.1\r\nX-Foo-Bar: Baz"; $request = Serializer::fromString($message); - $this->assertEquals('CONNECT', $request->getMethod()); - $this->assertEquals('www.example.com:80', $request->getRequestTarget()); + $this->assertSame('CONNECT', $request->getMethod()); + $this->assertSame('www.example.com:80', $request->getRequestTarget()); $uri = $request->getUri(); - $this->assertNotEquals('www.example.com', $uri->getHost()); - $this->assertNotEquals(80, $uri->getPort()); + $this->assertNotSame('www.example.com', $uri->getHost()); + $this->assertNotSame(80, $uri->getPort()); } public function testCanDeserializeRequestWithAsteriskForm() { $message = "OPTIONS * HTTP/1.1\r\nHost: www.example.com"; $request = Serializer::fromString($message); - $this->assertEquals('OPTIONS', $request->getMethod()); - $this->assertEquals('*', $request->getRequestTarget()); + $this->assertSame('OPTIONS', $request->getMethod()); + $this->assertSame('*', $request->getRequestTarget()); $uri = $request->getUri(); - $this->assertNotEquals('www.example.com', $uri->getHost()); + $this->assertNotSame('www.example.com', $uri->getHost()); $this->assertTrue($request->hasHeader('Host')); - $this->assertEquals('www.example.com', $request->getHeaderLine('Host')); + $this->assertSame('www.example.com', $request->getHeaderLine('Host')); } public function invalidRequestLines() @@ -224,7 +224,7 @@ public function testCanDeserializeResponseWithMultipleHeadersOfSameName() $this->assertTrue($request->hasHeader('X-Foo-Bar')); $values = $request->getHeader('X-Foo-Bar'); - $this->assertEquals(['Baz', 'Bat'], $values); + $this->assertSame(['Baz', 'Bat'], $values); } public function headersWithContinuationLines() @@ -246,7 +246,7 @@ public function testCanDeserializeResponseWithHeaderContinuations($text) $this->assertInstanceOf(Request::class, $request); $this->assertTrue($request->hasHeader('X-Foo-Bar')); - $this->assertEquals('Baz;Bat', $request->getHeaderLine('X-Foo-Bar')); + $this->assertSame('Baz;Bat', $request->getHeaderLine('X-Foo-Bar')); } public function messagesWithInvalidHeaders() diff --git a/test/RequestTest.php b/test/RequestTest.php index d7a18bdb..23eb45e9 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -37,7 +37,7 @@ public function testMethodMutatorReturnsCloneWithChangedMethod() { $request = $this->request->withMethod('GET'); $this->assertNotSame($this->request, $request); - $this->assertEquals('GET', $request->getMethod()); + $this->assertSame('GET', $request->getMethod()); } public function testReturnsUnpopulatedUriByDefault() @@ -68,7 +68,7 @@ public function testWithUriReturnsNewInstanceWithNewUri() $request2 = $request->withUri(new Uri('/baz/bat?foo=bar')); $this->assertNotSame($this->request, $request2); $this->assertNotSame($request, $request2); - $this->assertEquals('/baz/bat?foo=bar', (string) $request2->getUri()); + $this->assertSame('/baz/bat?foo=bar', (string) $request2->getUri()); } public function testConstructorCanAcceptAllMessageParts() @@ -86,12 +86,12 @@ public function testConstructorCanAcceptAllMessageParts() ); $this->assertSame($uri, $request->getUri()); - $this->assertEquals('POST', $request->getMethod()); + $this->assertSame('POST', $request->getMethod()); $this->assertSame($body, $request->getBody()); $testHeaders = $request->getHeaders(); foreach ($headers as $key => $value) { $this->assertArrayHasKey($key, $testHeaders); - $this->assertEquals($value, $testHeaders[$key]); + $this->assertSame($value, $testHeaders[$key]); } } @@ -227,14 +227,14 @@ public function testConstructorRaisesExceptionForInvalidHeaders($headers, $conta public function testRequestTargetIsSlashWhenNoUriPresent() { $request = new Request(); - $this->assertEquals('/', $request->getRequestTarget()); + $this->assertSame('/', $request->getRequestTarget()); } public function testRequestTargetIsSlashWhenUriHasNoPathOrQuery() { $request = (new Request()) ->withUri(new Uri('http://example.com')); - $this->assertEquals('/', $request->getRequestTarget()); + $this->assertSame('/', $request->getRequestTarget()); } public function requestsWithUri() @@ -272,7 +272,7 @@ public function requestsWithUri() */ public function testReturnsRequestTargetWhenUriIsPresent($request, $expected) { - $this->assertEquals($expected, $request->getRequestTarget()); + $this->assertSame($expected, $request->getRequestTarget()); } public function validRequestTargets() @@ -293,7 +293,7 @@ public function validRequestTargets() public function testCanProvideARequestTarget($requestTarget) { $request = (new Request())->withRequestTarget($requestTarget); - $this->assertEquals($requestTarget, $request->getRequestTarget()); + $this->assertSame($requestTarget, $request->getRequestTarget()); } public function testRequestTargetCannotContainWhitespace() @@ -311,7 +311,7 @@ public function testRequestTargetDoesNotCacheBetweenInstances() $request = (new Request())->withUri(new Uri('https://example.com/foo/bar')); $original = $request->getRequestTarget(); $newRequest = $request->withUri(new Uri('http://mwop.net/bar/baz')); - $this->assertNotEquals($original, $newRequest->getRequestTarget()); + $this->assertNotSame($original, $newRequest->getRequestTarget()); } public function testSettingNewUriResetsRequestTarget() @@ -319,7 +319,7 @@ public function testSettingNewUriResetsRequestTarget() $request = (new Request())->withUri(new Uri('https://example.com/foo/bar')); $newRequest = $request->withUri(new Uri('http://mwop.net/bar/baz')); - $this->assertNotEquals($request->getRequestTarget(), $newRequest->getRequestTarget()); + $this->assertNotSame($request->getRequestTarget(), $newRequest->getRequestTarget()); } /** @@ -371,7 +371,7 @@ public function testGetHostHeaderReturnsUriHostWhenPresent() { $request = new Request('http://example.com'); $header = $request->getHeader('host'); - $this->assertEquals(['example.com'], $header); + $this->assertSame(['example.com'], $header); } /** @@ -381,7 +381,7 @@ public function testGetHostHeaderReturnsUriHostWhenHostHeaderDeleted() { $request = (new Request('http://example.com'))->withoutHeader('host'); $header = $request->getHeader('host'); - $this->assertEquals(['example.com'], $header); + $this->assertSame(['example.com'], $header); } /** @@ -434,13 +434,13 @@ public function testHostHeaderSetFromUriOnCreationIfNoHostHeaderSpecified() { $request = new Request('http://www.example.com'); $this->assertTrue($request->hasHeader('Host')); - $this->assertEquals('www.example.com', $request->getHeaderLine('host')); + $this->assertSame('www.example.com', $request->getHeaderLine('host')); } public function testHostHeaderNotSetFromUriOnCreationIfHostHeaderSpecified() { $request = new Request('http://www.example.com', null, 'php://memory', ['Host' => 'www.test.com']); - $this->assertEquals('www.test.com', $request->getHeaderLine('host')); + $this->assertSame('www.test.com', $request->getHeaderLine('host')); } public function testPassingPreserveHostFlagWhenUpdatingUriDoesNotUpdateHostHeader() @@ -451,7 +451,7 @@ public function testPassingPreserveHostFlagWhenUpdatingUriDoesNotUpdateHostHeade $uri = (new Uri())->withHost('www.example.com'); $new = $request->withUri($uri, true); - $this->assertEquals('example.com', $new->getHeaderLine('Host')); + $this->assertSame('example.com', $new->getHeaderLine('Host')); } public function testNotPassingPreserveHostFlagWhenUpdatingUriWithoutHostDoesNotUpdateHostHeader() @@ -462,7 +462,7 @@ public function testNotPassingPreserveHostFlagWhenUpdatingUriWithoutHostDoesNotU $uri = new Uri(); $new = $request->withUri($uri); - $this->assertEquals('example.com', $new->getHeaderLine('Host')); + $this->assertSame('example.com', $new->getHeaderLine('Host')); } public function testHostHeaderUpdatesToUriHostAndPortWhenPreserveHostDisabledAndNonStandardPort() @@ -475,7 +475,7 @@ public function testHostHeaderUpdatesToUriHostAndPortWhenPreserveHostDisabledAnd ->withPort(10081); $new = $request->withUri($uri); - $this->assertEquals('www.example.com:10081', $new->getHeaderLine('Host')); + $this->assertSame('www.example.com:10081', $new->getHeaderLine('Host')); } public function headersWithInjectionVectors() @@ -541,7 +541,7 @@ public function testWithUriAndNoPreserveHostWillOverwriteHostHeaderRegardlessOfO $uri = new Uri('http://example.org/foo/bar'); $new = $request->withUri($uri); $host = $new->getHeaderLine('host'); - $this->assertEquals('example.org', $host); + $this->assertSame('example.org', $host); $headers = $new->getHeaders(); $this->assertArrayHasKey('Host', $headers); if ($hostKey !== 'Host') { diff --git a/test/Response/EmptyResponseTest.php b/test/Response/EmptyResponseTest.php index 19ba65a9..b236fb85 100644 --- a/test/Response/EmptyResponseTest.php +++ b/test/Response/EmptyResponseTest.php @@ -19,16 +19,16 @@ public function testConstructor() { $response = new EmptyResponse(201); $this->assertInstanceOf(Response::class, $response); - $this->assertEquals('', (string) $response->getBody()); - $this->assertEquals(201, $response->getStatusCode()); + $this->assertSame('', (string) $response->getBody()); + $this->assertSame(201, $response->getStatusCode()); } public function testHeaderConstructor() { $response = EmptyResponse::withHeaders(['x-empty' => ['true']]); $this->assertInstanceOf(Response::class, $response); - $this->assertEquals('', (string) $response->getBody()); - $this->assertEquals(204, $response->getStatusCode()); - $this->assertEquals('true', $response->getHeaderLine('x-empty')); + $this->assertSame('', (string) $response->getBody()); + $this->assertSame(204, $response->getStatusCode()); + $this->assertSame('true', $response->getHeaderLine('x-empty')); } } diff --git a/test/Response/HtmlResponseTest.php b/test/Response/HtmlResponseTest.php index 949d01b9..89f75fa8 100644 --- a/test/Response/HtmlResponseTest.php +++ b/test/Response/HtmlResponseTest.php @@ -22,7 +22,7 @@ public function testConstructorAcceptsHtmlString() $response = new HtmlResponse($body); $this->assertSame($body, (string) $response->getBody()); - $this->assertEquals(200, $response->getStatusCode()); + $this->assertSame(200, $response->getStatusCode()); } public function testConstructorAllowsPassingStatus() @@ -31,7 +31,7 @@ public function testConstructorAllowsPassingStatus() $status = 404; $response = new HtmlResponse($body, $status); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame(404, $response->getStatusCode()); $this->assertSame($body, (string) $response->getBody()); } @@ -44,9 +44,9 @@ public function testConstructorAllowsPassingHeaders() ]; $response = new HtmlResponse($body, $status, $headers); - $this->assertEquals(['foo-bar'], $response->getHeader('x-custom')); - $this->assertEquals('text/html; charset=utf-8', $response->getHeaderLine('content-type')); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame(['foo-bar'], $response->getHeader('x-custom')); + $this->assertSame('text/html; charset=utf-8', $response->getHeaderLine('content-type')); + $this->assertSame(404, $response->getStatusCode()); $this->assertSame($body, (string) $response->getBody()); } @@ -89,6 +89,6 @@ public function testConstructorRewindsBodyStream() $response = new HtmlResponse($html); $actual = $response->getBody()->getContents(); - $this->assertEquals($html, $actual); + $this->assertSame($html, $actual); } } diff --git a/test/Response/JsonResponseTest.php b/test/Response/JsonResponseTest.php index 4b339e2f..210279df 100644 --- a/test/Response/JsonResponseTest.php +++ b/test/Response/JsonResponseTest.php @@ -27,8 +27,8 @@ public function testConstructorAcceptsDataAndCreatesJsonEncodedMessageBody() $json = '{"nested":{"json":["tree"]}}'; $response = new JsonResponse($data); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('application/json', $response->getHeaderLine('content-type')); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('application/json', $response->getHeaderLine('content-type')); $this->assertSame($json, (string) $response->getBody()); } @@ -53,8 +53,8 @@ public function scalarValuesForJSON() public function testScalarValuePassedToConstructorJsonEncodesDirectly($value) { $response = new JsonResponse($value); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('application/json', $response->getHeaderLine('content-type')); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('application/json', $response->getHeaderLine('content-type')); // 15 is the default mask used by JsonResponse $this->assertSame(json_encode($value, 15), (string) $response->getBody()); } @@ -62,13 +62,13 @@ public function testScalarValuePassedToConstructorJsonEncodesDirectly($value) public function testCanProvideStatusCodeToConstructor() { $response = new JsonResponse(null, 404); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame(404, $response->getStatusCode()); } public function testCanProvideAlternateContentTypeViaHeadersPassedToConstructor() { $response = new JsonResponse(null, 200, ['content-type' => 'foo/json']); - $this->assertEquals('foo/json', $response->getHeaderLine('content-type')); + $this->assertSame('foo/json', $response->getHeaderLine('content-type')); } public function testJsonErrorHandlingOfResources() @@ -128,14 +128,14 @@ public function testConstructorRewindsBodyStream() $response = new JsonResponse($json); $actual = json_decode($response->getBody()->getContents(), true); - $this->assertEquals($json, $actual); + $this->assertSame($json, $actual); } public function testPayloadGetter() { $payload = ['test' => 'data']; $response = new JsonResponse($payload); - $this->assertEquals($payload, $response->getPayload()); + $this->assertSame($payload, $response->getPayload()); } public function testWithPayload() @@ -145,9 +145,9 @@ public function testWithPayload() $newResponse = $response->withPayload($json); $this->assertNotSame($response, $newResponse); - $this->assertEquals($json, $newResponse->getPayload()); + $this->assertSame($json, $newResponse->getPayload()); $decodedBody = json_decode($newResponse->getBody()->getContents(), true); - $this->assertEquals($json, $decodedBody); + $this->assertSame($json, $decodedBody); } public function testEncodingOptionsGetter() @@ -189,6 +189,6 @@ public function testModifyingThePayloadDoesntMutateResponseInstance() $payload->bar = 'baz'; $this->assertEquals($originalPayload, $response->getPayload()); - $this->assertNotEquals($payload, $response->getPayload()); + $this->assertNotSame($payload, $response->getPayload()); } } diff --git a/test/Response/RedirectResponseTest.php b/test/Response/RedirectResponseTest.php index 4b07866d..7b91d03e 100644 --- a/test/Response/RedirectResponseTest.php +++ b/test/Response/RedirectResponseTest.php @@ -19,36 +19,36 @@ class RedirectResponseTest extends TestCase public function testConstructorAcceptsStringUriAndProduces302ResponseWithLocationHeader() { $response = new RedirectResponse('/foo/bar'); - $this->assertEquals(302, $response->getStatusCode()); + $this->assertSame(302, $response->getStatusCode()); $this->assertTrue($response->hasHeader('Location')); - $this->assertEquals('/foo/bar', $response->getHeaderLine('Location')); + $this->assertSame('/foo/bar', $response->getHeaderLine('Location')); } public function testConstructorAcceptsUriInstanceAndProduces302ResponseWithLocationHeader() { $uri = new Uri('https://example.com:10082/foo/bar'); $response = new RedirectResponse($uri); - $this->assertEquals(302, $response->getStatusCode()); + $this->assertSame(302, $response->getStatusCode()); $this->assertTrue($response->hasHeader('Location')); - $this->assertEquals((string) $uri, $response->getHeaderLine('Location')); + $this->assertSame((string) $uri, $response->getHeaderLine('Location')); } public function testConstructorAllowsSpecifyingAlternateStatusCode() { $response = new RedirectResponse('/foo/bar', 301); - $this->assertEquals(301, $response->getStatusCode()); + $this->assertSame(301, $response->getStatusCode()); $this->assertTrue($response->hasHeader('Location')); - $this->assertEquals('/foo/bar', $response->getHeaderLine('Location')); + $this->assertSame('/foo/bar', $response->getHeaderLine('Location')); } public function testConstructorAllowsSpecifyingHeaders() { $response = new RedirectResponse('/foo/bar', 302, ['X-Foo' => ['Bar']]); - $this->assertEquals(302, $response->getStatusCode()); + $this->assertSame(302, $response->getStatusCode()); $this->assertTrue($response->hasHeader('Location')); - $this->assertEquals('/foo/bar', $response->getHeaderLine('Location')); + $this->assertSame('/foo/bar', $response->getHeaderLine('Location')); $this->assertTrue($response->hasHeader('X-Foo')); - $this->assertEquals('Bar', $response->getHeaderLine('X-Foo')); + $this->assertSame('Bar', $response->getHeaderLine('X-Foo')); } public function invalidUris() diff --git a/test/Response/SapiEmitterTest.php b/test/Response/SapiEmitterTest.php index 62aa6320..8bf90da9 100644 --- a/test/Response/SapiEmitterTest.php +++ b/test/Response/SapiEmitterTest.php @@ -27,12 +27,12 @@ public function testEmitsBufferLevel() $response->getBody()->write('Content!'); ob_start(); $this->emitter->emit($response); - $this->assertEquals('Content!', ob_get_contents()); + $this->assertSame('Content!', ob_get_contents()); ob_end_clean(); - $this->assertEquals('level4 ', ob_get_contents(), 'current buffer level string must remains after emit'); + $this->assertSame('level4 ', ob_get_contents(), 'current buffer level string must remains after emit'); ob_end_clean(); $this->emitter->emit($response, 2); - $this->assertEquals('level2 level3 Content!', ob_get_contents(), 'must buffer until specified level'); + $this->assertSame('level2 level3 Content!', ob_get_contents(), 'must buffer until specified level'); ob_end_clean(); } } diff --git a/test/Response/SapiStreamEmitterTest.php b/test/Response/SapiStreamEmitterTest.php index fe401755..ff25396d 100644 --- a/test/Response/SapiStreamEmitterTest.php +++ b/test/Response/SapiStreamEmitterTest.php @@ -38,7 +38,7 @@ public function testEmitCallbackStreamResponse() ->withBody($stream); ob_start(); $this->emitter->emit($response); - $this->assertEquals('it works', ob_get_clean()); + $this->assertSame('it works', ob_get_clean()); } public function testDoesNotInjectContentLengthHeaderIfStreamSizeIsUnknown() @@ -249,9 +249,9 @@ function ($bufferLength) use (& $peakBufferLength) { $stream->checkProphecyMethodsPredictions(); - $this->assertEquals($seekable, $rewindCalled); - $this->assertEquals(! $readable, $fullContentsCalled); - $this->assertEquals($contents, $emittedContents); + $this->assertSame($seekable, $rewindCalled); + $this->assertSame(! $readable, $fullContentsCalled); + $this->assertSame($contents, $emittedContents); $this->assertLessThanOrEqual($maxBufferLength, $peakBufferLength); } @@ -381,8 +381,8 @@ function ($bufferLength) use (& $peakBufferLength) { $stream->checkProphecyMethodsPredictions(); - $this->assertEquals($seekable, $seekCalled); - $this->assertEquals(substr($contents, $first, $last - $first + 1), $emittedContents); + $this->assertSame($seekable, $seekCalled); + $this->assertSame(substr($contents, $first, $last - $first + 1), $emittedContents); $this->assertLessThanOrEqual($maxBufferLength, $peakBufferLength); } @@ -536,8 +536,8 @@ public function testEmitHtmlResponse() ob_start(); $this->emitter->emit($response); - $this->assertEquals('text/html; charset=utf-8', $response->getHeaderLine('content-type')); - $this->assertEquals($contents, ob_get_clean()); + $this->assertSame('text/html; charset=utf-8', $response->getHeaderLine('content-type')); + $this->assertSame($contents, ob_get_clean()); } public function emitJsonResponseProvider() @@ -564,8 +564,8 @@ public function testEmitJsonResponse($contents) ob_start(); $this->emitter->emit($response); - $this->assertEquals('application/json', $response->getHeaderLine('content-type')); - $this->assertEquals(json_encode($contents), ob_get_clean()); + $this->assertSame('application/json', $response->getHeaderLine('content-type')); + $this->assertSame(json_encode($contents), ob_get_clean()); } public function testEmitTextResponse() @@ -577,8 +577,8 @@ public function testEmitTextResponse() ob_start(); $this->emitter->emit($response); - $this->assertEquals('text/plain; charset=utf-8', $response->getHeaderLine('content-type')); - $this->assertEquals($contents, ob_get_clean()); + $this->assertSame('text/plain; charset=utf-8', $response->getHeaderLine('content-type')); + $this->assertSame($contents, ob_get_clean()); } public function contentRangeProvider() @@ -602,7 +602,7 @@ public function testContentRange($header, $body, $expected) ob_start(); $this->emitter->emit($response); - $this->assertEquals($expected, ob_get_clean()); + $this->assertSame($expected, ob_get_clean()); } public function testContentRangeUnseekableBody() @@ -616,6 +616,6 @@ public function testContentRangeUnseekableBody() ob_start(); $this->emitter->emit($response); - $this->assertEquals('lo w', ob_get_clean()); + $this->assertSame('lo w', ob_get_clean()); } } diff --git a/test/Response/SerializerTest.php b/test/Response/SerializerTest.php index e586103c..ca3d8c9a 100644 --- a/test/Response/SerializerTest.php +++ b/test/Response/SerializerTest.php @@ -28,7 +28,7 @@ public function testSerializesBasicResponse() $response->getBody()->write('Content!'); $message = Serializer::toString($response); - $this->assertEquals( + $this->assertSame( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nX-Foo-Bar: Baz\r\n\r\nContent!", $message ); @@ -41,7 +41,7 @@ public function testSerializesResponseWithoutBodyCorrectly() ->withAddedHeader('Content-Type', 'text/plain'); $message = Serializer::toString($response); - $this->assertEquals( + $this->assertSame( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n", $message ); @@ -78,17 +78,17 @@ public function testCanDeserializeBasicResponse() $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertInstanceOf(Response::class, $response); - $this->assertEquals('1.0', $response->getProtocolVersion()); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('A-OK', $response->getReasonPhrase()); + $this->assertSame('1.0', $response->getProtocolVersion()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('A-OK', $response->getReasonPhrase()); $this->assertTrue($response->hasHeader('Content-Type')); - $this->assertEquals('text/plain', $response->getHeaderLine('Content-Type')); + $this->assertSame('text/plain', $response->getHeaderLine('Content-Type')); $this->assertTrue($response->hasHeader('X-Foo-Bar')); - $this->assertEquals('Baz', $response->getHeaderLine('X-Foo-Bar')); + $this->assertSame('Baz', $response->getHeaderLine('X-Foo-Bar')); - $this->assertEquals('Content!', (string) $response->getBody()); + $this->assertSame('Content!', (string) $response->getBody()); } public function testCanDeserializeResponseWithMultipleHeadersOfSameName() @@ -101,7 +101,7 @@ public function testCanDeserializeResponseWithMultipleHeadersOfSameName() $this->assertTrue($response->hasHeader('X-Foo-Bar')); $values = $response->getHeader('X-Foo-Bar'); - $this->assertEquals(['Baz', 'Bat'], $values); + $this->assertSame(['Baz', 'Bat'], $values); } public function headersWithContinuationLines() @@ -123,7 +123,7 @@ public function testCanDeserializeResponseWithHeaderContinuations($text) $this->assertInstanceOf(Response::class, $response); $this->assertTrue($response->hasHeader('X-Foo-Bar')); - $this->assertEquals('Baz;Bat', $response->getHeaderLine('X-Foo-Bar')); + $this->assertSame('Baz;Bat', $response->getHeaderLine('X-Foo-Bar')); } public function testCanDeserializeResponseWithoutBody() @@ -135,7 +135,7 @@ public function testCanDeserializeResponseWithoutBody() $this->assertInstanceOf(Response::class, $response); $this->assertTrue($response->hasHeader('X-Foo-Bar')); - $this->assertEquals('Baz', $response->getHeaderLine('X-Foo-Bar')); + $this->assertSame('Baz', $response->getHeaderLine('X-Foo-Bar')); $body = $response->getBody()->getContents(); $this->assertEmpty($body); @@ -164,7 +164,7 @@ public function testCanDeserializeResponseWithoutHeadersButContainingBody() $this->assertEmpty($response->getHeaders()); $body = $response->getBody()->getContents(); - $this->assertEquals('Content!', $body); + $this->assertSame('Content!', $body); } public function testDeserializationRaisesExceptionForInvalidStatusLine() diff --git a/test/Response/TextResponseTest.php b/test/Response/TextResponseTest.php index 85661379..2dd80613 100644 --- a/test/Response/TextResponseTest.php +++ b/test/Response/TextResponseTest.php @@ -22,7 +22,7 @@ public function testConstructorAcceptsBodyAsString() $response = new TextResponse($body); $this->assertSame($body, (string) $response->getBody()); - $this->assertEquals(200, $response->getStatusCode()); + $this->assertSame(200, $response->getStatusCode()); } public function testConstructorAllowsPassingStatus() @@ -31,7 +31,7 @@ public function testConstructorAllowsPassingStatus() $status = 404; $response = new TextResponse($body, $status); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame(404, $response->getStatusCode()); $this->assertSame($body, (string) $response->getBody()); } @@ -44,9 +44,9 @@ public function testConstructorAllowsPassingHeaders() ]; $response = new TextResponse($body, $status, $headers); - $this->assertEquals(['foo-bar'], $response->getHeader('x-custom')); - $this->assertEquals('text/plain; charset=utf-8', $response->getHeaderLine('content-type')); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame(['foo-bar'], $response->getHeader('x-custom')); + $this->assertSame('text/plain; charset=utf-8', $response->getHeaderLine('content-type')); + $this->assertSame(404, $response->getStatusCode()); $this->assertSame($body, (string) $response->getBody()); } @@ -92,6 +92,6 @@ public function testConstructorRewindsBodyStream() $response = new TextResponse($text); $actual = $response->getBody()->getContents(); - $this->assertEquals($text, $actual); + $this->assertSame($text, $actual); } } diff --git a/test/ResponseTest.php b/test/ResponseTest.php index 51c95e88..f4eb549a 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -30,20 +30,20 @@ public function setUp() public function testStatusCodeIs200ByDefault() { - $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertSame(200, $this->response->getStatusCode()); } public function testStatusCodeMutatorReturnsCloneWithChanges() { $response = $this->response->withStatus(400); $this->assertNotSame($this->response, $response); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertSame(400, $response->getStatusCode()); } public function testReasonPhraseDefaultsToStandards() { $response = $this->response->withStatus(422); - $this->assertEquals('Unprocessable Entity', $response->getReasonPhrase()); + $this->assertSame('Unprocessable Entity', $response->getReasonPhrase()); } public function ianaCodesReasonPhrasesProvider() @@ -100,13 +100,13 @@ public function ianaCodesReasonPhrasesProvider() public function testReasonPhraseDefaultsAgainstIana($code, $reasonPhrase) { $response = $this->response->withStatus($code); - $this->assertEquals($reasonPhrase, $response->getReasonPhrase()); + $this->assertSame($reasonPhrase, $response->getReasonPhrase()); } public function testCanSetCustomReasonPhrase() { $response = $this->response->withStatus(422, 'Foo Bar!'); - $this->assertEquals('Foo Bar!', $response->getReasonPhrase()); + $this->assertSame('Foo Bar!', $response->getReasonPhrase()); } public function testConstructorRaisesExceptionForInvalidStream() @@ -126,8 +126,8 @@ public function testConstructorCanAcceptAllMessageParts() $response = new Response($body, $status, $headers); $this->assertSame($body, $response->getBody()); - $this->assertEquals(302, $response->getStatusCode()); - $this->assertEquals($headers, $response->getHeaders()); + $this->assertSame(302, $response->getStatusCode()); + $this->assertSame($headers, $response->getHeaders()); } /** @@ -137,7 +137,7 @@ public function testCreateWithValidStatusCodes($code) { $response = $this->response->withStatus($code); - $this->assertEquals($code, $response->getStatusCode()); + $this->assertSame($code, $response->getStatusCode()); } public function validStatusCodes() diff --git a/test/ServerRequestFactoryTest.php b/test/ServerRequestFactoryTest.php index 27aeacf7..53ee2a63 100644 --- a/test/ServerRequestFactoryTest.php +++ b/test/ServerRequestFactoryTest.php @@ -78,7 +78,7 @@ public function testMarshalsExpectedHeadersFromServerArray() 'content-length' => 'UNSPECIFIED', ]; - $this->assertEquals($expected, ServerRequestFactory::marshalHeaders($server)); + $this->assertSame($expected, ServerRequestFactory::marshalHeaders($server)); } public function testMarshalsVariablesPrefixedByApacheFromServerArray() @@ -117,7 +117,7 @@ public function testMarshalRequestUriUsesIISUnencodedUrlValueIfPresentAndUrlWasR 'UNENCODED_URL' => '/foo/bar', ]; - $this->assertEquals($server['UNENCODED_URL'], ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame($server['UNENCODED_URL'], ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalRequestUriUsesHTTPXRewriteUrlIfPresent() @@ -129,7 +129,7 @@ public function testMarshalRequestUriUsesHTTPXRewriteUrlIfPresent() 'HTTP_X_REWRITE_URL' => '/bar/baz', ]; - $this->assertEquals($server['HTTP_X_REWRITE_URL'], ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame($server['HTTP_X_REWRITE_URL'], ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalRequestUriUsesHTTPXOriginalUrlIfPresent() @@ -142,7 +142,7 @@ public function testMarshalRequestUriUsesHTTPXOriginalUrlIfPresent() 'HTTP_X_ORIGINAL_URL' => '/baz/bat', ]; - $this->assertEquals($server['HTTP_X_ORIGINAL_URL'], ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame($server['HTTP_X_ORIGINAL_URL'], ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalRequestUriStripsSchemeHostAndPortInformationWhenPresent() @@ -151,7 +151,7 @@ public function testMarshalRequestUriStripsSchemeHostAndPortInformationWhenPrese 'REQUEST_URI' => 'http://example.com:8000/foo/bar', ]; - $this->assertEquals('/foo/bar', ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame('/foo/bar', ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalRequestUriUsesOrigPathInfoIfPresent() @@ -160,14 +160,14 @@ public function testMarshalRequestUriUsesOrigPathInfoIfPresent() 'ORIG_PATH_INFO' => '/foo/bar', ]; - $this->assertEquals('/foo/bar', ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame('/foo/bar', ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalRequestUriFallsBackToRoot() { $server = []; - $this->assertEquals('/', ServerRequestFactory::marshalRequestUri($server)); + $this->assertSame('/', ServerRequestFactory::marshalRequestUri($server)); } public function testMarshalHostAndPortUsesHostHeaderWhenPresent() @@ -179,7 +179,7 @@ public function testMarshalHostAndPortUsesHostHeaderWhenPresent() $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders()); - $this->assertEquals('example.com', $accumulator->host); + $this->assertSame('example.com', $accumulator->host); $this->assertNull($accumulator->port); } @@ -192,8 +192,8 @@ public function testMarshalHostAndPortWillDetectPortInHostHeaderWhenPresent() $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders()); - $this->assertEquals('example.com', $accumulator->host); - $this->assertEquals(8000, $accumulator->port); + $this->assertSame('example.com', $accumulator->host); + $this->assertSame(8000, $accumulator->port); } public function testMarshalHostAndPortReturnsEmptyValuesIfNoHostHeaderAndNoServerName() @@ -203,7 +203,7 @@ public function testMarshalHostAndPortReturnsEmptyValuesIfNoHostHeaderAndNoServe $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders()); - $this->assertEquals('', $accumulator->host); + $this->assertSame('', $accumulator->host); $this->assertNull($accumulator->port); } @@ -217,7 +217,7 @@ public function testMarshalHostAndPortReturnsServerNameForHostWhenPresent() ]; $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders()); - $this->assertEquals('example.com', $accumulator->host); + $this->assertSame('example.com', $accumulator->host); $this->assertNull($accumulator->port); } @@ -232,8 +232,8 @@ public function testMarshalHostAndPortReturnsServerPortForPortWhenPresentWithSer ]; $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders()); - $this->assertEquals('example.com', $accumulator->host); - $this->assertEquals(8000, $accumulator->port); + $this->assertSame('example.com', $accumulator->host); + $this->assertSame(8000, $accumulator->port); } public function testMarshalHostAndPortReturnsServerNameForHostIfServerAddrPresentButHostIsNotIpv6Address() @@ -247,7 +247,7 @@ public function testMarshalHostAndPortReturnsServerNameForHostIfServerAddrPresen ]; $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders()); - $this->assertEquals('example.com', $accumulator->host); + $this->assertSame('example.com', $accumulator->host); } public function testMarshalHostAndPortReturnsServerAddrForHostIfPresentAndHostIsIpv6Address() @@ -262,8 +262,8 @@ public function testMarshalHostAndPortReturnsServerAddrForHostIfPresentAndHostIs ]; $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders()); - $this->assertEquals('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host); - $this->assertEquals(8000, $accumulator->port); + $this->assertSame('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host); + $this->assertSame(8000, $accumulator->port); } public function testMarshalHostAndPortWillDetectPortInIpv6StyleHost() @@ -277,8 +277,8 @@ public function testMarshalHostAndPortWillDetectPortInIpv6StyleHost() ]; $accumulator = (object) ['host' => '', 'port' => null]; ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders()); - $this->assertEquals('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host); - $this->assertEquals(80, $accumulator->port); + $this->assertSame('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host); + $this->assertSame(80, $accumulator->port); } public function testMarshalUriDetectsHttpsSchemeFromServerValue() @@ -294,7 +294,7 @@ public function testMarshalUriDetectsHttpsSchemeFromServerValue() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('https', $uri->getScheme()); + $this->assertSame('https', $uri->getScheme()); } public function testMarshalUriUsesHttpSchemeIfHttpsServerValueEqualsOff() @@ -310,7 +310,7 @@ public function testMarshalUriUsesHttpSchemeIfHttpsServerValueEqualsOff() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('http', $uri->getScheme()); + $this->assertSame('http', $uri->getScheme()); } public function testMarshalUriDetectsHttpsSchemeFromXForwardedProtoValue() @@ -325,7 +325,7 @@ public function testMarshalUriDetectsHttpsSchemeFromXForwardedProtoValue() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('https', $uri->getScheme()); + $this->assertSame('https', $uri->getScheme()); } public function testMarshalUriStripsQueryStringFromRequestUri() @@ -341,7 +341,7 @@ public function testMarshalUriStripsQueryStringFromRequestUri() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('/foo/bar', $uri->getPath()); + $this->assertSame('/foo/bar', $uri->getPath()); } public function testMarshalUriInjectsQueryStringFromServer() @@ -358,7 +358,7 @@ public function testMarshalUriInjectsQueryStringFromServer() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('bar=baz', $uri->getQuery()); + $this->assertSame('bar=baz', $uri->getQuery()); } public function testMarshalUriInjectsFragmentFromServer() @@ -374,7 +374,7 @@ public function testMarshalUriInjectsFragmentFromServer() $uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders()); $this->assertInstanceOf(Uri::class, $uri); - $this->assertEquals('foo', $uri->getFragment()); + $this->assertSame('foo', $uri->getFragment()); } public function testCanCreateServerRequestViaFromGlobalsMethod() @@ -408,12 +408,12 @@ public function testCanCreateServerRequestViaFromGlobalsMethod() $request = ServerRequestFactory::fromGlobals($server, $query, $body, $cookies, $files); $this->assertInstanceOf(ServerRequest::class, $request); - $this->assertEquals($cookies, $request->getCookieParams()); - $this->assertEquals($query, $request->getQueryParams()); - $this->assertEquals($body, $request->getParsedBody()); + $this->assertSame($cookies, $request->getCookieParams()); + $this->assertSame($query, $request->getQueryParams()); + $this->assertSame($body, $request->getParsedBody()); $this->assertEquals($expectedFiles, $request->getUploadedFiles()); $this->assertEmpty($request->getAttributes()); - $this->assertEquals('1.1', $request->getProtocolVersion()); + $this->assertSame('1.1', $request->getProtocolVersion()); } public function testFromGlobalsUsesCookieHeaderInsteadOfCookieSuperGlobal() @@ -495,7 +495,7 @@ public function testNormalizeServerUsesMixedCaseAuthorizationHeaderFromApacheWhe $server = ServerRequestFactory::normalizeServer([]); $this->assertArrayHasKey('HTTP_AUTHORIZATION', $server); - $this->assertEquals('foobar', $server['HTTP_AUTHORIZATION']); + $this->assertSame('foobar', $server['HTTP_AUTHORIZATION']); } public function testNormalizeServerUsesLowerCaseAuthorizationHeaderFromApacheWhenPresent() @@ -509,7 +509,7 @@ public function testNormalizeServerUsesLowerCaseAuthorizationHeaderFromApacheWhe $server = ServerRequestFactory::normalizeServer([]); $this->assertArrayHasKey('HTTP_AUTHORIZATION', $server); - $this->assertEquals('foobar', $server['HTTP_AUTHORIZATION']); + $this->assertSame('foobar', $server['HTTP_AUTHORIZATION']); } public function testNormalizeServerReturnsArrayUnalteredIfApacheHeadersDoNotContainAuthorization() @@ -523,7 +523,7 @@ public function testNormalizeServerReturnsArrayUnalteredIfApacheHeadersDoNotCont $expected = ['FOO_BAR' => 'BAZ']; $server = ServerRequestFactory::normalizeServer($expected); - $this->assertEquals($expected, $server); + $this->assertSame($expected, $server); } /** @@ -560,7 +560,7 @@ public function testMarshalProtocolReturnsDefaultValueIfHeaderIsNotPresent() $method = new ReflectionMethod(ServerRequestFactory::class, 'marshalProtocolVersion'); $method->setAccessible(true); $version = $method->invoke(null, []); - $this->assertEquals('1.1', $version); + $this->assertSame('1.1', $version); } /** @@ -571,7 +571,7 @@ public function testMarshalProtocolVersionReturnsHttpVersions($protocol, $expect $method = new ReflectionMethod(ServerRequestFactory::class, 'marshalProtocolVersion'); $method->setAccessible(true); $version = $method->invoke(null, ['SERVER_PROTOCOL' => $protocol]); - $this->assertEquals($expected, $version); + $this->assertSame($expected, $version); } public function marshalProtocolVersionProvider() diff --git a/test/ServerRequestTest.php b/test/ServerRequestTest.php index 6778dfd8..86662d71 100644 --- a/test/ServerRequestTest.php +++ b/test/ServerRequestTest.php @@ -43,7 +43,7 @@ public function testQueryParamsMutatorReturnsCloneWithChanges() $value = ['foo' => 'bar']; $request = $this->request->withQueryParams($value); $this->assertNotSame($this->request, $request); - $this->assertEquals($value, $request->getQueryParams()); + $this->assertSame($value, $request->getQueryParams()); } public function testCookiesAreEmptyByDefault() @@ -56,7 +56,7 @@ public function testCookiesMutatorReturnsCloneWithChanges() $value = ['foo' => 'bar']; $request = $this->request->withCookieParams($value); $this->assertNotSame($this->request, $request); - $this->assertEquals($value, $request->getCookieParams()); + $this->assertSame($value, $request->getCookieParams()); } public function testUploadedFilesAreEmptyByDefault() @@ -74,7 +74,7 @@ public function testParsedBodyMutatorReturnsCloneWithChanges() $value = ['foo' => 'bar']; $request = $this->request->withParsedBody($value); $this->assertNotSame($this->request, $request); - $this->assertEquals($value, $request->getParsedBody()); + $this->assertSame($value, $request->getParsedBody()); } public function testAttributesAreEmptyByDefault() @@ -93,7 +93,7 @@ public function testAttributeMutatorReturnsCloneWithChanges() { $request = $this->request->withAttribute('foo', 'bar'); $this->assertNotSame($this->request, $request); - $this->assertEquals('bar', $request->getAttribute('foo')); + $this->assertSame('bar', $request->getAttribute('foo')); return $request; } @@ -173,7 +173,7 @@ public function testUsesProvidedConstructorArguments($parameterMethod, $methodRe $r = new ReflectionProperty($body, 'stream'); $r->setAccessible(true); $stream = $r->getValue($body); - $this->assertEquals('php://memory', $stream); + $this->assertSame('php://memory', $stream); } /** diff --git a/test/ServerTest.php b/test/ServerTest.php index 0fab8bf8..e26d1f8e 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -127,8 +127,8 @@ public function testCreateServerWillCreateDefaultInstancesForRequestAndResponse( $this->assertInstanceOf(ServerRequest::class, $server->request); $request = $server->request; - $this->assertEquals('POST', $request->getMethod()); - $this->assertEquals('/foo/bar', $request->getUri()->getPath()); + $this->assertSame('POST', $request->getMethod()); + $this->assertSame('/foo/bar', $request->getUri()->getPath()); $this->assertTrue($request->hasHeader('Accept')); $this->assertInstanceOf(Response::class, $server->response); diff --git a/test/StreamTest.php b/test/StreamTest.php index 53ec7581..a107f228 100644 --- a/test/StreamTest.php +++ b/test/StreamTest.php @@ -66,7 +66,7 @@ public function testToStringRetrievesFullContentsOfStream() { $message = 'foo bar'; $this->stream->write($message); - $this->assertEquals($message, (string) $this->stream); + $this->assertSame($message, (string) $this->stream); } public function testDetachReturnsResource() @@ -89,7 +89,7 @@ public function testStringSerializationReturnsEmptyStringWhenStreamIsNotReadable file_put_contents($this->tmpnam, 'FOO BAR'); $stream = new Stream($this->tmpnam, 'w'); - $this->assertEquals('', $stream->__toString()); + $this->assertSame('', $stream->__toString()); } public function testCloseClosesResource() @@ -141,7 +141,7 @@ public function testTellReportsCurrentPositionInResource() fseek($resource, 2); - $this->assertEquals(2, $stream->tell()); + $this->assertSame(2, $stream->tell()); } public function testTellRaisesExceptionIfResourceIsDetached() @@ -222,7 +222,7 @@ public function testSeekAdvancesToGivenOffsetOfStream() $resource = fopen($this->tmpnam, 'wb+'); $stream = new Stream($resource); $this->assertTrue($stream->seek(2)); - $this->assertEquals(2, $stream->tell()); + $this->assertSame(2, $stream->tell()); } public function testRewindResetsToStartOfStream() @@ -233,7 +233,7 @@ public function testRewindResetsToStartOfStream() $stream = new Stream($resource); $this->assertTrue($stream->seek(2)); $stream->rewind(); - $this->assertEquals(0, $stream->tell()); + $this->assertSame(0, $stream->tell()); } public function testSeekRaisesExceptionWhenStreamIsDetached() @@ -318,7 +318,7 @@ public function testIsWritableReturnsCorrectFlagForMode($mode, $fileShouldExist, } $resource = fopen($this->tmpnam, $mode); $stream = new Stream($resource); - $this->assertEquals($flag, $stream->isWritable()); + $this->assertSame($flag, $stream->isWritable()); } public function provideDataForIsReadable() @@ -362,7 +362,7 @@ public function testIsReadableReturnsCorrectFlagForMode($mode, $fileShouldExist, } $resource = fopen($this->tmpnam, $mode); $stream = new Stream($resource); - $this->assertEquals($flag, $stream->isReadable()); + $this->assertSame($flag, $stream->isReadable()); } public function testWriteRaisesExceptionWhenStreamIsDetached() @@ -423,7 +423,7 @@ public function testReadReturnsEmptyStringWhenAtEndOfFile() while (! feof($resource)) { fread($resource, 4096); } - $this->assertEquals('', $stream->read(4096)); + $this->assertSame('', $stream->read(4096)); } public function testGetContentsRisesExceptionIfStreamIsNotReadable() @@ -486,7 +486,7 @@ public function testAttachWithStringRepresentingResourceCreatesAndAttachesResour $this->stream->rewind(); $test = (string) $this->stream; - $this->assertEquals('FooBar', $test); + $this->assertSame('FooBar', $test); } public function testGetContentsShouldGetFullStreamContents() @@ -500,7 +500,7 @@ public function testGetContentsShouldGetFullStreamContents() // rewind, because current pointer is at end of stream! $this->stream->rewind(); $test = $this->stream->getContents(); - $this->assertEquals('FooBar', $test); + $this->assertSame('FooBar', $test); } public function testGetContentsShouldReturnStreamContentsFromCurrentPointer() @@ -514,7 +514,7 @@ public function testGetContentsShouldReturnStreamContentsFromCurrentPointer() // seek to position 3 $this->stream->seek(3); $test = $this->stream->getContents(); - $this->assertEquals('Bar', $test); + $this->assertSame('Bar', $test); } public function testGetMetadataReturnsAllMetadataWhenNoKeyPresent() @@ -526,7 +526,7 @@ public function testGetMetadataReturnsAllMetadataWhenNoKeyPresent() $expected = stream_get_meta_data($resource); $test = $this->stream->getMetadata(); - $this->assertEquals($expected, $test); + $this->assertSame($expected, $test); } public function testGetMetadataReturnsDataForSpecifiedKey() @@ -540,7 +540,7 @@ public function testGetMetadataReturnsDataForSpecifiedKey() $test = $this->stream->getMetadata('uri'); - $this->assertEquals($expected, $test); + $this->assertSame($expected, $test); } public function testGetMetadataReturnsNullIfNoDataExistsForKey() @@ -560,7 +560,7 @@ public function testGetSizeReturnsStreamSize() $resource = fopen(__FILE__, 'r'); $expected = fstat($resource); $stream = new Stream($resource); - $this->assertEquals($expected['size'], $stream->getSize()); + $this->assertSame($expected['size'], $stream->getSize()); } /** @@ -632,6 +632,6 @@ public function testCanReadContentFromNotSeekableResource() $stream->expects($this->any())->method('isSeekable') ->will($this->returnValue(false)); - $this->assertEquals('FOO BAR', $stream->__toString()); + $this->assertSame('FOO BAR', $stream->__toString()); } } diff --git a/test/UploadedFileTest.php b/test/UploadedFileTest.php index 9061cf51..6e5439e3 100644 --- a/test/UploadedFileTest.php +++ b/test/UploadedFileTest.php @@ -203,7 +203,7 @@ public function testMovesFileToDesignatedPath() $upload->moveTo($to); $this->assertTrue(file_exists($to)); $contents = file_get_contents($to); - $this->assertEquals($stream->__toString(), $contents); + $this->assertSame($stream->__toString(), $contents); } public function invalidMovePaths() @@ -333,7 +333,7 @@ public function testMoveToCreatesStreamIfOnlyAFilenameWasProvided() $original = file_get_contents(__FILE__); $test = file_get_contents($this->tmpFile); - $this->assertEquals($original, $test); + $this->assertSame($original, $test); } public function errorConstantsAndMessages() diff --git a/test/UriTest.php b/test/UriTest.php index 3b11323e..d63f0fdc 100644 --- a/test/UriTest.php +++ b/test/UriTest.php @@ -18,21 +18,21 @@ class UriTest extends TestCase public function testConstructorSetsAllProperties() { $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); - $this->assertEquals('https', $uri->getScheme()); - $this->assertEquals('user:pass', $uri->getUserInfo()); - $this->assertEquals('local.example.com', $uri->getHost()); - $this->assertEquals(3001, $uri->getPort()); - $this->assertEquals('user:pass@local.example.com:3001', $uri->getAuthority()); - $this->assertEquals('/foo', $uri->getPath()); - $this->assertEquals('bar=baz', $uri->getQuery()); - $this->assertEquals('quz', $uri->getFragment()); + $this->assertSame('https', $uri->getScheme()); + $this->assertSame('user:pass', $uri->getUserInfo()); + $this->assertSame('local.example.com', $uri->getHost()); + $this->assertSame(3001, $uri->getPort()); + $this->assertSame('user:pass@local.example.com:3001', $uri->getAuthority()); + $this->assertSame('/foo', $uri->getPath()); + $this->assertSame('bar=baz', $uri->getQuery()); + $this->assertSame('quz', $uri->getFragment()); } public function testCanSerializeToString() { $url = 'https://user:pass@local.example.com:3001/foo?bar=baz#quz'; $uri = new Uri($url); - $this->assertEquals($url, (string) $uri); + $this->assertSame($url, (string) $uri); } public function testWithSchemeReturnsNewInstanceWithNewScheme() @@ -40,8 +40,8 @@ public function testWithSchemeReturnsNewInstanceWithNewScheme() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withScheme('http'); $this->assertNotSame($uri, $new); - $this->assertEquals('http', $new->getScheme()); - $this->assertEquals('http://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('http', $new->getScheme()); + $this->assertSame('http://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function testWithSchemeReturnsSameInstanceWithSameScheme() @@ -49,8 +49,8 @@ public function testWithSchemeReturnsSameInstanceWithSameScheme() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withScheme('https'); $this->assertSame($uri, $new); - $this->assertEquals('https', $new->getScheme()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('https', $new->getScheme()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function testWithUserInfoReturnsNewInstanceWithProvidedUser() @@ -58,8 +58,8 @@ public function testWithUserInfoReturnsNewInstanceWithProvidedUser() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withUserInfo('matthew'); $this->assertNotSame($uri, $new); - $this->assertEquals('matthew', $new->getUserInfo()); - $this->assertEquals('https://matthew@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('matthew', $new->getUserInfo()); + $this->assertSame('https://matthew@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function testWithUserInfoReturnsNewInstanceWithProvidedUserAndPassword() @@ -67,8 +67,8 @@ public function testWithUserInfoReturnsNewInstanceWithProvidedUserAndPassword() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withUserInfo('matthew', 'zf2'); $this->assertNotSame($uri, $new); - $this->assertEquals('matthew:zf2', $new->getUserInfo()); - $this->assertEquals('https://matthew:zf2@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('matthew:zf2', $new->getUserInfo()); + $this->assertSame('https://matthew:zf2@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function testWithUserInfoThrowExceptionIfPasswordIsNotString() @@ -85,8 +85,8 @@ public function testWithUserInfoReturnsSameInstanceIfUserAndPasswordAreSameAsBef $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withUserInfo('user', 'pass'); $this->assertSame($uri, $new); - $this->assertEquals('user:pass', $new->getUserInfo()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('user:pass', $new->getUserInfo()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function userInfoProvider() @@ -119,8 +119,8 @@ public function testWithHostReturnsNewInstanceWithProvidedHost() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withHost('framework.zend.com'); $this->assertNotSame($uri, $new); - $this->assertEquals('framework.zend.com', $new->getHost()); - $this->assertEquals('https://user:pass@framework.zend.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('framework.zend.com', $new->getHost()); + $this->assertSame('https://user:pass@framework.zend.com:3001/foo?bar=baz#quz', (string) $new); } public function testWithHostReturnsSameInstanceWithProvidedHostIsSameAsBefore() @@ -128,8 +128,8 @@ public function testWithHostReturnsSameInstanceWithProvidedHostIsSameAsBefore() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withHost('local.example.com'); $this->assertSame($uri, $new); - $this->assertEquals('local.example.com', $new->getHost()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('local.example.com', $new->getHost()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function validPorts() @@ -150,7 +150,7 @@ public function testWithPortReturnsNewInstanceWithProvidedPort($port) $new = $uri->withPort($port); $this->assertNotSame($uri, $new); $this->assertEquals($port, $new->getPort()); - $this->assertEquals( + $this->assertSame( sprintf('https://user:pass@local.example.com%s/foo?bar=baz#quz', $port === null ? '' : ':' . $port), (string) $new ); @@ -196,8 +196,8 @@ public function testWithPathReturnsNewInstanceWithProvidedPath() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withPath('/bar/baz'); $this->assertNotSame($uri, $new); - $this->assertEquals('/bar/baz', $new->getPath()); - $this->assertEquals('https://user:pass@local.example.com:3001/bar/baz?bar=baz#quz', (string) $new); + $this->assertSame('/bar/baz', $new->getPath()); + $this->assertSame('https://user:pass@local.example.com:3001/bar/baz?bar=baz#quz', (string) $new); } public function testWithPathReturnsSameInstanceWithProvidedPathSameAsBefore() @@ -205,8 +205,8 @@ public function testWithPathReturnsSameInstanceWithProvidedPathSameAsBefore() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withPath('/foo'); $this->assertSame($uri, $new); - $this->assertEquals('/foo', $new->getPath()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('/foo', $new->getPath()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function invalidPaths() @@ -240,8 +240,8 @@ public function testWithQueryReturnsNewInstanceWithProvidedQuery() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withQuery('baz=bat'); $this->assertNotSame($uri, $new); - $this->assertEquals('baz=bat', $new->getQuery()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?baz=bat#quz', (string) $new); + $this->assertSame('baz=bat', $new->getQuery()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?baz=bat#quz', (string) $new); } public function invalidQueryStrings() @@ -274,8 +274,8 @@ public function testWithFragmentReturnsNewInstanceWithProvidedFragment() $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withFragment('qat'); $this->assertNotSame($uri, $new); - $this->assertEquals('qat', $new->getFragment()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#qat', (string) $new); + $this->assertSame('qat', $new->getFragment()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#qat', (string) $new); } public function testWithFragmentReturnsSameInstanceWithProvidedFragmentSameAsBefore() @@ -283,8 +283,8 @@ public function testWithFragmentReturnsSameInstanceWithProvidedFragmentSameAsBef $uri = new Uri('https://user:pass@local.example.com:3001/foo?bar=baz#quz'); $new = $uri->withFragment('quz'); $this->assertSame($uri, $new); - $this->assertEquals('quz', $new->getFragment()); - $this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); + $this->assertSame('quz', $new->getFragment()); + $this->assertSame('https://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new); } public function authorityInfo() @@ -303,39 +303,39 @@ public function authorityInfo() public function testRetrievingAuthorityReturnsExpectedValues($url, $expected) { $uri = new Uri($url); - $this->assertEquals($expected, $uri->getAuthority()); + $this->assertSame($expected, $uri->getAuthority()); } public function testCanEmitOriginFormUrl() { $url = '/foo/bar?baz=bat'; $uri = new Uri($url); - $this->assertEquals($url, (string) $uri); + $this->assertSame($url, (string) $uri); } public function testSettingEmptyPathOnAbsoluteUriReturnsAnEmptyPath() { $uri = new Uri('http://example.com/foo'); $new = $uri->withPath(''); - $this->assertEquals('', $new->getPath()); + $this->assertSame('', $new->getPath()); } public function testStringRepresentationOfAbsoluteUriWithNoPathSetsAnEmptyPath() { $uri = new Uri('http://example.com'); - $this->assertEquals('http://example.com', (string) $uri); + $this->assertSame('http://example.com', (string) $uri); } public function testEmptyPathOnOriginFormRemainsAnEmptyPath() { $uri = new Uri('?foo=bar'); - $this->assertEquals('', $uri->getPath()); + $this->assertSame('', $uri->getPath()); } public function testStringRepresentationOfOriginFormWithNoPathRetainsEmptyPath() { $uri = new Uri('?foo=bar'); - $this->assertEquals('?foo=bar', (string) $uri); + $this->assertSame('?foo=bar', (string) $uri); } public function invalidConstructorUris() @@ -372,14 +372,14 @@ public function testMutatingSchemeStripsOffDelimiter() { $uri = new Uri('http://example.com'); $new = $uri->withScheme('https://'); - $this->assertEquals('https', $new->getScheme()); + $this->assertSame('https', $new->getScheme()); } public function testESchemeStripsOffDelimiter() { $uri = new Uri('https://example.com'); $new = $uri->withScheme('://'); - $this->assertEquals('', $new->getScheme()); + $this->assertSame('', $new->getScheme()); } public function invalidSchemes() @@ -421,28 +421,28 @@ public function testPathIsNotPrefixedWithSlashIfSetWithoutOne() { $uri = new Uri('http://example.com'); $new = $uri->withPath('foo/bar'); - $this->assertEquals('foo/bar', $new->getPath()); + $this->assertSame('foo/bar', $new->getPath()); } public function testPathNotSlashPrefixedIsEmittedWithSlashDelimiterWhenUriIsCastToString() { $uri = new Uri('http://example.com'); $new = $uri->withPath('foo/bar'); - $this->assertEquals('http://example.com/foo/bar', $new->__toString()); + $this->assertSame('http://example.com/foo/bar', $new->__toString()); } public function testStripsQueryPrefixIfPresent() { $uri = new Uri('http://example.com'); $new = $uri->withQuery('?foo=bar'); - $this->assertEquals('foo=bar', $new->getQuery()); + $this->assertSame('foo=bar', $new->getQuery()); } public function testEncodeFragmentPrefixIfPresent() { $uri = new Uri('http://example.com'); $new = $uri->withFragment('#/foo/bar'); - $this->assertEquals('%23/foo/bar', $new->getFragment()); + $this->assertSame('%23/foo/bar', $new->getFragment()); } public function standardSchemePortCombinations() @@ -462,7 +462,7 @@ public function testAuthorityOmitsPortForStandardSchemePortCombinations($scheme, ->withHost('example.com') ->withScheme($scheme) ->withPort($port); - $this->assertEquals('example.com', $uri->getAuthority()); + $this->assertSame('example.com', $uri->getAuthority()); } public function mutations() @@ -486,10 +486,10 @@ public function testMutationResetsUriStringPropertyInClone($method, $value) { $uri = new Uri('http://example.com/path?query=string#fragment'); $string = (string) $uri; - $this->assertAttributeEquals($string, 'uriString', $uri); + $this->assertAttributeSame($string, 'uriString', $uri); $test = $uri->{$method}($value); $this->assertAttributeInternalType('null', 'uriString', $test); - $this->assertAttributeEquals($string, 'uriString', $uri); + $this->assertAttributeSame($string, 'uriString', $uri); } /** @@ -499,14 +499,14 @@ public function testPathIsProperlyEncoded() { $uri = (new Uri())->withPath('/foo^bar'); $expected = '/foo%5Ebar'; - $this->assertEquals($expected, $uri->getPath()); + $this->assertSame($expected, $uri->getPath()); } public function testPathDoesNotBecomeDoubleEncoded() { $uri = (new Uri())->withPath('/foo%5Ebar'); $expected = '/foo%5Ebar'; - $this->assertEquals($expected, $uri->getPath()); + $this->assertSame($expected, $uri->getPath()); } public function queryStringsForEncoding() @@ -527,7 +527,7 @@ public function queryStringsForEncoding() public function testQueryIsProperlyEncoded($query, $expected) { $uri = (new Uri())->withQuery($query); - $this->assertEquals($expected, $uri->getQuery()); + $this->assertSame($expected, $uri->getQuery()); } /** @@ -537,7 +537,7 @@ public function testQueryIsProperlyEncoded($query, $expected) public function testQueryIsNotDoubleEncoded($query, $expected) { $uri = (new Uri())->withQuery($expected); - $this->assertEquals($expected, $uri->getQuery()); + $this->assertSame($expected, $uri->getQuery()); } /** @@ -547,7 +547,7 @@ public function testFragmentIsProperlyEncoded() { $uri = (new Uri())->withFragment('/p^th?key^=`bar#b@z'); $expected = '/p%5Eth?key%5E=%60bar%23b@z'; - $this->assertEquals($expected, $uri->getFragment()); + $this->assertSame($expected, $uri->getFragment()); } /** @@ -557,14 +557,14 @@ public function testFragmentIsNotDoubleEncoded() { $expected = '/p%5Eth?key%5E=%60bar%23b@z'; $uri = (new Uri())->withFragment($expected); - $this->assertEquals($expected, $uri->getFragment()); + $this->assertSame($expected, $uri->getFragment()); } public function testProperlyTrimsLeadingSlashesToPreventXSS() { $url = 'http://example.org//zend.com'; $uri = new Uri($url); - $this->assertEquals('http://example.org/zend.com', (string) $uri); + $this->assertSame('http://example.org/zend.com', (string) $uri); } public function invalidStringComponentValues() @@ -618,7 +618,7 @@ public function testUtf8Uri() { $uri = new Uri('http://ουτοπία.δπθ.gr/'); - $this->assertEquals('ουτοπία.δπθ.gr', $uri->getHost()); + $this->assertSame('ουτοπία.δπθ.gr', $uri->getHost()); } /** @@ -628,7 +628,7 @@ public function testUtf8Path($url, $result) { $uri = new Uri($url); - $this->assertEquals($result, $uri->getPath()); + $this->assertSame($result, $uri->getPath()); } @@ -647,7 +647,7 @@ public function testUtf8Query($url, $result) { $uri = new Uri($url); - $this->assertEquals($result, $uri->getQuery()); + $this->assertSame($result, $uri->getQuery()); } public function utf8QueryStringsDataProvider() @@ -661,13 +661,13 @@ public function utf8QueryStringsDataProvider() public function testUriDoesNotAppendColonToHostIfPortIsEmpty() { $uri = (new Uri())->withHost('google.com'); - $this->assertEquals('//google.com', (string) $uri); + $this->assertSame('//google.com', (string) $uri); } public function testAuthorityIsPrefixedByDoubleSlashIfPresent() { $uri = (new Uri())->withHost('example.com'); - $this->assertEquals('//example.com', (string) $uri); + $this->assertSame('//example.com', (string) $uri); } public function testReservedCharsInPathUnencoded()