File tree 2 files changed +35
-0
lines changed
src/Symfony/Component/BrowserKit 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,16 @@ public function setServerParameter($key, $value)
138
138
$ this ->server [$ key ] = $ value ;
139
139
}
140
140
141
+ /**
142
+ * Unset single server parameter.
143
+ *
144
+ * @param string $key A key of the parameter
145
+ */
146
+ public function unSetServerParameter ($ key )
147
+ {
148
+ unset($ this ->server [$ key ]);
149
+ }
150
+
141
151
/**
142
152
* Gets single server parameter for specified key.
143
153
*
Original file line number Diff line number Diff line change @@ -620,6 +620,31 @@ public function testSetServerParameter()
620
620
$ this ->assertEquals ('testua ' , $ client ->getServerParameter ('HTTP_USER_AGENT ' ));
621
621
}
622
622
623
+ public function testUnSetServerParameter ()
624
+ {
625
+ $ client = new TestClient ();
626
+
627
+ $ this ->assertEquals ('' , $ client ->getServerParameter ('HTTP_HOST ' ));
628
+ $ this ->assertEquals ('Symfony BrowserKit ' , $ client ->getServerParameter ('HTTP_USER_AGENT ' ));
629
+
630
+ $ client ->setServerParameter ('HTTP_HOST ' , 'testhost ' );
631
+ $ client ->unSetServerParameter ('HTTP_HOST ' );
632
+
633
+ $ this ->assertEquals ('' , $ client ->getServerParameter ('HTTP_HOST ' ));
634
+
635
+ $ client ->setServerParameter ('HTTP_USER_AGENT ' , 'testua ' );
636
+ $ client ->unSetServerParameter ('HTTP_USER_AGENT ' );
637
+
638
+ $ this ->assertEquals ('' , $ client ->getServerParameter ('HTTP_USER_AGENT ' ));
639
+
640
+ $ client ->setServerParameter ('HTTP_X-Requested-With ' , 'XMLHttpRequest ' );
641
+ $ client ->unSetServerParameter ('HTTP_X-Requested-With ' );
642
+
643
+ $ client ->unSetServerParameter ('HTTP_X-fefef-With ' );
644
+
645
+ $ this ->assertEquals ('' , $ client ->getServerParameter ('HTTP_X-Requested-With ' ));
646
+ }
647
+
623
648
public function testSetServerParameterInRequest ()
624
649
{
625
650
$ client = new TestClient ();
You can’t perform that action at this time.
0 commit comments