Debian Codegraph @

tests/phpunit/integration/includes/utils/MWFilePropsTest.php

raw symbols SCIP
1 <?php
2
3 use Wikimedia\FileBackend\FileBackend;
4
5 /**
6 * @covers \MWFileProps
7 */
8 class MWFilePropsTest extends MediaWikiIntegrationTestCase {
9 public static function provideGetPropsFromPath() {
10 return [
11 'nonexistent.png' => [ 'nonexistent.png', [
12 'fileExists' => false,
13 'size' => 0,
14 'file-mime' => null,
15 'major_mime' => null,
16 'minor_mime' => null,
17 'mime' => null,
18 'sha1' => '',
19 'metadata' => [],
20 'width' => 0,
21 'height' => 0,
22 'bits' => 0,
23 'media_type' => 'UNKNOWN',
24 ] ],
25 'zip-kind-of-valid.png' => [ 'zip-kind-of-valid.png', [
26 'fileExists' => true,
27 'size' => 189,
28 'file-mime' => 'application/zip',
29 'major_mime' => 'application',
30 'minor_mime' => 'zip',
31 'mime' => 'application/zip',
32 'sha1' => 'rt7k3bexfau9i8jd5z41oxi3fqz7psb',
33 'metadata' => [],
34 'width' => 0,
35 'height' => 0,
36 'bits' => 0,
37 'media_type' => 'ARCHIVE',
38 ] ],
39 'tinyrgb.jpg' => [ 'tinyrgb.jpg', [
40 'width' => 120,
41 'height' => 78,
42 'bits' => 8,
43 'fileExists' => true,
44 'size' => 5118,
45 'file-mime' => 'image/jpeg',
46 'major_mime' => 'image',
47 'minor_mime' => 'jpeg',
48 'mime' => 'image/jpeg',
49 'sha1' => 'iqrl77mbbzax718nogdpirzfodf7meh',
50 'metadata' => [
51 'JPEGFileComment' => [
52 'File source: http://127.0.0.1:8080/wiki/File:Srgb_copy.jpg',
53 ],
54 'MEDIAWIKI_EXIF_VERSION' => 2,
55 ],
56 'media_type' => 'BITMAP',
57 ] ],
58 ];
59 }
60
61 /**
62 * @dataProvider provideGetPropsFromPath
63 * @param string $relPath
64 * @param array $expected
65 */
66 public function testGetPropsFromPath( $relPath, $expected ) {
67 $mwfp = new MWFileProps(
68 $this->getServiceContainer()->getMimeAnalyzer()
69 );
70 $path = __DIR__ . '/../../../data/media/' . $relPath;
71
72 $props = $mwfp->getPropsFromPath( $path, FileBackend::extensionFromPath( $path ) );
73 $this->assertArrayEquals( $expected, $props, false, true );
74 }
75 }