‪TYPO3CMS  ‪main
CheckValueTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
23 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
29 final class ‪CheckValueTest extends FunctionalTestCase
30 {
31  protected array ‪$testExtensionsToLoad = [
32  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler',
33  ];
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38  $this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefault.csv');
39  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users_admin.csv');
40  $backendUser = $this->setUpBackendUser(1);
41  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
42  }
43 
44  private function ‪insertRecordWithRadioFieldValue($value): array
45  {
46  // pid 88 comes from ImportDefault
47  $actionService = new ActionService();
48  $result = $actionService->createNewRecord('tt_content', 88, [
49  'tx_testdatahandler_radio' => $value,
50  ]);
51  $recordUid = $result['tt_content'][0];
52  return BackendUtility::getRecord('tt_content', $recordUid);
53  }
54 
55  #[Test]
57  {
58  ‪$record = $this->‪insertRecordWithRadioFieldValue('predefined value');
59  self::assertEquals('predefined value', ‪$record['tx_testdatahandler_radio']);
60  }
61 
62  #[Test]
64  {
65  ‪$record = $this->‪insertRecordWithRadioFieldValue('processed value');
66  self::assertEquals('processed value', ‪$record['tx_testdatahandler_radio']);
67  }
68 
69  #[Test]
71  {
72  ‪$record = $this->‪insertRecordWithRadioFieldValue('some other value');
73  self::assertEquals('', ‪$record['tx_testdatahandler_radio']);
74  }
75 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest
Definition: CheckValueTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\radioButtonValueMustBeDefinedInTcaItems
‪radioButtonValueMustBeDefinedInTcaItems()
Definition: CheckValueTest.php:56
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\radioButtonValueIsNotSavedIfNotDefinedInTcaItemsOrProcessingItems
‪radioButtonValueIsNotSavedIfNotDefinedInTcaItemsOrProcessingItems()
Definition: CheckValueTest.php:70
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\radioButtonValueMustComeFromItemsProcFuncIfNotDefinedInTcaItems
‪radioButtonValueMustComeFromItemsProcFuncIfNotDefinedInTcaItems()
Definition: CheckValueTest.php:63
‪TYPO3\CMS\Webhooks\Message\$record
‪identifier readonly int readonly array $record
Definition: PageModificationMessage.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular
Definition: CheckValueTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\setUp
‪setUp()
Definition: CheckValueTest.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\insertRecordWithRadioFieldValue
‪insertRecordWithRadioFieldValue($value)
Definition: CheckValueTest.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\CheckValueTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: CheckValueTest.php:31