converted phpunit ClientRequestTest to PHPTs
[m6w6/ext-http] / phpunit / HeaderTest.php
index b34adcb5e9e525183d71f0129b1008645552c575..184f21a58065223e3617f9414e379e155d51beff 100644 (file)
@@ -47,9 +47,9 @@ class HeaderTest extends PHPUnit_Framework_TestCase {
     function testParse() {
        $header = "Foo: bar\nBar: foo\n";
        $this->assertEquals(array("Foo"=>"bar","Bar"=>"foo"), http\Header::parse($header)); 
-       $header = http\Header::parse($header, "http\\Header");
-       $this->assertCount(2, $header);
-       $this->assertContainsOnlyInstancesOf("http\\Header", $header); 
+       $headers = http\Header::parse($header, "http\\Header");
+       $this->assertCount(2, $headers);
+       $this->assertContainsOnlyInstancesOf("http\\Header", $headers); 
     }
     
     function testParseError() {
@@ -57,4 +57,27 @@ class HeaderTest extends PHPUnit_Framework_TestCase {
        $this->setExpectedException("PHPUnit_Framework_Error_Warning", "Could not parse headers");
        $this->assertFalse(http\Header::parse($header));
     }
+       
+       function testParams() {
+               $header = new http\Header("Cache-control", "public, must-revalidate, max-age=0");
+               $this->assertEquals(
+                       array(
+                               "public" => array("value" => true, "arguments" => array()),
+                               "must-revalidate" => array("value" => true, "arguments" => array()),
+                               "max-age" => array("value" => 0, "arguments" => array()),
+                       ),
+                       $header->getParams()->params
+               );
+       }
+       
+       function testParamsWithArgs() {
+               $header = new http\Header("Custom", '"foo" is "bar". "bar" is "bis" where "bis" is "where".');
+               $this->assertEquals(
+                       array(
+                               "foo" => array("value" => "bar", "arguments" => array()),
+                               "bar" => array("value" => "bis", "arguments" => array("bis" => "where"))
+                       ),
+                       $header->getParams(".", "where", "is")->params
+               );
+       }
 }