Commit e51562e 1 parent 750b726 commit e51562e Copy full SHA for e51562e
File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use ElkArte \Server ;
4
+ use PHPUnit \Framework \TestCase ;
5
+
6
+ class ServerTest extends TestCase
7
+ {
8
+ /**
9
+ * Test that the `getProtocol()` method of the `Server` class
10
+ * correctly returns web server's protocol.
11
+ */
12
+ public function testGetProtocol ()
13
+ {
14
+ $ serverData = [
15
+ 'SERVER_PROTOCOL ' => 'HTTP/1.1 ' ,
16
+ ];
17
+
18
+ $ server = new Server ($ serverData );
19
+
20
+ $ this ->assertEquals ('HTTP/1.1 ' , $ server ->getProtocol ());
21
+ }
22
+
23
+ /**
24
+ * Testing `getProtocol()` method when 'SERVER_PROTOCOL' value is not set.
25
+ * In this case, the method should return 'HTTP/1.0'
26
+ */
27
+ public function testGetProtocolDefault ()
28
+ {
29
+ $ serverData = [];
30
+
31
+ $ server = new Server ($ serverData );
32
+
33
+ $ this ->assertEquals ('HTTP/1.0 ' , $ server ->getProtocol ());
34
+ }
35
+
36
+ /**
37
+ * Test the `getProtocol()` method to handle invalid value of 'SERVER_PROTOCOL'.
38
+ * The method should return the default 'HTTP/1.0'
39
+ */
40
+ public function testGetProtocolInvalid ()
41
+ {
42
+ $ serverData = [
43
+ 'SERVER_PROTOCOL ' => 'INVALID_PROTOCOL ' ,
44
+ ];
45
+
46
+ $ server = new Server ($ serverData );
47
+
48
+ $ this ->assertEquals ('HTTP/1.0 ' , $ server ->getProtocol ());
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments