[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / sv / Tests / Unit / AuthenticationServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Sv\Tests\Unit;
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 /**
18 * Testcase for class \TYPO3\CMS\Sv\AuthenticationService
19 *
20 */
21 class AuthenticationServiceTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
22 {
23 /**
24 * Date provider for processLoginReturnsCorrectData
25 *
26 * @return array
27 */
28 public function processLoginDataProvider()
29 {
30 return [
31 'Backend login with securityLevel "normal"' => [
32 'normal',
33 [
34 'status' => 'login',
35 'uname' => 'admin',
36 'uident' => 'password',
37 ],
38 [
39 'status' => 'login',
40 'uname' => 'admin',
41 'uident' => 'password',
42 'uident_text' => 'password',
43 ]
44 ],
45 'Frontend login with securityLevel "normal"' => [
46 'normal',
47 [
48 'status' => 'login',
49 'uname' => 'admin',
50 'uident' => 'password',
51 ],
52 [
53 'status' => 'login',
54 'uname' => 'admin',
55 'uident' => 'password',
56 'uident_text' => 'password',
57 ]
58 ],
59 ];
60 }
61
62 /**
63 * @test
64 * @dataProvider processLoginDataProvider
65 */
66 public function processLoginReturnsCorrectData($passwordSubmissionStrategy, $loginData, $expectedProcessedData)
67 {
68 /** @var $authenticationService \TYPO3\CMS\Sv\AuthenticationService */
69 $authenticationService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Sv\AuthenticationService::class);
70 // Login data is modified by reference
71 $authenticationService->processLoginData($loginData, $passwordSubmissionStrategy);
72 $this->assertEquals($expectedProcessedData, $loginData);
73 }
74 }