Debian Codegraph @

tests/phpunit/unit/includes/user/TempUser/TempUserCreatorTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Unit\User\TempUser;
4
5 use MediaWiki\Permissions\Authority;
6 use MediaWiki\Tests\Unit\MockServiceDependenciesTrait;
7 use MediaWiki\User\TempUser\RealTempUserConfig;
8 use MediaWiki\User\TempUser\TempUserCreator;
9 use MediaWikiUnitTestCase;
10
11 /**
12 * @covers \MediaWiki\User\TempUser\TempUserCreator
13 */
14 class TempUserCreatorTest extends MediaWikiUnitTestCase {
15
16 use MockServiceDependenciesTrait;
17
18 /** @dataProvider providePassThroughMethods */
19 public function testPassThroughMethods( $methodName, $mockArguments = [] ) {
20 // Tests methods in the TempUserCreator class that pass through to
21 // the TempUserConfig methods with the same name.
22 $mockTempUserConfig = $this->createMock( RealTempUserConfig::class );
23 $mockTempUserConfig->expects( $this->once() )
24 ->method( $methodName )
25 ->with( ...$mockArguments );
26 $objectUnderTest = $this->newServiceInstance( TempUserCreator::class, [
27 'config' => $mockTempUserConfig
28 ] );
29 $objectUnderTest->$methodName( ...$mockArguments );
30 }
31
32 public static function providePassThroughMethods() {
33 return [
34 'isEnabled' => [ 'isEnabled' ],
35 'isAutoCreateAction' => [ 'isAutoCreateAction', [ 'mock-action' ] ],
36 'isTempName' => [ 'isTempName', [ 'mock-name' ] ],
37 'isReservedName' => [ 'isReservedName', [ 'mock-name' ] ],
38 'getPlaceholderName' => [ 'getPlaceholderName' ],
39 'getMatchPattern' => [ 'getMatchPattern' ],
40 'getMatchPatterns' => [ 'getMatchPatterns' ],
41 'getExpireAfterDays' => [ 'getExpireAfterDays' ],
42 'getNotifyBeforeExpirationDays' => [ 'getNotifyBeforeExpirationDays' ],
43 ];
44 }
45
46 public function testShouldAutoCreate() {
47 $this->testPassThroughMethods(
48 'shouldAutocreate',
49 [ $this->createMock( Authority::class ), 'mock-action' ]
50 );
51 }
52 }