Skip to content

Commit 7b973b7

Browse files
committed
Change assertEquals method to assertSame in tests
1 parent 8412fd4 commit 7b973b7

File tree

8 files changed

+258
-266
lines changed

8 files changed

+258
-266
lines changed

tests/EmptyResponseTest.php

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public function setUp(): void
2626

2727
public function testGettersDefault(): void
2828
{
29-
self::assertEquals(EmptyResponse::STATUS_NO_CONTENT, $this->response->getStatusCode());
30-
self::assertEquals(
29+
$this->assertSame(EmptyResponse::STATUS_NO_CONTENT, $this->response->getStatusCode());
30+
$this->assertSame(
3131
EmptyResponse::PHRASES[EmptyResponse::STATUS_NO_CONTENT],
3232
$this->response->getReasonPhrase()
3333
);
34-
self::assertInstanceOf(StreamInterface::class, $this->response->getBody());
35-
self::assertEquals('php://temp', $this->response->getBody()->getMetadata('uri'));
36-
self::assertEquals('', $this->response->getBody()->getContents());
37-
self::assertEquals([], $this->response->getHeaders());
38-
self::assertEquals('1.1', $this->response->getProtocolVersion());
34+
$this->assertInstanceOf(StreamInterface::class, $this->response->getBody());
35+
$this->assertSame('php://temp', $this->response->getBody()->getMetadata('uri'));
36+
$this->assertSame('', $this->response->getBody()->getContents());
37+
$this->assertSame([], $this->response->getHeaders());
38+
$this->assertSame('1.1', $this->response->getProtocolVersion());
3939
}
4040

4141
public function testGettersWithSpecifiedArguments(): void
@@ -46,36 +46,28 @@ public function testGettersWithSpecifiedArguments(): void
4646
$protocol = '2',
4747
$reasonPhrase = 'Custom Phrase',
4848
);
49-
self::assertEquals($statusCode, $response->getStatusCode());
50-
self::assertEquals($reasonPhrase, $response->getReasonPhrase());
51-
self::assertInstanceOf(StreamInterface::class, $response->getBody());
52-
self::assertEquals('php://temp', $response->getBody()->getMetadata('uri'));
53-
self::assertEquals(['Content-Language' => ['en']], $response->getHeaders());
54-
self::assertEquals($protocol, $response->getProtocolVersion());
49+
$this->assertSame($statusCode, $response->getStatusCode());
50+
$this->assertSame($reasonPhrase, $response->getReasonPhrase());
51+
$this->assertInstanceOf(StreamInterface::class, $response->getBody());
52+
$this->assertSame('php://temp', $response->getBody()->getMetadata('uri'));
53+
$this->assertSame(['Content-Language' => ['en']], $response->getHeaders());
54+
$this->assertSame($protocol, $response->getProtocolVersion());
5555
}
5656

5757
public function testWithStatus(): void
5858
{
5959
$response = $this->response->withStatus(EmptyResponse::STATUS_CREATED);
60-
self::assertNotEquals($this->response, $response);
61-
self::assertEquals(EmptyResponse::STATUS_CREATED, $response->getStatusCode());
62-
self::assertEquals(EmptyResponse::PHRASES[EmptyResponse::STATUS_CREATED], $response->getReasonPhrase());
60+
$this->assertNotSame($this->response, $response);
61+
$this->assertSame(EmptyResponse::STATUS_CREATED, $response->getStatusCode());
62+
$this->assertSame(EmptyResponse::PHRASES[EmptyResponse::STATUS_CREATED], $response->getReasonPhrase());
6363
}
6464

6565
public function testWithStatusAndCustomReasonPhrase(): void
6666
{
6767
$response = $this->response->withStatus(EmptyResponse::STATUS_CREATED, $customPhrase = 'Custom Phrase');
68-
self::assertNotEquals($this->response, $response);
69-
self::assertEquals(EmptyResponse::STATUS_CREATED, $response->getStatusCode());
70-
self::assertEquals($customPhrase, $response->getReasonPhrase());
71-
}
72-
73-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
74-
{
75-
$response = $this->response->withStatus(EmptyResponse::STATUS_NO_CONTENT);
76-
self::assertEquals($this->response, $response);
77-
self::assertEquals(EmptyResponse::STATUS_NO_CONTENT, $response->getStatusCode());
78-
self::assertEquals(EmptyResponse::PHRASES[EmptyResponse::STATUS_NO_CONTENT], $response->getReasonPhrase());
68+
$this->assertNotSame($this->response, $response);
69+
$this->assertSame(EmptyResponse::STATUS_CREATED, $response->getStatusCode());
70+
$this->assertSame($customPhrase, $response->getReasonPhrase());
7971
}
8072

8173
/**

tests/HtmlResponseTest.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public function setUp(): void
3636

3737
public function testGettersDefault(): void
3838
{
39-
self::assertEquals(HtmlResponse::STATUS_OK, $this->response->getStatusCode());
40-
self::assertEquals(HtmlResponse::PHRASES[HtmlResponse::STATUS_OK], $this->response->getReasonPhrase());
41-
self::assertInstanceOf(StreamInterface::class, $this->response->getBody());
42-
self::assertEquals('php://temp', $this->response->getBody()->getMetadata('uri'));
43-
self::assertEquals($this->content, $this->response->getBody()->getContents());
44-
self::assertEquals($this->contentType, $this->response->getHeaderLine('content-type'));
45-
self::assertEquals('1.1', $this->response->getProtocolVersion());
39+
$this->assertSame(HtmlResponse::STATUS_OK, $this->response->getStatusCode());
40+
$this->assertSame(HtmlResponse::PHRASES[HtmlResponse::STATUS_OK], $this->response->getReasonPhrase());
41+
$this->assertInstanceOf(StreamInterface::class, $this->response->getBody());
42+
$this->assertSame('php://temp', $this->response->getBody()->getMetadata('uri'));
43+
$this->assertSame($this->content, $this->response->getBody()->getContents());
44+
$this->assertSame($this->contentType, $this->response->getHeaderLine('content-type'));
45+
$this->assertSame('1.1', $this->response->getProtocolVersion());
4646
}
4747

4848
public function testGettersSpecifiedArguments(): void
@@ -54,18 +54,18 @@ public function testGettersSpecifiedArguments(): void
5454
$protocol = '2',
5555
$reasonPhrase = HtmlResponse::PHRASES[HtmlResponse::STATUS_NOT_FOUND]
5656
);
57-
self::assertEquals($this->content, $response->getBody()->getContents());
58-
self::assertEquals($statusCode, $response->getStatusCode());
59-
self::assertEquals($reasonPhrase, $response->getReasonPhrase());
60-
self::assertInstanceOf(StreamInterface::class, $response->getBody());
61-
self::assertEquals(
57+
$this->assertSame($this->content, $response->getBody()->getContents());
58+
$this->assertSame($statusCode, $response->getStatusCode());
59+
$this->assertSame($reasonPhrase, $response->getReasonPhrase());
60+
$this->assertInstanceOf(StreamInterface::class, $response->getBody());
61+
$this->assertSame(
6262
[
6363
'Content-Language' => ['en'],
6464
'Content-Type' => [$this->contentType],
6565
],
6666
$response->getHeaders()
6767
);
68-
self::assertEquals($protocol, $response->getProtocolVersion());
68+
$this->assertSame($protocol, $response->getProtocolVersion());
6969
}
7070

7171
public function testGettersIfHasBeenPassedContentTypeHeader(): void
@@ -77,42 +77,42 @@ public function testGettersIfHasBeenPassedContentTypeHeader(): void
7777
$protocol = '2',
7878
$reasonPhrase = HtmlResponse::PHRASES[HtmlResponse::STATUS_NOT_FOUND]
7979
);
80-
self::assertEquals($this->content, $response->getBody()->getContents());
81-
self::assertEquals($statusCode, $response->getStatusCode());
82-
self::assertEquals($reasonPhrase, $response->getReasonPhrase());
83-
self::assertInstanceOf(StreamInterface::class, $response->getBody());
84-
self::assertEquals(
80+
$this->assertSame($this->content, $response->getBody()->getContents());
81+
$this->assertSame($statusCode, $response->getStatusCode());
82+
$this->assertSame($reasonPhrase, $response->getReasonPhrase());
83+
$this->assertInstanceOf(StreamInterface::class, $response->getBody());
84+
$this->assertSame(
8585
[
8686
'Content-Language' => ['en'],
8787
'Content-Type' => ['text/plain; charset=UTF-8'],
8888
],
8989
$response->getHeaders()
9090
);
91-
self::assertEquals($protocol, $response->getProtocolVersion());
91+
$this->assertSame($protocol, $response->getProtocolVersion());
9292
}
9393

9494
public function testWithStatus(): void
9595
{
9696
$response = $this->response->withStatus(HtmlResponse::STATUS_NOT_FOUND);
97-
self::assertNotEquals($this->response, $response);
98-
self::assertEquals(HtmlResponse::STATUS_NOT_FOUND, $response->getStatusCode());
99-
self::assertEquals(HtmlResponse::PHRASES[HtmlResponse::STATUS_NOT_FOUND], $response->getReasonPhrase());
97+
$this->assertNotSame($this->response, $response);
98+
$this->assertSame(HtmlResponse::STATUS_NOT_FOUND, $response->getStatusCode());
99+
$this->assertSame(HtmlResponse::PHRASES[HtmlResponse::STATUS_NOT_FOUND], $response->getReasonPhrase());
100100
}
101101

102102
public function testWithStatusAndCustomReasonPhrase(): void
103103
{
104104
$response = $this->response->withStatus(HtmlResponse::STATUS_NOT_FOUND, $customPhrase = 'Custom Phrase');
105-
self::assertNotEquals($this->response, $response);
106-
self::assertEquals(HtmlResponse::STATUS_NOT_FOUND, $response->getStatusCode());
107-
self::assertEquals($customPhrase, $response->getReasonPhrase());
105+
$this->assertNotSame($this->response, $response);
106+
$this->assertSame(HtmlResponse::STATUS_NOT_FOUND, $response->getStatusCode());
107+
$this->assertSame($customPhrase, $response->getReasonPhrase());
108108
}
109109

110110
public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase(): void
111111
{
112112
$response = $this->response->withStatus(HtmlResponse::STATUS_OK, $customPhrase = 'Custom Phrase');
113-
self::assertNotEquals($this->response, $response);
114-
self::assertEquals(HtmlResponse::STATUS_OK, $response->getStatusCode());
115-
self::assertEquals($customPhrase, $response->getReasonPhrase());
113+
$this->assertNotSame($this->response, $response);
114+
$this->assertSame(HtmlResponse::STATUS_OK, $response->getStatusCode());
115+
$this->assertSame($customPhrase, $response->getReasonPhrase());
116116
}
117117

118118
/**

0 commit comments

Comments
 (0)