TYPO3 CMS  TYPO3_8-7
AbstractUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
25 
29 class AbstractUserAuthenticationTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
30 {
34  public function getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven()
35  {
37  $connection = $this->prophesize(Connection::class);
38  $connection->getDatabasePlatform()->willReturn(new MockPlatform());
39  $connection->getExpressionBuilder()->willReturn(new ExpressionBuilder($connection->reveal()));
40 
41  // TODO: This should rather be a functional test if we need a query builder
42  // or we should clean up the code itself to not need to mock internal behavior here
43  $queryBuilder = new QueryBuilder(
44  $connection->reveal(),
45  null,
46  $this->prophesize(\Doctrine\DBAL\Query\QueryBuilder::class)->reveal()
47  );
48 
50  $connectionPool = $this->prophesize(ConnectionPool::class);
51  $connectionPool->getQueryBuilderForTable(Argument::cetera())->willReturn($queryBuilder);
52 
53  GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
54 
56  $mock = $this->getMockBuilder(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::class)
57  ->setMethods(['dummy'])
58  ->getMock();
59  $mock->checkPid = true;
60  $mock->checkPid_value = null;
61  $mock->user_table = 'be_users';
62  $result = $mock->getAuthInfoArray();
63  $this->assertEquals('', $result['db_user']['checkPidList']);
64  }
65 }
static addInstance($className, $instance)