Merge "Added DBAccessObjectUtils class to avoid duplication"
[lhc/web/wiklou.git] / tests / phpunit / includes / filebackend / SwiftFileBackendTest.php
1 <?php
2
3 /**
4 * @group FileRepo
5 * @group FileBackend
6 * @group medium
7 */
8 class SwiftFileBackendTest extends MediaWikiTestCase {
9 /** @var SwiftFileBackend */
10 private $backend;
11
12 protected function setUp() {
13 parent::setUp();
14
15 $this->backend = TestingAccessWrapper::newFromObject(
16 new SwiftFileBackend( array(
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 ) )
26 );
27 }
28
29 /**
30 * @dataProvider provider_testSanitzeHdrs
31 * @covers SwiftFileBackend::sanitzeHdrs
32 */
33 public function testSanitzeHdrs( $raw, $sanitized ) {
34 $hdrs = $this->backend->sanitizeHdrs( array( 'headers' => $raw ) );
35
36 $this->assertEquals( $hdrs, $sanitized, 'sanitizeHdrs() has expected result' );
37 }
38
39 public static function provider_testSanitzeHdrs() {
40 return array(
41 array(
42 array(
43 'content-length' => 345,
44 'content-type' => 'image+bitmap/jpeg',
45 'content-disposition' => 'inline',
46 'content-duration' => 35.6363,
47 'content-custom' => 'hello',
48 'x-content-custom' => 'hello'
49 ),
50 array(
51 'content-disposition' => 'inline',
52 'content-duration' => 35.6363,
53 'content-custom' => 'hello',
54 'x-content-custom' => 'hello'
55 )
56 ),
57 array(
58 array(
59 'content-length' => 345,
60 'content-type' => 'image+bitmap/jpeg',
61 'content-disposition' => 'inline; filename=xxx; ' . str_repeat( 'o', 1024 ),
62 'content-duration' => 35.6363,
63 'content-custom' => 'hello',
64 'x-content-custom' => 'hello'
65 ),
66 array(
67 'content-disposition' => 'inline;filename=xxx',
68 'content-duration' => 35.6363,
69 'content-custom' => 'hello',
70 'x-content-custom' => 'hello'
71 )
72 ),
73 array(
74 array(
75 'content-length' => 345,
76 'content-type' => 'image+bitmap/jpeg',
77 'content-disposition' => 'filename='. str_repeat( 'o', 1024 ) . ';inline',
78 'content-duration' => 35.6363,
79 'content-custom' => 'hello',
80 'x-content-custom' => 'hello'
81 ),
82 array(
83 'content-disposition' => '',
84 'content-duration' => 35.6363,
85 'content-custom' => 'hello',
86 'x-content-custom' => 'hello'
87 )
88 )
89 );
90 }
91 }