tests & bugfixes
[m6w6/ext-http] / phpunit / HeaderTest.php
1 <?php
2
3 class HeaderTest extends PHPUnit_Framework_TestCase {
4 function setUp() {
5 $this->h = new http\Header("foo", "bar");
6 }
7 function testString() {
8 $this->assertEquals("Foo: bar", (string) $this->h);
9 }
10
11 function testSerialize() {
12 $this->assertEquals("Foo: bar", (string) unserialize(serialize($this->h)));
13 }
14
15 function testMatch() {
16 $ae = new http\Header("Accept-encoding", "gzip, deflate");
17 $this->assertTrue($ae->match("gzip", http\Header::MATCH_WORD));
18 $this->assertTrue($ae->match("gzip", http\Header::MATCH_WORD|http\Header::MATCH_CASE));
19 $this->assertFalse($ae->match("gzip", http\Header::MATCH_STRICT));
20 $this->assertTrue($ae->match("deflate", http\Header::MATCH_WORD));
21 $this->assertTrue($ae->match("deflate", http\Header::MATCH_WORD|http\Header::MATCH_CASE));
22 $this->assertFalse($ae->match("deflate", http\Header::MATCH_STRICT));
23
24 $this->assertFalse($ae->match("zip", http\Header::MATCH_WORD));
25 $this->assertFalse($ae->match("gzip", http\Header::MATCH_FULL));
26 }
27 }