/** * Tests the parse_header_values() method. * * @dataProvider provider_parse_header_values * * @param array header array to parse * @param array expected result * @return void */ public function test_parse_header_values($header_array, $expected) { $header = HTTP_Header::parse_header_values($header_array); // Test the correct type is returned $this->assertTrue(is_array($header)); foreach ($header as $key => $value) { if ($value instanceof HTTP_Header_Value) { $this->assertSame($value->value(), $expected[$key]->value()); $this->assertSame($value->key(), $expected[$key]->key()); $this->assertSame($value->properties(), $expected[$key]->properties()); } elseif (is_array($value)) { foreach ($value as $k => $v) { $this->assertSame($v->value(), $expected[$key][$k]->value()); $this->assertSame($v->key(), $expected[$key][$k]->key()); $this->assertSame($v->properties(), $expected[$key][$k]->properties()); } } else { $this->fail('Unexpected value in HTTP_Header::parse_header_values() return value.'); } } }
/** * Overloads the `ArrayObject::exchangeArray()` method to ensure all * values passed are parsed correctly into a [Kohana_HTTP_Header_Value]. * * // Input new headers * $headers->exchangeArray(array( * 'date' => 'Wed, 24 Nov 2010 21:09:23 GMT', * 'cache-control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' * )); * * @param array $array Array to exchange * @return array */ public function exchangeArray($array) { return parent::exchangeArray(HTTP_Header::parse_header_values($array)); }