2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Prophecy\ObjectProphecy;
18 use TYPO3\CMS\Backend\Form\Exception\DatabaseDefaultLanguageException;
22 use TYPO3\CMS\Core\Tests\UnitTestCase;
42 $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
43 $GLOBALS[
'TYPO3_DB'] = $this->dbProphecy->reveal();
54 'tableName' =>
'tt_content',
64 $this->assertEquals($input, $this->subject->addData($input));
73 'tableName' =>
'tt_content',
76 'text' =>
'localized text',
77 'sys_language_uid' => 2,
82 'languageField' =>
'sys_language_uid',
83 'transOrigPointerField' =>
'l10n_parent',
89 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
90 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=23')->shouldBeCalled()->willReturn(null);
92 $this->setExpectedException(DatabaseDefaultLanguageException::class, $this->anything(), 1438249426);
94 $this->subject->addData($input);
103 'tableName' =>
'tt_content',
106 'text' =>
'localized text',
107 'sys_language_uid' => 2,
112 'languageField' =>
'sys_language_uid',
113 'transOrigPointerField' =>
'l10n_parent',
118 $defaultLanguageRow = [
120 'text' =>
'default language text',
121 'sys_language_uid' => 0,
124 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
125 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=23')->shouldBeCalled()->willReturn($defaultLanguageRow);
128 $expected[
'defaultLanguageRow'] = $defaultLanguageRow;
130 $this->assertEquals($expected, $this->subject->addData($input));
140 'text' =>
'field content of default lang record when lang overlay was created',
144 'tableName' =>
'tt_content',
147 'text' =>
'localized text',
148 'sys_language_uid' => 2,
150 'l10n_diffsource' => serialize($diffSource),
154 'languageField' =>
'sys_language_uid',
155 'transOrigPointerField' =>
'l10n_parent',
156 'transOrigDiffSourceField' =>
'l10n_diffsource',
159 'defaultLanguageRow' => null,
162 $defaultLanguageRow = [
164 'text' =>
'default language text',
165 'sys_language_uid' => 0,
168 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
169 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=23')->shouldBeCalled()->willReturn($defaultLanguageRow);
172 $expected[
'defaultLanguageRow'] = $defaultLanguageRow;
173 $expected[
'defaultLanguageDiffRow'] = $diffSource;
175 $this->assertEquals($expected, $this->subject->addData($input));
181 public function addDataSetsAdditionalLanguageRowsIfRequestedInUserTypoScript()
184 'tableName' =>
'tt_content',
187 'text' =>
'localized text',
188 'sys_language_uid' => 2,
193 'languageField' =>
'sys_language_uid',
194 'transOrigPointerField' =>
'l10n_parent',
199 'additionalPreviewLanguages' =>
'3',
202 'systemLanguageRows' => [
205 'title' =>
'Default Language',
214 'defaultLanguageRow' => null,
215 'additionalLanguageRows' => [],
218 $translationResult = [
226 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
227 $recordWsolResult = [
229 'text' =>
'localized text in french',
232 $defaultLanguageRow = [
234 'text' =>
'default language text',
235 'sys_language_uid' => 0,
238 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
239 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=23')->shouldBeCalled()->willReturn($defaultLanguageRow);
242 $translationProphecy = $this->prophesize(TranslationConfigurationProvider::class);
244 $translationProphecy->translationInfo(
'tt_content', 23, 3)->shouldBeCalled()->willReturn($translationResult);
247 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=43')->shouldBeCalled()->willReturn($recordWsolResult);
250 $expected[
'defaultLanguageRow'] = $defaultLanguageRow;
251 $expected[
'additionalLanguageRows'] = [
254 'text' =>
'localized text in french',
258 $this->assertEquals($expected, $this->subject->addData($input));
264 public function addDataSetsDoesNotAddHandledRowAsAdditionalLanguageRows()
267 'tableName' =>
'tt_content',
270 'text' =>
'localized text',
271 'sys_language_uid' => 2,
276 'languageField' =>
'sys_language_uid',
277 'transOrigPointerField' =>
'l10n_parent',
282 'additionalPreviewLanguages' =>
'2,3',
285 'systemLanguageRows' => [
288 'title' =>
'Default Language',
302 'defaultLanguageRow' => null,
303 'additionalLanguageRows' => [],
306 $translationResult = [
314 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
315 $recordWsolResult = [
317 'text' =>
'localized text in french',
320 $defaultLanguageRow = [
322 'text' =>
'default language text',
323 'sys_language_uid' => 0,
326 $GLOBALS[
'TCA'][
'tt_content'] = array(
'foo');
327 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=23')->shouldBeCalled()->willReturn($defaultLanguageRow);
330 $translationProphecy = $this->prophesize(TranslationConfigurationProvider::class);
332 $translationProphecy->translationInfo(
'tt_content', 23, 3)->shouldBeCalled()->willReturn($translationResult);
333 $translationProphecy->translationInfo(
'tt_content', 23, 2)->shouldNotBeCalled();
336 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=43')->shouldBeCalled()->willReturn($recordWsolResult);
339 $expected[
'defaultLanguageRow'] = $defaultLanguageRow;
340 $expected[
'additionalLanguageRows'] = [
343 'text' =>
'localized text in french',
347 $this->assertEquals($expected, $this->subject->addData($input));