TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
SaltedPasswordServiceTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Saltedpasswords\Tests\Functional;
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 
20 
25 {
26 
32  protected $xmlDatabaseFixtures = [
33  'typo3/sysext/saltedpasswords/Tests/Functional/Fixtures/be_users.xml'
34  ];
35 
39  protected $subject;
40 
46  protected function setUp()
47  {
48  parent::setUp();
49  foreach ($this->xmlDatabaseFixtures as $fixture) {
50  $this->importDataSet($fixture);
51  }
52  $this->subject = GeneralUtility::makeInstance(SaltedPasswordService::class);
53  }
54 
61  {
62  $newPassword = ['password' => '008c5926ca861023c1d2a36653fd88e2'];
63 
64  $this->subject->pObj = new \stdClass();
65  $this->subject->pObj->user_table = 'be_users';
66 
67  $this->callInaccessibleMethod($this->subject, 'updatePassword', 3, $newPassword);
68 
69  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
70 
71  $currentPassword = $queryBuilder
72  ->select('password')
73  ->from('be_users')
74  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(3, \PDO::PARAM_INT)))
75  ->execute()
76  ->fetchColumn();
77 
78  $this->assertEquals($newPassword['password'], $currentPassword);
79  }
80 }
callInaccessibleMethod($object, $name,...$arguments)
static makeInstance($className,...$constructorArguments)