[SECURITY] Protect Mailtransport
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / Element / GroupElementTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form;
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 TYPO3\CMS\Backend\Form\Element\GroupElement;
19 use TYPO3\CMS\Backend\Form\NodeFactory;
20 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
21 use TYPO3\CMS\Lang\LanguageService;
22
23 /**
24 * Test case
25 */
26 class GroupElementTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
27 {
28 /**
29 * @test
30 */
31 public function renderThrowsExceptionIfDbRecordsDoNotContainTableName()
32 {
33 $data = [
34 'parameterArray' => [
35 'fieldConf' => [
36 'config' => [
37 'allowed' => 'aForeignTable',
38 'internal_type' => 'db',
39 'show_thumbs' => true,
40 ],
41 ],
42 // This should trigger the exception, a correct value would be 'aForeignTable_42|aLabel'
43 'itemFormElValue' => 42
44 ],
45 ];
46
47 $languageService = $this->prophesize(LanguageService::class);
48 $GLOBALS['LANG'] = $languageService->reveal();
49 $languageService->sL(Argument::cetera())->willReturnArgument(0);
50 $backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class);
51 $GLOBALS['BE_USER'] = $backendUserAuthentication->reveal();
52 $backendUserAuthentication->getPagePermsClause(1)->willReturn(1);
53
54 $nodeFactoryProphecy = $this->prophesize(NodeFactory::class);
55 $subject = new GroupElement($nodeFactoryProphecy->reveal(), $data);
56
57 $this->expectException(\RuntimeException::class);
58 $this->expectExceptionCode(1468149217);
59
60 $subject->render();
61 }
62 }