‪TYPO3CMS  11.5
AbstractUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Query\QueryBuilder as DoctrineQueryBuilder;
21 use Prophecy\Argument;
22 use Prophecy\PhpUnit\ProphecyTrait;
27 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
30 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
31 
35 class ‪AbstractUserAuthenticationTest extends UnitTestCase
36 {
37  use ProphecyTrait;
38 
43  {
44  $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
45 
46  $connection = $this->prophesize(Connection::class);
47  $connection->getDatabasePlatform()->willReturn(new ‪MockPlatform());
48  $connection->getExpressionBuilder()->willReturn(new ‪ExpressionBuilder($connection->reveal()));
49 
50  // TODO: This should rather be a functional test if we need a query builder
51  // or we should clean up the code itself to not need to mock internal behavior here
52  $queryBuilder = new QueryBuilder(
53  $connection->reveal(),
54  null,
55  $this->prophesize(DoctrineQueryBuilder::class)->reveal()
56  );
57 
58  $connectionPool = $this->prophesize(ConnectionPool::class);
59  $connectionPool->getQueryBuilderForTable(Argument::cetera())->willReturn($queryBuilder);
60 
61  GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
62 
63  $mock = $this->getMockBuilder(AbstractUserAuthentication::class)
64  ->addMethods(['dummy'])
65  ->disableOriginalConstructor()
66  ->getMock();
67  $mock->loginType = 'BE';
68  $mock->checkPid = true;
69  $mock->checkPid_value = null;
70  $mock->user_table = 'be_users';
71  $result = $mock->getAuthInfoArray();
72  self::assertEquals('', $result['db_user']['checkPidList']);
73  }
74 }
‪TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder
Definition: ExpressionBuilder.php:36
‪TYPO3\CMS\Core\Tests\Unit\Authentication
Definition: AbstractUserAuthenticationTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Authentication\AbstractUserAuthenticationTest
Definition: AbstractUserAuthenticationTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Database\Mocks\MockPlatform
Definition: MockPlatform.php:24
‪TYPO3\CMS\Core\Tests\Unit\Authentication\AbstractUserAuthenticationTest\getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven
‪getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven()
Definition: AbstractUserAuthenticationTest.php:41
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:38
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
Definition: AbstractUserAuthentication.php:56