Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit 5a2dba3

Browse files
authored
Merge pull request #21 from open-source-contributions/improve_assertions
Improve PHPUnit assertions
2 parents acc78bf + ab9083c commit 5a2dba3

38 files changed

+333
-333
lines changed

tests/HeaderAccessControlAllowCredentialsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ public function testGetFieldName()
1919
{
2020
$header = new HeaderAccessControlAllowCredentials();
2121

22-
$this->assertEquals('Access-Control-Allow-Credentials', $header->getFieldName());
22+
$this->assertSame('Access-Control-Allow-Credentials', $header->getFieldName());
2323
}
2424

2525
public function testGetFieldValue()
2626
{
2727
$header = new HeaderAccessControlAllowCredentials();
2828

29-
$this->assertEquals('true', $header->getFieldValue());
29+
$this->assertSame('true', $header->getFieldValue());
3030
}
3131

3232
public function testToString()
3333
{
3434
$header = new HeaderAccessControlAllowCredentials();
3535

36-
$this->assertEquals('Access-Control-Allow-Credentials: true', (string) $header);
36+
$this->assertSame('Access-Control-Allow-Credentials: true', (string) $header);
3737
}
3838

3939
public function testIteration()

tests/HeaderAccessControlAllowHeadersTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testSetValue()
3535

3636
$this->assertInstanceOf(HeaderInterface::class, $header->setValue('value-second'));
3737

38-
$this->assertEquals([
38+
$this->assertSame([
3939
'value-first',
4040
'value-second',
4141
], $header->getValue());
@@ -47,7 +47,7 @@ public function testSetSeveralValues()
4747

4848
$header->setValue('value-third', 'value-fourth');
4949

50-
$this->assertEquals([
50+
$this->assertSame([
5151
'value-first',
5252
'value-second',
5353
'value-third',
@@ -77,7 +77,7 @@ public function testGetValue()
7777
{
7878
$header = new HeaderAccessControlAllowHeaders('value');
7979

80-
$this->assertEquals(['value'], $header->getValue());
80+
$this->assertSame(['value'], $header->getValue());
8181
}
8282

8383
public function testResetValue()
@@ -86,34 +86,34 @@ public function testResetValue()
8686

8787
$this->assertInstanceOf(HeaderInterface::class, $header->resetValue());
8888

89-
$this->assertEquals([], $header->getValue());
89+
$this->assertSame([], $header->getValue());
9090
}
9191

9292
public function testGetFieldName()
9393
{
9494
$header = new HeaderAccessControlAllowHeaders('value');
9595

96-
$this->assertEquals('Access-Control-Allow-Headers', $header->getFieldName());
96+
$this->assertSame('Access-Control-Allow-Headers', $header->getFieldName());
9797
}
9898

9999
public function testGetFieldValue()
100100
{
101101
$header = new HeaderAccessControlAllowHeaders('value');
102102

103-
$this->assertEquals('value', $header->getFieldValue());
103+
$this->assertSame('value', $header->getFieldValue());
104104
}
105105

106106
public function testToStringWithOneValue()
107107
{
108108
$header = new HeaderAccessControlAllowHeaders('value');
109109

110-
$this->assertEquals('Access-Control-Allow-Headers: value', (string) $header);
110+
$this->assertSame('Access-Control-Allow-Headers: value', (string) $header);
111111
}
112112

113113
public function testToStringWithSeveralValues()
114114
{
115115
$header = new HeaderAccessControlAllowHeaders('value-first', 'value-second', 'value-third');
116116

117-
$this->assertEquals('Access-Control-Allow-Headers: value-first, value-second, value-third', (string) $header);
117+
$this->assertSame('Access-Control-Allow-Headers: value-first, value-second, value-third', (string) $header);
118118
}
119119
}

tests/HeaderAccessControlAllowMethodsTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testSetValue()
3535

3636
$this->assertInstanceOf(HeaderInterface::class, $header->setValue('get'));
3737

38-
$this->assertEquals([
38+
$this->assertSame([
3939
'HEAD',
4040
'GET',
4141
], $header->getValue());
@@ -47,7 +47,7 @@ public function testSetSeveralValues()
4747

4848
$header->setValue('post', 'patch');
4949

50-
$this->assertEquals([
50+
$this->assertSame([
5151
'HEAD',
5252
'GET',
5353
'POST',
@@ -77,7 +77,7 @@ public function testGetValue()
7777
{
7878
$header = new HeaderAccessControlAllowMethods('head');
7979

80-
$this->assertEquals(['HEAD'], $header->getValue());
80+
$this->assertSame(['HEAD'], $header->getValue());
8181
}
8282

8383
public function testResetValue()
@@ -86,34 +86,34 @@ public function testResetValue()
8686

8787
$this->assertInstanceOf(HeaderInterface::class, $header->resetValue());
8888

89-
$this->assertEquals([], $header->getValue());
89+
$this->assertSame([], $header->getValue());
9090
}
9191

9292
public function testGetFieldName()
9393
{
9494
$header = new HeaderAccessControlAllowMethods('head');
9595

96-
$this->assertEquals('Access-Control-Allow-Methods', $header->getFieldName());
96+
$this->assertSame('Access-Control-Allow-Methods', $header->getFieldName());
9797
}
9898

9999
public function testGetFieldValue()
100100
{
101101
$header = new HeaderAccessControlAllowMethods('head');
102102

103-
$this->assertEquals('HEAD', $header->getFieldValue());
103+
$this->assertSame('HEAD', $header->getFieldValue());
104104
}
105105

106106
public function testToStringWithOneValue()
107107
{
108108
$header = new HeaderAccessControlAllowMethods('head');
109109

110-
$this->assertEquals('Access-Control-Allow-Methods: HEAD', (string) $header);
110+
$this->assertSame('Access-Control-Allow-Methods: HEAD', (string) $header);
111111
}
112112

113113
public function testToStringWithSeveralValues()
114114
{
115115
$header = new HeaderAccessControlAllowMethods('head', 'get', 'post');
116116

117-
$this->assertEquals('Access-Control-Allow-Methods: HEAD, GET, POST', (string) $header);
117+
$this->assertSame('Access-Control-Allow-Methods: HEAD, GET, POST', (string) $header);
118118
}
119119
}

tests/HeaderAccessControlAllowOriginTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testSetUri()
4949

5050
$this->assertInstanceOf(HeaderInterface::class, $header->setUri($uri2));
5151

52-
$this->assertEquals($uri2, $header->getUri());
52+
$this->assertSame($uri2, $header->getUri());
5353
}
5454

5555
public function testSetEmptyUri()
@@ -60,7 +60,7 @@ public function testSetEmptyUri()
6060

6161
$this->assertInstanceOf(HeaderInterface::class, $header->setUri(null));
6262

63-
$this->assertEquals(null, $header->getUri());
63+
$this->assertNull($header->getUri());
6464
}
6565

6666
public function testSetInvalidUriThatWithoutScheme()
@@ -87,28 +87,28 @@ public function testGetUri()
8787

8888
$header = new HeaderAccessControlAllowOrigin($uri);
8989

90-
$this->assertEquals($uri, $header->getUri());
90+
$this->assertSame($uri, $header->getUri());
9191
}
9292

9393
public function testGetEmptyUri()
9494
{
9595
$header = new HeaderAccessControlAllowOrigin(null);
9696

97-
$this->assertEquals(null, $header->getUri());
97+
$this->assertNull($header->getUri());
9898
}
9999

100100
public function testGetFieldName()
101101
{
102102
$header = new HeaderAccessControlAllowOrigin(null);
103103

104-
$this->assertEquals('Access-Control-Allow-Origin', $header->getFieldName());
104+
$this->assertSame('Access-Control-Allow-Origin', $header->getFieldName());
105105
}
106106

107107
public function testGetFieldValueWithoutUri()
108108
{
109109
$header = new HeaderAccessControlAllowOrigin(null);
110110

111-
$this->assertEquals('*', $header->getFieldValue());
111+
$this->assertSame('*', $header->getFieldValue());
112112
}
113113

114114
public function testGetFieldValueWithSchemeAndHost()
@@ -117,7 +117,7 @@ public function testGetFieldValueWithSchemeAndHost()
117117

118118
$header = new HeaderAccessControlAllowOrigin($uri);
119119

120-
$this->assertEquals('http://localhost', $header->getFieldValue());
120+
$this->assertSame('http://localhost', $header->getFieldValue());
121121
}
122122

123123
public function testGetFieldValueWithSchemeAndHostAndPort()
@@ -126,7 +126,7 @@ public function testGetFieldValueWithSchemeAndHostAndPort()
126126

127127
$header = new HeaderAccessControlAllowOrigin($uri);
128128

129-
$this->assertEquals('http://localhost:3000', $header->getFieldValue());
129+
$this->assertSame('http://localhost:3000', $header->getFieldValue());
130130
}
131131

132132
public function testGetFieldValueWithValidOrigin()
@@ -135,14 +135,14 @@ public function testGetFieldValueWithValidOrigin()
135135

136136
$header = new HeaderAccessControlAllowOrigin($uri);
137137

138-
$this->assertEquals('http://localhost:3000', $header->getFieldValue());
138+
$this->assertSame('http://localhost:3000', $header->getFieldValue());
139139
}
140140

141141
public function testToStringWithoutUri()
142142
{
143143
$header = new HeaderAccessControlAllowOrigin(null);
144144

145-
$this->assertEquals('Access-Control-Allow-Origin: *', (string) $header);
145+
$this->assertSame('Access-Control-Allow-Origin: *', (string) $header);
146146
}
147147

148148
public function testToStringWithSchemeAndHost()
@@ -151,7 +151,7 @@ public function testToStringWithSchemeAndHost()
151151

152152
$header = new HeaderAccessControlAllowOrigin($uri);
153153

154-
$this->assertEquals('Access-Control-Allow-Origin: http://localhost', (string) $header);
154+
$this->assertSame('Access-Control-Allow-Origin: http://localhost', (string) $header);
155155
}
156156

157157
public function testToStringWithSchemeAndHostAndPort()
@@ -160,7 +160,7 @@ public function testToStringWithSchemeAndHostAndPort()
160160

161161
$header = new HeaderAccessControlAllowOrigin($uri);
162162

163-
$this->assertEquals('Access-Control-Allow-Origin: http://localhost:3000', (string) $header);
163+
$this->assertSame('Access-Control-Allow-Origin: http://localhost:3000', (string) $header);
164164
}
165165

166166
public function testToStringWithValidOrigin()
@@ -169,6 +169,6 @@ public function testToStringWithValidOrigin()
169169

170170
$header = new HeaderAccessControlAllowOrigin($uri);
171171

172-
$this->assertEquals('Access-Control-Allow-Origin: http://localhost:3000', (string) $header);
172+
$this->assertSame('Access-Control-Allow-Origin: http://localhost:3000', (string) $header);
173173
}
174174
}

tests/HeaderAccessControlExposeHeadersTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testSetValue()
3535

3636
$this->assertInstanceOf(HeaderInterface::class, $header->setValue('value-second'));
3737

38-
$this->assertEquals([
38+
$this->assertSame([
3939
'value-first',
4040
'value-second',
4141
], $header->getValue());
@@ -47,7 +47,7 @@ public function testSetSeveralValues()
4747

4848
$header->setValue('value-third', 'value-fourth');
4949

50-
$this->assertEquals([
50+
$this->assertSame([
5151
'value-first',
5252
'value-second',
5353
'value-third',
@@ -77,7 +77,7 @@ public function testGetValue()
7777
{
7878
$header = new HeaderAccessControlExposeHeaders('value');
7979

80-
$this->assertEquals(['value'], $header->getValue());
80+
$this->assertSame(['value'], $header->getValue());
8181
}
8282

8383
public function testResetValue()
@@ -86,34 +86,34 @@ public function testResetValue()
8686

8787
$this->assertInstanceOf(HeaderInterface::class, $header->resetValue());
8888

89-
$this->assertEquals([], $header->getValue());
89+
$this->assertSame([], $header->getValue());
9090
}
9191

9292
public function testGetFieldName()
9393
{
9494
$header = new HeaderAccessControlExposeHeaders('value');
9595

96-
$this->assertEquals('Access-Control-Expose-Headers', $header->getFieldName());
96+
$this->assertSame('Access-Control-Expose-Headers', $header->getFieldName());
9797
}
9898

9999
public function testGetFieldValue()
100100
{
101101
$header = new HeaderAccessControlExposeHeaders('value');
102102

103-
$this->assertEquals('value', $header->getFieldValue());
103+
$this->assertSame('value', $header->getFieldValue());
104104
}
105105

106106
public function testToStringWithOneValue()
107107
{
108108
$header = new HeaderAccessControlExposeHeaders('value');
109109

110-
$this->assertEquals('Access-Control-Expose-Headers: value', (string) $header);
110+
$this->assertSame('Access-Control-Expose-Headers: value', (string) $header);
111111
}
112112

113113
public function testToStringWithSeveralValues()
114114
{
115115
$header = new HeaderAccessControlExposeHeaders('value-first', 'value-second', 'value-third');
116116

117-
$this->assertEquals('Access-Control-Expose-Headers: value-first, value-second, value-third', (string) $header);
117+
$this->assertSame('Access-Control-Expose-Headers: value-first, value-second, value-third', (string) $header);
118118
}
119119
}

tests/HeaderAccessControlMaxAgeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testSetValue()
2828

2929
$this->assertInstanceOf(HeaderInterface::class, $header->setValue(-1));
3030

31-
$this->assertEquals(-1, $header->getValue());
31+
$this->assertSame(-1, $header->getValue());
3232
}
3333

3434
public function testSetInvalidValue()
@@ -44,27 +44,27 @@ public function testGetValue()
4444
{
4545
$header = new HeaderAccessControlMaxAge(86400);
4646

47-
$this->assertEquals(86400, $header->getValue());
47+
$this->assertSame(86400, $header->getValue());
4848
}
4949

5050
public function testGetFieldName()
5151
{
5252
$header = new HeaderAccessControlMaxAge(86400);
5353

54-
$this->assertEquals('Access-Control-Max-Age', $header->getFieldName());
54+
$this->assertSame('Access-Control-Max-Age', $header->getFieldName());
5555
}
5656

5757
public function testGetFieldValue()
5858
{
5959
$header = new HeaderAccessControlMaxAge(86400);
6060

61-
$this->assertEquals('86400', $header->getFieldValue());
61+
$this->assertSame('86400', $header->getFieldValue());
6262
}
6363

6464
public function testToString()
6565
{
6666
$header = new HeaderAccessControlMaxAge(86400);
6767

68-
$this->assertEquals('Access-Control-Max-Age: 86400', (string) $header);
68+
$this->assertSame('Access-Control-Max-Age: 86400', (string) $header);
6969
}
7070
}

0 commit comments

Comments
 (0)