Browse Source

[BrowserKit] added getServerParameter method which makes setServerParameters/setServerParameter methods testable

hidenorigoto 14 năm trước cách đây
mục cha
commit
1d85a3dcb1
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      src/Symfony/Component/BrowserKit/Client.php

+ 12 - 0
src/Symfony/Component/BrowserKit/Client.php

@@ -119,6 +119,18 @@ abstract class Client
         $this->server[$key] = $value;
     }
 
+    /**
+     * Gets single server parameter for specified key.
+     *
+     * @param string $key     A key of the parameter to get
+     * @param string $default A default value when key is undefined
+     * @return string A value of the parameter
+     */
+    public function getServerParameter($key, $default = '')
+    {
+        return (isset($this->server[$key])) ? $this->server[$key] : $default;
+    }
+
     /**
      * Returns the History instance.
      *