2015-11-22 20:17:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
2021-03-28 18:57:32 +00:00
|
|
|
namespace MediaWiki\Tests\Unit\Auth;
|
2015-11-22 20:17:00 +00:00
|
|
|
|
2021-04-16 13:17:10 +00:00
|
|
|
use Config;
|
2021-03-28 18:57:32 +00:00
|
|
|
use MediaWiki\Auth\AbstractAuthenticationProvider;
|
|
|
|
|
use MediaWiki\Auth\AuthManager;
|
2021-04-16 13:17:10 +00:00
|
|
|
use MediaWiki\HookContainer\HookContainer;
|
|
|
|
|
use MediaWiki\User\UserNameUtils;
|
|
|
|
|
use Psr\Log\LoggerInterface;
|
2017-04-19 19:37:35 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
2015-11-22 20:17:00 +00:00
|
|
|
/**
|
|
|
|
|
* @group AuthManager
|
2018-11-01 11:48:52 +00:00
|
|
|
* @covers \MediaWiki\Auth\AbstractAuthenticationProvider
|
2015-11-22 20:17:00 +00:00
|
|
|
*/
|
2021-03-28 18:57:32 +00:00
|
|
|
class AbstractAuthenticationProviderTest extends \MediaWikiUnitTestCase {
|
2021-05-13 16:02:38 +00:00
|
|
|
use AuthenticationProviderTestTrait;
|
|
|
|
|
|
2015-11-22 20:17:00 +00:00
|
|
|
public function testAbstractAuthenticationProvider() {
|
2021-05-28 12:16:14 +00:00
|
|
|
$this->hideDeprecated( 'MediaWiki\Auth\AbstractAuthenticationProvider::setConfig' );
|
|
|
|
|
$this->hideDeprecated( 'MediaWiki\Auth\AbstractAuthenticationProvider::setLogger' );
|
|
|
|
|
$this->hideDeprecated( 'MediaWiki\Auth\AbstractAuthenticationProvider::setManager' );
|
|
|
|
|
$this->hideDeprecated( 'MediaWiki\Auth\AbstractAuthenticationProvider::setHookContainer' );
|
|
|
|
|
|
2015-11-22 20:17:00 +00:00
|
|
|
$provider = $this->getMockForAbstractClass( AbstractAuthenticationProvider::class );
|
2017-04-19 19:37:35 +00:00
|
|
|
$providerPriv = TestingAccessWrapper::newFromObject( $provider );
|
2015-11-22 20:17:00 +00:00
|
|
|
|
2021-04-16 13:17:10 +00:00
|
|
|
// test AbstractAuthenticationProvider::init
|
|
|
|
|
$logger = $this->getMockForAbstractClass( LoggerInterface::class );
|
|
|
|
|
$authManager = $this->createMock( AuthManager::class );
|
|
|
|
|
$hookContainer = $this->createMock( HookContainer::class );
|
|
|
|
|
$config = $this->getMockForAbstractClass( Config::class );
|
|
|
|
|
$userNameUtils = $this->createNoOpMock( UserNameUtils::class );
|
2021-05-13 16:02:38 +00:00
|
|
|
$this->initProvider( $provider, $config, $logger, $authManager, $hookContainer, $userNameUtils );
|
2021-04-16 13:17:10 +00:00
|
|
|
$this->assertSame( $logger, $providerPriv->logger );
|
|
|
|
|
$this->assertSame( $authManager, $providerPriv->manager );
|
|
|
|
|
$this->assertSame( $hookContainer, $providerPriv->hookContainer );
|
|
|
|
|
$this->assertSame( $config, $providerPriv->config );
|
|
|
|
|
$this->assertSame( $userNameUtils, $providerPriv->userNameUtils );
|
|
|
|
|
|
|
|
|
|
// test AbstractAuthenticationProvider::setLogger
|
|
|
|
|
$obj = $this->getMockForAbstractClass( LoggerInterface::class );
|
2015-11-22 20:17:00 +00:00
|
|
|
$provider->setLogger( $obj );
|
|
|
|
|
$this->assertSame( $obj, $providerPriv->logger, 'setLogger' );
|
|
|
|
|
|
2021-04-16 13:17:10 +00:00
|
|
|
// test AbstractAuthenticationProvider::setManager
|
2021-03-28 18:57:32 +00:00
|
|
|
$obj = $this->createMock( AuthManager::class );
|
2015-11-22 20:17:00 +00:00
|
|
|
$provider->setManager( $obj );
|
|
|
|
|
$this->assertSame( $obj, $providerPriv->manager, 'setManager' );
|
|
|
|
|
|
2021-04-16 13:17:10 +00:00
|
|
|
// test AbstractAuthenticationProvider::setConfig
|
|
|
|
|
$obj = $this->getMockForAbstractClass( Config::class );
|
2015-11-22 20:17:00 +00:00
|
|
|
$provider->setConfig( $obj );
|
|
|
|
|
$this->assertSame( $obj, $providerPriv->config, 'setConfig' );
|
|
|
|
|
|
2021-05-28 12:16:14 +00:00
|
|
|
// test AbstractAuthenticationProvider::setHookContainer
|
|
|
|
|
$obj = $this->createHookContainer();
|
|
|
|
|
$provider->setHookContainer( $obj );
|
|
|
|
|
$this->assertSame( $obj, $providerPriv->hookContainer, 'setHookContainer' );
|
|
|
|
|
|
2021-04-16 13:17:10 +00:00
|
|
|
// test AbstractAuthenticationProvider::getUniqueId
|
2019-12-13 17:44:39 +00:00
|
|
|
$this->assertIsString( $provider->getUniqueId(), 'getUniqueId' );
|
2015-11-22 20:17:00 +00:00
|
|
|
}
|
|
|
|
|
}
|