@@ -31,17 +31,16 @@ protected function setUp(): void
3131 parent ::setUp ();
3232
3333 // set a baseline user agent
34- $ _SERVER [ ' HTTP_USER_AGENT '] = $ this ->_user_agent ;
34+ service ( ' superglobals ' )-> setServer ( ' HTTP_USER_AGENT ', $ this ->_user_agent ) ;
3535
3636 $ this ->agent = new UserAgent ();
3737 }
3838
3939 public function testMobile (): void
4040 {
4141 // Mobile Not Set
42- $ _SERVER [ ' HTTP_USER_AGENT '] = $ this ->_mobile_ua ;
42+ service ( ' superglobals ' )-> setServer ( ' HTTP_USER_AGENT ', $ this ->_mobile_ua ) ;
4343 $ this ->assertFalse ($ this ->agent ->isMobile ());
44- unset($ _SERVER ['HTTP_USER_AGENT ' ]);
4544 }
4645
4746 public function testIsFunctions (): void
@@ -55,12 +54,13 @@ public function testIsFunctions(): void
5554
5655 public function testReferrer (): void
5756 {
58- $ _SERVER ['HTTP_REFERER ' ] = 'http://codeigniter.com/user_guide/ ' ;
57+ service ('superglobals ' )->setServer ('HTTP_REFERER ' , 'http://codeigniter.com/user_guide/ ' );
58+
5959 $ this ->assertTrue ($ this ->agent ->isReferral ());
6060 $ this ->assertSame ('http://codeigniter.com/user_guide/ ' , $ this ->agent ->getReferrer ());
6161
6262 $ this ->setPrivateProperty ($ this ->agent , 'referrer ' , null );
63- unset( $ _SERVER [ ' HTTP_REFERER '] );
63+ service ( ' superglobals ' )-> setServer ( ' HTTP_REFERER ', '' );
6464 $ this ->assertFalse ($ this ->agent ->isReferral ());
6565 $ this ->assertSame ('' , $ this ->agent ->getReferrer ());
6666 }
@@ -108,7 +108,7 @@ public function testParseBot(): void
108108
109109 public function testEmptyUserAgentVariable (): void
110110 {
111- unset( $ _SERVER [ ' HTTP_USER_AGENT '] );
111+ service ( ' superglobals ' )-> setServer ( ' HTTP_USER_AGENT ', '' );
112112 $ agent = new UserAgent ();
113113 $ this ->assertEmpty ((string ) $ agent );
114114 }
0 commit comments