diff --git a/composer.lock b/composer.lock index d02255f..7257181 100644 --- a/composer.lock +++ b/composer.lock @@ -5257,4 +5257,4 @@ "ext-xdebug": "*" }, "plugin-api-version": "2.6.0" -} +} \ No newline at end of file diff --git a/tests/HookTest.php b/tests/HookTest.php index e393c3e..913b1b8 100644 --- a/tests/HookTest.php +++ b/tests/HookTest.php @@ -22,32 +22,32 @@ public function setUp(): void public function testDescriptionCanBeSet() { - $this->assertEquals('', $this->hook->getDesc()); + $this->assertSame('', $this->hook->getDesc()); $this->hook->desc('new hook'); - $this->assertEquals('new hook', $this->hook->getDesc()); + $this->assertSame('new hook', $this->hook->getDesc()); } public function testGroupsCanBeSet() { - $this->assertEquals([], $this->hook->getGroups()); + $this->assertSame([], $this->hook->getGroups()); $this->hook->groups(['api', 'homepage']); - $this->assertEquals(['api', 'homepage'], $this->hook->getGroups()); + $this->assertSame(['api', 'homepage'], $this->hook->getGroups()); } public function testActionCanBeSet() { $this->hook->action(fn () => 'hello world'); $this->assertIsCallable($this->hook->getAction()); - $this->assertEquals('hello world', $this->hook->getAction()()); + $this->assertSame('hello world', $this->hook->getAction()()); } public function testParamCanBeSet() { - $this->assertEquals([], $this->hook->getParams()); + $this->assertSame([], $this->hook->getParams()); $this->hook ->param('x', '', new Text(10)) @@ -89,12 +89,12 @@ public function testResourcesCanBeInjected() $result = $context->inject($main); - $this->assertEquals('user:00:00:00', $result); + $this->assertSame('user:00:00:00', $result); } public function testParamValuesCanBeSet() { - $this->assertEquals([], $this->hook->getParams()); + $this->assertSame([], $this->hook->getParams()); $values = [ 'x' => 'hello', @@ -105,13 +105,18 @@ public function testParamValuesCanBeSet() ->param('x', '', new Numeric()) ->param('y', '', new Numeric()); - foreach ($this->hook->getParams() as $key => $param) { + /** + * @var array $params + */ + $params = $this->hook->getParams(); + + foreach ($params as $key => $param) { $this->hook->setParamValue($key, $values[$key]); } $this->assertCount(2, $this->hook->getParams()); - $this->assertEquals('hello', $this->hook->getParams()['x']['value']); - $this->assertEquals('world', $this->hook->getParams()['y']['value']); + $this->assertSame('hello', $this->hook->getParams()['x']['value']); + $this->assertSame('world', $this->hook->getParams()['y']['value']); } public function tearDown(): void diff --git a/tests/HttpTest.php b/tests/HttpTest.php index 63324cd..fb6e4e0 100755 --- a/tests/HttpTest.php +++ b/tests/HttpTest.php @@ -77,21 +77,21 @@ public function testCanGetDifferentModes(): void Http::setMode(Http::MODE_TYPE_PRODUCTION); - $this->assertEquals(Http::MODE_TYPE_PRODUCTION, Http::getMode()); + $this->assertSame(Http::MODE_TYPE_PRODUCTION, Http::getMode()); $this->assertTrue(Http::isProduction()); $this->assertFalse(Http::isDevelopment()); $this->assertFalse(Http::isStage()); Http::setMode(Http::MODE_TYPE_DEVELOPMENT); - $this->assertEquals(Http::MODE_TYPE_DEVELOPMENT, Http::getMode()); + $this->assertSame(Http::MODE_TYPE_DEVELOPMENT, Http::getMode()); $this->assertFalse(Http::isProduction()); $this->assertTrue(Http::isDevelopment()); $this->assertFalse(Http::isStage()); Http::setMode(Http::MODE_TYPE_STAGE); - $this->assertEquals(Http::MODE_TYPE_STAGE, Http::getMode()); + $this->assertSame(Http::MODE_TYPE_STAGE, Http::getMode()); $this->assertFalse(Http::isProduction()); $this->assertFalse(Http::isDevelopment()); $this->assertTrue(Http::isStage()); @@ -136,7 +136,7 @@ public function testCanExecuteRoute(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('x-def-y-def', $result); + $this->assertSame('x-def-y-def', $result); } public function testCanExecuteRouteWithParams(): void @@ -191,7 +191,7 @@ public function testCanExecuteRouteWithParams(): void $result = \ob_get_contents(); \ob_end_clean(); $resource = $context->get('rand'); - $this->assertEquals($resource . '-param-x-param-y', $result); + $this->assertSame($resource . '-param-x-param-y', $result); } public function testCanExecuteRouteWithParamsWithError(): void @@ -240,7 +240,7 @@ public function testCanExecuteRouteWithParamsWithError(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('error: Invalid `x` param: Value must be a valid string and no longer than 1 chars', $result); + $this->assertSame('error: Invalid `x` param: Value must be a valid string and no longer than 1 chars', $result); } public function testCanExecuteRouteWithParamsWithHooks(): void @@ -345,7 +345,7 @@ public function testCanExecuteRouteWithParamsWithHooks(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('init-' . $resource . '-(init-api)-param-x-param-y-(shutdown-api)-shutdown', $result); + $this->assertSame('init-' . $resource . '-(init-api)-param-x-param-y-(shutdown-api)-shutdown', $result); $context = clone $this->context; @@ -376,7 +376,7 @@ public function testCanExecuteRouteWithParamsWithHooks(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('init-' . $resource . '-(init-homepage)-param-x*param-y-(shutdown-homepage)-shutdown', $result); + $this->assertSame('init-' . $resource . '-(init-homepage)-param-x*param-y-(shutdown-homepage)-shutdown', $result); } public function testCanAddAndExecuteHooks() @@ -420,7 +420,7 @@ public function testCanAddAndExecuteHooks() $this->http->run($context); $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('(init)-x-def-(shutdown)', $result); + $this->assertSame('(init)-x-def-(shutdown)', $result); // Default Params $route = $this->http->addRoute('GET', '/path-4'); @@ -450,7 +450,7 @@ public function testCanAddAndExecuteHooks() $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('x-def', $result); + $this->assertSame('x-def', $result); } public function testAllowRouteOverrides() @@ -468,7 +468,7 @@ public function testAllowRouteOverrides() $this->fail('Failed to throw exception'); } catch (\Exception $e) { // Threw exception as expected - $this->assertEquals('Route for (GET:) already registered.', $e->getMessage()); + $this->assertSame('Route for (GET:) already registered.', $e->getMessage()); } // Test success @@ -533,7 +533,7 @@ public function testCanHookThrowExceptions() $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('error: Param "y" is not optional.', $result); + $this->assertSame('error: Param "y" is not optional.', $result); $context = clone $this->context; @@ -555,7 +555,7 @@ public function testCanHookThrowExceptions() $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('(init)-y-def-x-def-(shutdown)', $result); + $this->assertSame('(init)-y-def-x-def-(shutdown)', $result); } public function providerRouteMatching(): array @@ -606,7 +606,7 @@ public function testCanMatchRoute(string $method, string $path, ?string $url = n $_SERVER['REQUEST_URI'] = $url; $route = $this->http->match(new Request()); - $this->assertEquals($expected, $route); + $this->assertSame($expected, $route); } public function testMatchWithNullPath(): void @@ -619,7 +619,7 @@ public function testMatchWithNullPath(): void $_SERVER['REQUEST_URI'] = '?param=1'; // This will cause parse_url to return null for PATH component $matched = $this->http->match(new Request()); - $this->assertEquals($expected, $matched); + $this->assertSame($expected, $matched); } public function testMatchWithEmptyPath(): void @@ -632,7 +632,7 @@ public function testMatchWithEmptyPath(): void $_SERVER['REQUEST_URI'] = 'https://example.com'; // No path component $matched = $this->http->match(new Request()); - $this->assertEquals($expected, $matched); + $this->assertSame($expected, $matched); } public function testMatchWithMalformedURL(): void @@ -645,7 +645,7 @@ public function testMatchWithMalformedURL(): void $_SERVER['REQUEST_URI'] = '#fragment'; // Malformed scheme $matched = $this->http->match(new Request()); - $this->assertEquals($expected, $matched); + $this->assertSame($expected, $matched); } public function testMatchWithOnlyQueryString(): void @@ -658,7 +658,7 @@ public function testMatchWithOnlyQueryString(): void $_SERVER['REQUEST_URI'] = '?param=value'; // Only query string, no path $matched = $this->http->match(new Request()); - $this->assertEquals($expected, $matched); + $this->assertSame($expected, $matched); } public function testNoMismatchRoute(): void @@ -697,8 +697,8 @@ public function testNoMismatchRoute(): void $this->http->run($context); - $this->assertEquals($_SERVER['REQUEST_METHOD'], $context->get('route')->getMethod()); - $this->assertEquals($_SERVER['REQUEST_URI'], $context->get('route')->getPath()); + $this->assertSame($_SERVER['REQUEST_METHOD'], $context->get('route')->getMethod()); + $this->assertSame($_SERVER['REQUEST_URI'], $context->get('route')->getPath()); } } @@ -778,7 +778,7 @@ public function testWildcardRoute(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('HELLO', $result); + $this->assertSame('HELLO', $result); \ob_start(); $context->get('request')->setMethod('OPTIONS'); @@ -786,7 +786,7 @@ public function testWildcardRoute(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('', $result); + $this->assertSame('', $result); $_SERVER['REQUEST_METHOD'] = $method; $_SERVER['REQUEST_URI'] = $uri; @@ -811,7 +811,7 @@ public function testCallableStringParametersNotExecuted(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('callback-value: phpinfo', $result); + $this->assertSame('callback-value: phpinfo', $result); // Test with request parameter that is a callable string $route2 = new Route('GET', '/test-callable-string-param'); @@ -830,7 +830,7 @@ public function testCallableStringParametersNotExecuted(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('func-value: system', $result); + $this->assertSame('func-value: system', $result); // Test callable closure still works $route3 = new Route('GET', '/test-callable-closure'); @@ -849,6 +849,6 @@ public function testCallableStringParametersNotExecuted(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('generated: generated-value', $result); + $this->assertSame('generated: generated-value', $result); } } diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 6138ae7..1bf74bd 100755 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -24,14 +24,14 @@ public function testCanGetHeaders() $_SERVER['HTTP_CUSTOM'] = 'value1'; $_SERVER['HTTP_CUSTOM_NEW'] = 'value2'; - $this->assertEquals('value1', $this->request->getHeader('custom')); - $this->assertEquals('value2', $this->request->getHeader('custom-new')); + $this->assertSame('value1', $this->request->getHeader('custom')); + $this->assertSame('value2', $this->request->getHeader('custom-new')); $headers = $this->request->getHeaders(); $this->assertIsArray($headers); $this->assertCount(2, $headers); - $this->assertEquals('value1', $headers['custom']); - $this->assertEquals('value2', $headers['custom-new']); + $this->assertSame('value1', $headers['custom']); + $this->assertSame('value2', $headers['custom-new']); } public function testCanAddHeaders() @@ -39,8 +39,8 @@ public function testCanAddHeaders() $this->request->addHeader('custom', 'value1'); $this->request->addHeader('custom-new', 'value2'); - $this->assertEquals('value1', $this->request->getHeader('custom')); - $this->assertEquals('value2', $this->request->getHeader('custom-new')); + $this->assertSame('value1', $this->request->getHeader('custom')); + $this->assertSame('value2', $this->request->getHeader('custom-new')); } public function testCanRemoveHeaders() @@ -48,71 +48,71 @@ public function testCanRemoveHeaders() $this->request->addHeader('custom', 'value1'); $this->request->addHeader('custom-new', 'value2'); - $this->assertEquals('value1', $this->request->getHeader('custom')); - $this->assertEquals('value2', $this->request->getHeader('custom-new')); + $this->assertSame('value1', $this->request->getHeader('custom')); + $this->assertSame('value2', $this->request->getHeader('custom-new')); $this->request->removeHeader('custom'); - $this->assertEquals(null, $this->request->getHeader('custom')); - $this->assertEquals('value2', $this->request->getHeader('custom-new')); + $this->assertSame('', $this->request->getHeader('custom')); + $this->assertSame('value2', $this->request->getHeader('custom-new')); } public function testCanGetQueryParameter() { $_GET['key'] = 'value'; - $this->assertEquals($this->request->getQuery('key'), 'value'); - $this->assertEquals($this->request->getQuery('unknown', 'test'), 'test'); + $this->assertSame($this->request->getQuery('key'), 'value'); + $this->assertSame($this->request->getQuery('unknown', 'test'), 'test'); } public function testCanSetQuery() { $this->request->setQuery(['key' => 'value']); - $this->assertEquals($this->request->getQuery('key'), 'value'); - $this->assertEquals($this->request->getQuery('unknown', 'test'), 'test'); + $this->assertSame($this->request->getQuery('key'), 'value'); + $this->assertSame($this->request->getQuery('unknown', 'test'), 'test'); } public function testCanGetPayload() { - $this->assertEquals($this->request->getPayload('unknown', 'test'), 'test'); + $this->assertSame($this->request->getPayload('unknown', 'test'), 'test'); } public function testCanSetPayload() { $this->request->setPayload(['key' => 'value']); - $this->assertEquals($this->request->getPayload('key'), 'value'); - $this->assertEquals($this->request->getPayload('unknown', 'test'), 'test'); + $this->assertSame($this->request->getPayload('key'), 'value'); + $this->assertSame($this->request->getPayload('unknown', 'test'), 'test'); } public function testCanGetRawPayload() { - $this->assertEquals($this->request->getRawPayload(), ''); + $this->assertSame($this->request->getRawPayload(), ''); } public function testCanGetServer() { $_SERVER['key'] = 'value'; - $this->assertEquals($this->request->getServer('key'), 'value'); - $this->assertEquals($this->request->getServer('unknown', 'test'), 'test'); + $this->assertSame($this->request->getServer('key'), 'value'); + $this->assertSame($this->request->getServer('unknown', 'test'), 'test'); } public function testCanSetServer() { $this->request->setServer('key', 'value'); - $this->assertEquals($this->request->getServer('key'), 'value'); - $this->assertEquals($this->request->getServer('unknown', 'test'), 'test'); + $this->assertSame($this->request->getServer('key'), 'value'); + $this->assertSame($this->request->getServer('unknown', 'test'), 'test'); } public function testCanGetCookie() { $_COOKIE['key'] = 'value'; - $this->assertEquals($this->request->getCookie('key'), 'value'); - $this->assertEquals($this->request->getCookie('unknown', 'test'), 'test'); + $this->assertSame($this->request->getCookie('key'), 'value'); + $this->assertSame($this->request->getCookie('unknown', 'test'), 'test'); } public function testCanGetProtocol() @@ -120,7 +120,7 @@ public function testCanGetProtocol() $_SERVER['HTTP_X_FORWARDED_PROTO'] = null; $_SERVER['REQUEST_SCHEME'] = 'http'; - $this->assertEquals('http', $this->request->getProtocol()); + $this->assertSame('http', $this->request->getProtocol()); } public function testCanGetForwardedProtocol() @@ -128,205 +128,205 @@ public function testCanGetForwardedProtocol() $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; $_SERVER['REQUEST_SCHEME'] = 'http'; - $this->assertEquals('https', $this->request->getProtocol()); + $this->assertSame('https', $this->request->getProtocol()); } public function testCanGetMethod() { - $this->assertEquals('UNKNOWN', $this->request->getMethod()); + $this->assertSame('UNKNOWN', $this->request->getMethod()); $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertEquals('GET', $this->request->getMethod()); + $this->assertSame('GET', $this->request->getMethod()); } public function testCanGetUri() { - $this->assertEquals('', $this->request->getURI()); + $this->assertSame('', $this->request->getURI()); $_SERVER['REQUEST_URI'] = '/index.html'; - $this->assertEquals('/index.html', $this->request->getURI()); + $this->assertSame('/index.html', $this->request->getURI()); } public function testCanSetUri() { $this->request->setURI('/page.html'); - $this->assertEquals('/page.html', $this->request->getURI()); + $this->assertSame('/page.html', $this->request->getURI()); } public function testCanGetQueryString() { - $this->assertEquals('', $this->request->getQueryString()); + $this->assertSame('', $this->request->getQueryString()); $_SERVER['QUERY_STRING'] = 'text=hello&value=key'; - $this->assertEquals('text=hello&value=key', $this->request->getQueryString()); + $this->assertSame('text=hello&value=key', $this->request->getQueryString()); } public function testCanSetQueryString() { $this->request->setURI('text=hello&value=key'); - $this->assertEquals('text=hello&value=key', $this->request->getURI()); + $this->assertSame('text=hello&value=key', $this->request->getURI()); } public function testCanGetPort() { $_SERVER['HTTP_HOST'] = 'localhost:8080'; - $this->assertEquals('8080', $this->request->getPort()); + $this->assertSame('8080', $this->request->getPort()); $_SERVER['HTTP_HOST'] = 'localhost'; - $this->assertEquals('', $this->request->getPort()); + $this->assertSame('', $this->request->getPort()); } public function testCanGetHostname() { $_SERVER['HTTP_HOST'] = 'localhost'; - $this->assertEquals('localhost', $this->request->getHostname()); + $this->assertSame('localhost', $this->request->getHostname()); } public function testCanGetHostnameWithPort() { $_SERVER['HTTP_HOST'] = 'localhost:8080'; - $this->assertEquals('localhost', $this->request->getHostname()); + $this->assertSame('localhost', $this->request->getHostname()); } public function testCanGetReferer() { - $this->assertEquals('default', $this->request->getReferer('default')); + $this->assertSame('default', $this->request->getReferer('default')); $_SERVER['HTTP_REFERER'] = 'referer'; - $this->assertEquals('referer', $this->request->getReferer('default')); + $this->assertSame('referer', $this->request->getReferer('default')); } public function testCanGetOrigin() { - $this->assertEquals('default', $this->request->getOrigin('default')); + $this->assertSame('default', $this->request->getOrigin('default')); $_SERVER['HTTP_ORIGIN'] = 'origin'; - $this->assertEquals('origin', $this->request->getOrigin('default')); + $this->assertSame('origin', $this->request->getOrigin('default')); } public function testCanGetUserAgent() { - $this->assertEquals('default', $this->request->getUserAgent('default')); + $this->assertSame('default', $this->request->getUserAgent('default')); $_SERVER['HTTP_USER_AGENT'] = 'user-agent'; - $this->assertEquals('user-agent', $this->request->getUserAgent('default')); + $this->assertSame('user-agent', $this->request->getUserAgent('default')); } public function testCanGetAccept() { - $this->assertEquals('default', $this->request->getAccept('default')); + $this->assertSame('default', $this->request->getAccept('default')); $_SERVER['HTTP_ACCEPT'] = 'accept'; - $this->assertEquals('accept', $this->request->getAccept('default')); + $this->assertSame('accept', $this->request->getAccept('default')); } public function testCanGetContentRange() { $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0-499/2000'; - $this->assertEquals('bytes', $this->request->getContentRangeUnit()); - $this->assertEquals(0, $this->request->getContentRangeStart()); - $this->assertEquals(499, $this->request->getContentRangeEnd()); - $this->assertEquals(2000, $this->request->getContentRangeSize()); + $this->assertSame('bytes', $this->request->getContentRangeUnit()); + $this->assertSame(0, $this->request->getContentRangeStart()); + $this->assertSame(499, $this->request->getContentRangeEnd()); + $this->assertSame(2000, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = ' 0-499/2000'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0-499/'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0--499/2000'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0-499test/2000'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0-49.9/200.0'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 0-49,9/200,0'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getContentRangeUnit()); - $this->assertEquals(null, $this->request->getContentRangeStart()); - $this->assertEquals(null, $this->request->getContentRangeEnd()); - $this->assertEquals(null, $this->request->getContentRangeSize()); + $this->assertSame(null, $this->request->getContentRangeUnit()); + $this->assertSame(null, $this->request->getContentRangeStart()); + $this->assertSame(null, $this->request->getContentRangeEnd()); + $this->assertSame(null, $this->request->getContentRangeSize()); } public function testCanGetRange() { $_SERVER['HTTP_RANGE'] = 'bytes=0-499'; - $this->assertEquals('bytes', $this->request->getRangeUnit()); - $this->assertEquals(0, $this->request->getRangeStart()); - $this->assertEquals(499, $this->request->getRangeEnd()); + $this->assertSame('bytes', $this->request->getRangeUnit()); + $this->assertSame(0, $this->request->getRangeStart()); + $this->assertSame(499, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = ' 0-499'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getRangeUnit()); - $this->assertEquals(null, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame(null, $this->request->getRangeUnit()); + $this->assertSame(null, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = 'bytes=0-'; $this->request = new Request(); - $this->assertEquals('bytes', $this->request->getRangeUnit()); - $this->assertEquals(0, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame('bytes', $this->request->getRangeUnit()); + $this->assertSame(0, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = 'bytes=0--499'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getRangeUnit()); - $this->assertEquals(null, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame(null, $this->request->getRangeUnit()); + $this->assertSame(null, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = 'bytes=0-499test'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getRangeUnit()); - $this->assertEquals(null, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame(null, $this->request->getRangeUnit()); + $this->assertSame(null, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = 'bytes=0-49.9'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getRangeUnit()); - $this->assertEquals(null, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame(null, $this->request->getRangeUnit()); + $this->assertSame(null, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); $_SERVER['HTTP_RANGE'] = 'bytes=0-49,9'; $this->request = new Request(); - $this->assertEquals(null, $this->request->getRangeUnit()); - $this->assertEquals(null, $this->request->getRangeStart()); - $this->assertEquals(null, $this->request->getRangeEnd()); + $this->assertSame(null, $this->request->getRangeUnit()); + $this->assertSame(null, $this->request->getRangeStart()); + $this->assertSame(null, $this->request->getRangeEnd()); } } diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index e992f45..be92f3f 100755 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -52,19 +52,19 @@ public function testCanGetStatus() // Assertions $this->assertInstanceOf('Utopia\Http\Response', $status); - $this->assertEquals(Response::STATUS_CODE_OK, $this->response->getStatusCode()); + $this->assertSame(Response::STATUS_CODE_OK, $this->response->getStatusCode()); } public function testCanAddHeader() { $result = $this->response->addHeader('key', 'value'); - $this->assertEquals($this->response, $result); + $this->assertSame($this->response, $result); } public function testCanAddCookie() { $result = $this->response->addCookie('name', 'value'); - $this->assertEquals($this->response, $result); + $this->assertSame($this->response, $result); //test cookie case insensitive $result = $this->response->addCookie('cookieName', 'cookieValue'); @@ -84,7 +84,7 @@ public function testCanSend() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('body', $html); + $this->assertSame('body', $html); } public function testCanSendRedirect() @@ -96,7 +96,7 @@ public function testCanSendRedirect() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('', $html); + $this->assertSame('', $html); ob_start(); //Start of build @@ -105,7 +105,7 @@ public function testCanSendRedirect() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('', $html); + $this->assertSame('', $html); } public function testCanSendText() @@ -117,8 +117,8 @@ public function testCanSendText() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('HELLO WORLD', $html); - $this->assertEquals('text/plain; charset=UTF-8', $this->response->getContentType()); + $this->assertSame('HELLO WORLD', $html); + $this->assertSame('text/plain; charset=UTF-8', $this->response->getContentType()); } public function testCanSendHtml() @@ -130,8 +130,8 @@ public function testCanSendHtml() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('', $html); - $this->assertEquals('text/html; charset=UTF-8', $this->response->getContentType()); + $this->assertSame('', $html); + $this->assertSame('text/html; charset=UTF-8', $this->response->getContentType()); } public function testCanSendJson() @@ -143,8 +143,8 @@ public function testCanSendJson() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('{"key":"value"}', $html); - $this->assertEquals('application/json; charset=UTF-8', $this->response->getContentType()); + $this->assertSame('{"key":"value"}', $html); + $this->assertSame('application/json; charset=UTF-8', $this->response->getContentType()); } public function testCanSendJsonp() @@ -156,8 +156,8 @@ public function testCanSendJsonp() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('parent.test({"key":"value"});', $html); - $this->assertEquals('text/javascript; charset=UTF-8', $this->response->getContentType()); + $this->assertSame('parent.test({"key":"value"});', $html); + $this->assertSame('text/javascript; charset=UTF-8', $this->response->getContentType()); } public function testCanSendIframe() @@ -169,7 +169,7 @@ public function testCanSendIframe() $html = ob_get_contents(); ob_end_clean(); //End of build - $this->assertEquals('', $html); - $this->assertEquals('text/html; charset=UTF-8', $this->response->getContentType()); + $this->assertSame('', $html); + $this->assertSame('text/html; charset=UTF-8', $this->response->getContentType()); } } diff --git a/tests/RouteTest.php b/tests/RouteTest.php index d5a0aee..deb5cff 100755 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -16,48 +16,48 @@ public function setUp(): void public function testCanGetMethod() { - $this->assertEquals('GET', $this->route->getMethod()); + $this->assertSame('GET', $this->route->getMethod()); } public function testCanGetAndSetPath() { - $this->assertEquals('/', $this->route->getPath()); + $this->assertSame('/', $this->route->getPath()); $this->route->path('/path'); - $this->assertEquals('/path', $this->route->getPath()); + $this->assertSame('/path', $this->route->getPath()); } public function testCanSetAndGetDescription() { - $this->assertEquals('', $this->route->getDesc()); + $this->assertSame('', $this->route->getDesc()); $this->route->desc('new route'); - $this->assertEquals('new route', $this->route->getDesc()); + $this->assertSame('new route', $this->route->getDesc()); } public function testCanSetAndGetGroups() { - $this->assertEquals([], $this->route->getGroups()); + $this->assertSame([], $this->route->getGroups()); $this->route->groups(['api', 'homepage']); - $this->assertEquals(['api', 'homepage'], $this->route->getGroups()); + $this->assertSame(['api', 'homepage'], $this->route->getGroups()); } public function testCanSetAndGetAction() { - $this->assertEquals(null, $this->route->getAction()); + $this->assertSame(null, $this->route->getAction()); $this->route->action(fn () => 'hello world'); - $this->assertEquals('hello world', $this->route->getAction()()); + $this->assertSame('hello world', $this->route->getAction()()); } public function testCanGetAndSetParam() { - $this->assertEquals([], $this->route->getParams()); + $this->assertSame([], $this->route->getParams()); $this->route ->param('x', '', new Text(10)) @@ -68,11 +68,11 @@ public function testCanGetAndSetParam() public function testCanSetAndGetLabels() { - $this->assertEquals('default', $this->route->getLabel('key', 'default')); + $this->assertSame('default', $this->route->getLabel('key', 'default')); $this->route->label('key', 'value'); - $this->assertEquals('value', $this->route->getLabel('key', 'default')); + $this->assertSame('value', $this->route->getLabel('key', 'default')); } public function testCanSetAndGetHooks() diff --git a/tests/RouterTest.php b/tests/RouterTest.php index a400c59..ec671a5 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -21,9 +21,9 @@ public function testCanMatchUrl(): void Router::addRoute($routeAbout); Router::addRoute($routeAboutMe); - $this->assertEquals($routeIndex, Router::match(Http::REQUEST_METHOD_GET, '/')); - $this->assertEquals($routeAbout, Router::match(Http::REQUEST_METHOD_GET, '/about')); - $this->assertEquals($routeAboutMe, Router::match(Http::REQUEST_METHOD_GET, '/about/me')); + $this->assertSame($routeIndex, Router::match(Http::REQUEST_METHOD_GET, '/')); + $this->assertSame($routeAbout, Router::match(Http::REQUEST_METHOD_GET, '/about')); + $this->assertSame($routeAboutMe, Router::match(Http::REQUEST_METHOD_GET, '/about/me')); } public function testCanMatchUrlWithPlaceholder(): void @@ -42,13 +42,13 @@ public function testCanMatchUrlWithPlaceholder(): void Router::addRoute($routeBlogPostComments); Router::addRoute($routeBlogPostCommentsSingle); - $this->assertEquals($routeBlog, Router::match(Http::REQUEST_METHOD_GET, '/blog')); - $this->assertEquals($routeBlogAuthors, Router::match(Http::REQUEST_METHOD_GET, '/blog/authors')); - $this->assertEquals($routeBlogAuthorsComments, Router::match(Http::REQUEST_METHOD_GET, '/blog/authors/comments')); - $this->assertEquals($routeBlogPost, Router::match(Http::REQUEST_METHOD_GET, '/blog/test')); - $this->assertEquals($routeBlogPostComments, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments')); - $this->assertEquals($routeBlogPostCommentsSingle, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments/0')); - $this->assertEquals($routeBlogPostCommentsSingle, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments/:comment')); + $this->assertSame($routeBlog, Router::match(Http::REQUEST_METHOD_GET, '/blog')); + $this->assertSame($routeBlogAuthors, Router::match(Http::REQUEST_METHOD_GET, '/blog/authors')); + $this->assertSame($routeBlogAuthorsComments, Router::match(Http::REQUEST_METHOD_GET, '/blog/authors/comments')); + $this->assertSame($routeBlogPost, Router::match(Http::REQUEST_METHOD_GET, '/blog/test')); + $this->assertSame($routeBlogPostComments, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments')); + $this->assertSame($routeBlogPostCommentsSingle, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments/0')); + $this->assertSame($routeBlogPostCommentsSingle, Router::match(Http::REQUEST_METHOD_GET, '/blog/test/comments/:comment')); } public function testCanMatchUrlWithWildcard(): void @@ -61,11 +61,11 @@ public function testCanMatchUrlWithWildcard(): void Router::addRoute($routeAbout); Router::addRoute($routeAboutWildcard); - $this->assertEquals($routeIndex, Router::match('GET', '/')); - $this->assertEquals($routeAbout, Router::match('GET', '/about')); - $this->assertEquals($routeAboutWildcard, Router::match('GET', '/about/me')); - $this->assertEquals($routeAboutWildcard, Router::match('GET', '/about/you')); - $this->assertEquals($routeAboutWildcard, Router::match('GET', '/about/me/myself/i')); + $this->assertSame($routeIndex, Router::match('GET', '/')); + $this->assertSame($routeAbout, Router::match('GET', '/about')); + $this->assertSame($routeAboutWildcard, Router::match('GET', '/about/me')); + $this->assertSame($routeAboutWildcard, Router::match('GET', '/about/you')); + $this->assertSame($routeAboutWildcard, Router::match('GET', '/about/me/myself/i')); } public function testCanMatchHttpMethod(): void @@ -76,8 +76,8 @@ public function testCanMatchHttpMethod(): void Router::addRoute($routeGET); Router::addRoute($routePOST); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/')); - $this->assertEquals($routePOST, Router::match(Http::REQUEST_METHOD_POST, '/')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/')); + $this->assertSame($routePOST, Router::match(Http::REQUEST_METHOD_POST, '/')); $this->assertNotEquals($routeGET, Router::match(Http::REQUEST_METHOD_POST, '/')); $this->assertNotEquals($routePOST, Router::match(Http::REQUEST_METHOD_GET, '/')); @@ -92,9 +92,9 @@ public function testCanMatchAlias(): void Router::addRoute($routeGET); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/target')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/alias')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/alias2')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/target')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/alias')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/alias2')); } public function testCanMatchMix(): void @@ -110,14 +110,14 @@ public function testCanMatchMix(): void Router::addRoute($routeGET); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/console')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/invite')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/login')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/recover')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/console/lorem/ipsum/dolor')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/auth/lorem/ipsum')); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/register/lorem/ipsum')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/console')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/invite')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/login')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/recover')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/console/lorem/ipsum/dolor')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/auth/lorem/ipsum')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/register/lorem/ipsum')); } public function testCanMatchFilename(): void @@ -125,7 +125,7 @@ public function testCanMatchFilename(): void $routeGET = new Route(Http::REQUEST_METHOD_GET, '/robots.txt'); Router::addRoute($routeGET); - $this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/robots.txt')); + $this->assertSame($routeGET, Router::match(Http::REQUEST_METHOD_GET, '/robots.txt')); } public function testCannotFindUnknownRouteByPath(): void @@ -139,7 +139,7 @@ public function testCannotFindUnknownRouteByMethod(): void Router::addRoute($route); - $this->assertEquals($route, Router::match(Http::REQUEST_METHOD_GET, '/404')); + $this->assertSame($route, Router::match(Http::REQUEST_METHOD_GET, '/404')); $this->assertNull(Router::match(Http::REQUEST_METHOD_POST, '/404')); } diff --git a/tests/e2e/BaseTest.php b/tests/e2e/BaseTest.php index 03db331..ef57842 100644 --- a/tests/e2e/BaseTest.php +++ b/tests/e2e/BaseTest.php @@ -9,21 +9,21 @@ trait BaseTest public function testResponse() { $response = $this->client->call(Client::METHOD_GET, '/'); - $this->assertEquals('Hello World!', $response['body']); + $this->assertSame('Hello World!', $response['body']); } public function testResponseValue() { $response = $this->client->call(Client::METHOD_GET, '/value/123'); - $this->assertEquals('123', $response['body']); + $this->assertSame('123', $response['body']); } public function testHeaders() { $response = $this->client->call(Client::METHOD_GET, '/headers'); $this->assertGreaterThan(8, count($response['headers'])); - $this->assertEquals('value1', $response['headers']['key1']); - $this->assertEquals('value2', $response['headers']['key2']); + $this->assertSame('value1', $response['headers']['key1']); + $this->assertSame('value2', $response['headers']['key2']); $this->assertNotEmpty($response['body']); } @@ -31,53 +31,53 @@ public function testHead() { $response = $this->client->call(Client::METHOD_HEAD, '/headers'); $this->assertGreaterThan(8, $response['headers']); - $this->assertEquals('value1', $response['headers']['key1']); - $this->assertEquals('value2', $response['headers']['key2']); + $this->assertSame('value1', $response['headers']['key1']); + $this->assertSame('value2', $response['headers']['key2']); $this->assertEmpty(trim($response['body'])); } public function testNoContent() { $response = $this->client->call(Client::METHOD_DELETE, '/no-content'); - $this->assertEquals(204, $response['headers']['status-code']); + $this->assertSame(204, $response['headers']['status-code']); $this->assertEmpty(trim($response['body'])); } public function testChunkResponse() { $response = $this->client->call(Client::METHOD_GET, '/chunked'); - $this->assertEquals('Hello World!', $response['body']); + $this->assertSame('Hello World!', $response['body']); } public function testRedirect() { $response = $this->client->call(Client::METHOD_GET, '/redirect'); - $this->assertEquals('Hello World!', $response['body']); + $this->assertSame('Hello World!', $response['body']); } public function testHumans() { $response = $this->client->call(Client::METHOD_GET, '/humans.txt'); - $this->assertEquals('humans.txt', $response['body']); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('Utopia', $response['headers']['x-engine']); + $this->assertSame('humans.txt', $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('Utopia', $response['headers']['x-engine']); } public function testParamInjection() { $response = $this->client->call(Client::METHOD_GET, '/param-injection?param=1234567891011'); - $this->assertEquals(400, $response['headers']['status-code']); + $this->assertSame(400, $response['headers']['status-code']); $this->assertStringStartsWith('Invalid `param` param: Value must be a valid string and at least 1 chars and no longer than 10 chars', $response['body']); $response = $this->client->call(Client::METHOD_GET, '/param-injection?param=test4573'); - $this->assertEquals(200, $response['headers']['status-code']); + $this->assertSame(200, $response['headers']['status-code']); $this->assertStringStartsWith('Hello World!test4573', $response['body']); } public function testNotFound() { $response = $this->client->call(Client::METHOD_GET, '/non-existing-page'); - $this->assertEquals(404, $response['headers']['status-code']); + $this->assertSame(404, $response['headers']['status-code']); $this->assertStringStartsWith('Not Found on ', $response['body']); } @@ -86,14 +86,14 @@ public function testCookie() // One cookie $cookie = 'cookie1=value1'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Two cookiees $cookie = 'cookie1=value1; cookie2=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); /** * Cookie response always expecting space in multiple cookie @@ -103,27 +103,27 @@ public function testCookie() // Two cookies without optional space $cookie = 'cookie1=value1;cookie2=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('cookie1=value1; cookie2=value2', $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('cookie1=value1; cookie2=value2', $response['body']); // Cookie with "=" in value $cookie = 'cookie1=value1=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Case sensitivity for cookie names $cookie = 'cookie1=v1;Cookie1=v2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('cookie1=v1; Cookie1=v2', $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('cookie1=v1; Cookie1=v2', $response['body']); } public function testSetCookie() { $response = $this->client->call(Client::METHOD_GET, '/set-cookie'); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('value1', $response['cookies']['key1']); - $this->assertEquals('value2', $response['cookies']['key2']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('value1', $response['cookies']['key1']); + $this->assertSame('value2', $response['cookies']['key2']); } } diff --git a/tests/e2e/ResponseFPMTest.php b/tests/e2e/ResponseFPMTest.php index b0f140c..f5c16a9 100644 --- a/tests/e2e/ResponseFPMTest.php +++ b/tests/e2e/ResponseFPMTest.php @@ -28,31 +28,31 @@ public function testCookie() // One cookie $cookie = 'cookie1=value1'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Two cookies with space (FPM preserves original format) $cookie = 'cookie1=value1; cookie2=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Two cookies without space (FPM preserves original format) $cookie = 'cookie1=value1;cookie2=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Cookie with "=" in value $cookie = 'cookie1=value1=value2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); // Case sensitivity for cookie names $cookie = 'cookie1=v1; Cookie1=v2'; $response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie' => $cookie ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals($cookie, $response['body']); + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($cookie, $response['body']); } }