wiki.techinc.nl/tests/phpunit/includes/filebackend/HTTPFileStreamerTest.php
Gergő Tisza 65648f5523 Add helper for HTTPFileStreamer header syntax
Adds a helper function for transforming an intuitive header array
to the peculiar syntax expected by HTTPFileStreamer and the related
FileRepo/FileBackend streaming methods.

Change-Id: Idac9281b0f1b3c93f4ec1d1c3f336db110e5d260
2019-07-11 23:23:59 +00:00

36 lines
949 B
PHP

<?php
use PHPUnit\Framework\TestCase;
class HTTPFileStreamerTest extends TestCase {
/**
* @covers HTTPFileStreamer::preprocessHeaders
* @dataProvider providePreprocessHeaders
*/
public function testPreprocessHeaders( array $input, array $expectedRaw, array $expectedOpt ) {
list( $actualRaw, $actualOpt ) = HTTPFileStreamer::preprocessHeaders( $input );
$this->assertSame( $expectedRaw, $actualRaw );
$this->assertSame( $expectedOpt, $actualOpt );
}
public function providePreprocessHeaders() {
return [
[
[ 'Vary' => 'cookie', 'Cache-Control' => 'private' ],
[ 'Vary: cookie', 'Cache-Control: private' ],
[],
],
[
[
'Range' => 'bytes=(123-456)',
'Content-Type' => 'video/mp4',
'If-Modified-Since' => 'Wed, 21 Oct 2015 07:28:00 GMT',
],
[ 'Content-Type: video/mp4' ],
[ 'range' => 'bytes=(123-456)', 'if-modified-since' => 'Wed, 21 Oct 2015 07:28:00 GMT' ],
],
];
}
}