Passed
Pull Request — master (#17)
by
unknown
01:30
created

testDetectMaxAllowedUploadsPerBatch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleBatchUpload;
4
5
use User;
0 ignored issues
show
Bug introduced by
The type User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * Class SimpleBatchUploadTest
9
 * @package SimpleBatchUpload
10
 * @group   Database
11
 */
12
class SimpleBatchUploadTest extends \MediaWikiTestCase {
0 ignored issues
show
Bug introduced by
The type MediaWikiTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
	protected function setUp() {
15
		parent::setUp();
16
		$this->setMwGlobals(
17
			[
18
				'wgSimpleBatchUploadMaxFilesPerBatch' => [
19
					'*' => 1,
20
					'user' => 2,
21
					'sysop' => 3
22
				]
23
			]
24
		);
25
	}
26
27
	/**
28
	 * @covers       SimpleBatchUpload\SimpleBatchUpload::detectMaxAllowedUploadsPerBatch
29
	 * @dataProvider provideTestDetectMaxAllowedUploadsPerBatch
30
	 */
31
	public function testDetectMaxAllowedUploadsPerBatch( $groups, $expectation ) {
32
		$sbu = new SimpleBatchUpload();
33
		if ( $groups !== false ) {
34
			$testUser = self::getTestUser( $groups );
35
			$limit = $sbu->getMaxFilesPerBatch( $testUser->getUser() );
36
		} else {
37
			$testUser = User::newFromId( 0 );
38
			$limit = $sbu->getMaxFilesPerBatch( $testUser );
39
		}
40
		$this->assertEquals( $expectation, $limit );
41
	}
42
43
	public static function provideTestDetectMaxAllowedUploadsPerBatch() {
44
		return [
45
			[ false, 1 ],
46
			[ [], 2 ],
47
			[ [ 'user' ], 2 ],
48
			[ [ 'sysop' ], 3 ],
49
			[ [ 'bureaucrat' ], 2 ],
50
			[ [ 'random' ], 2 ]
51
		];
52
	}
53
54
}
55