Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / filebackend / SwiftFileBackendTest.php
blob95ffb7057b35500c81832ba60dc27b3cb2752898
1 <?php
3 /**
4 * @group FileRepo
5 * @group FileBackend
6 * @group medium
7 */
8 class SwiftFileBackendTest extends MediaWikiTestCase {
9 /** @var TestingAccessWrapper Proxy to SwiftFileBackend */
10 private $backend;
12 protected function setUp() {
13 parent::setUp();
15 $this->backend = TestingAccessWrapper::newFromObject(
16 new SwiftFileBackend( [
17 'name' => 'local-swift-testing',
18 'class' => 'SwiftFileBackend',
19 'wikiId' => 'unit-testing',
20 'lockManager' => LockManagerGroup::singleton()->get( 'fsLockManager' ),
21 'swiftAuthUrl' => 'http://127.0.0.1:8080/auth', // unused
22 'swiftUser' => 'test:tester',
23 'swiftKey' => 'testing',
24 'swiftTempUrlKey' => 'b3968d0207b54ece87cccc06515a89d4' // unused
25 ] )
29 /**
30 * @dataProvider provider_testSanitizeHdrs
31 * @covers SwiftFileBackend::sanitizeHdrs
32 * @covers SwiftFileBackend::getCustomHeaders
34 public function testSanitizeHdrs( $raw, $sanitized ) {
35 $hdrs = $this->backend->sanitizeHdrs( [ 'headers' => $raw ] );
37 $this->assertEquals( $hdrs, $sanitized, 'sanitizeHdrs() has expected result' );
40 public static function provider_testSanitizeHdrs() {
41 return [
44 'content-length' => 345,
45 'content-type' => 'image+bitmap/jpeg',
46 'content-disposition' => 'inline',
47 'content-duration' => 35.6363,
48 'content-Custom' => 'hello',
49 'x-content-custom' => 'hello'
52 'content-disposition' => 'inline',
53 'content-duration' => 35.6363,
54 'content-custom' => 'hello',
55 'x-content-custom' => 'hello'
60 'content-length' => 345,
61 'content-type' => 'image+bitmap/jpeg',
62 'content-Disposition' => 'inline; filename=xxx; ' . str_repeat( 'o', 1024 ),
63 'content-duration' => 35.6363,
64 'content-custom' => 'hello',
65 'x-content-custom' => 'hello'
68 'content-disposition' => 'inline;filename=xxx',
69 'content-duration' => 35.6363,
70 'content-custom' => 'hello',
71 'x-content-custom' => 'hello'
76 'content-length' => 345,
77 'content-type' => 'image+bitmap/jpeg',
78 'content-disposition' => 'filename=' . str_repeat( 'o', 1024 ) . ';inline',
79 'content-duration' => 35.6363,
80 'content-custom' => 'hello',
81 'x-content-custom' => 'hello'
84 'content-disposition' => '',
85 'content-duration' => 35.6363,
86 'content-custom' => 'hello',
87 'x-content-custom' => 'hello'
93 /**
94 * @dataProvider provider_testGetMetadataHeaders
95 * @covers SwiftFileBackend::getMetadataHeaders
97 public function testGetMetadataHeaders( $raw, $sanitized ) {
98 $hdrs = $this->backend->getMetadataHeaders( $raw );
100 $this->assertEquals( $hdrs, $sanitized, 'getMetadataHeaders() has expected result' );
103 public static function provider_testGetMetadataHeaders() {
104 return [
107 'content-length' => 345,
108 'content-custom' => 'hello',
109 'x-content-custom' => 'hello',
110 'x-object-meta-custom' => 5,
111 'x-object-meta-sha1Base36' => 'a3deadfg...',
114 'x-object-meta-custom' => 5,
115 'x-object-meta-sha1base36' => 'a3deadfg...',
122 * @dataProvider provider_testGetMetadata
123 * @covers SwiftFileBackend::getMetadata
125 public function testGetMetadata( $raw, $sanitized ) {
126 $hdrs = $this->backend->getMetadata( $raw );
128 $this->assertEquals( $hdrs, $sanitized, 'getMetadata() has expected result' );
131 public static function provider_testGetMetadata() {
132 return [
135 'content-length' => 345,
136 'content-custom' => 'hello',
137 'x-content-custom' => 'hello',
138 'x-object-meta-custom' => 5,
139 'x-object-meta-sha1Base36' => 'a3deadfg...',
142 'custom' => 5,
143 'sha1base36' => 'a3deadfg...',