TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Authentication;
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 
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
25 
31 {
35  public function getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven()
36  {
38  $connection = $this->prophesize(Connection::class);
39  $connection->getDatabasePlatform()->willReturn(new MockPlatform());
40  $connection->getExpressionBuilder()->willReturn(new ExpressionBuilder($connection->reveal()));
41 
42  // TODO: This should rather be a functional test if we need a query builder
43  // or we should clean up the code itself to not need to mock internal behavior here
44  $queryBuilder = new QueryBuilder(
45  $connection->reveal(),
46  null,
47  $this->prophesize(\Doctrine\DBAL\Query\QueryBuilder::class)->reveal()
48  );
49 
51  $connectionPool = $this->prophesize(ConnectionPool::class);
52  $connectionPool->getQueryBuilderForTable(Argument::cetera())->willReturn($queryBuilder);
53 
54  GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
55 
57  $mock = $this->getMockBuilder(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::class)
58  ->setMethods(['dummy'])
59  ->getMock();
60  $mock->checkPid = true;
61  $mock->checkPid_value = null;
62  $mock->user_table = 'be_users';
63  $result = $mock->getAuthInfoArray();
64  $this->assertEquals('', $result['db_user']['checkPidList']);
65  }
66 }
static addInstance($className, $instance)