TYPO3 CMS  TYPO3_8-7
L10nModeUpdaterTest.php
Go to the documentation of this file.
1 <?php
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 
25 
30 {
35  {
36  $this->expectException(\RuntimeException::class);
37  $this->expectExceptionCode(1484176136);
38  (new L10nModeUpdater())->hasPotentialUpdateForTable('someTable');
39  }
40 
45  {
46  $GLOBALS['TCA'] = [
47  'testTable' => [
48  'ctrl' => [
49  'languageField' => 'sys_language_uid',
50  'transOrigPointerField' => 'l10n_parent',
51  ],
52  'columns' => [
53  'testField' => [
54  'label' => 'someLabel',
55  'config' => [
56  'type' => 'input',
57  ],
58  ],
59  ],
60  ],
61  ];
62  $subject = new L10nModeUpdater();
63  $this->assertFalse($subject->hasPotentialUpdateForTable('testTable'));
64  }
65 
70  {
71  $GLOBALS['TCA'] = [
72  'testTable' => [
73  'ctrl' => [
74  'languageField' => 'sys_language_uid',
75  'transOrigPointerField' => 'l10n_parent',
76  ],
77  'columns' => [
78  'testField' => [
79  'label' => 'someLabel',
80  'l10n_mode' => 'exclude',
81  'config' => [
82  'type' => 'input',
83  ],
84  ],
85  ],
86  ],
87  ];
88 
89  $connectionPoolProphecy = $this->prophesize(ConnectionPool::class);
90  GeneralUtility::addInstance(ConnectionPool::class, $connectionPoolProphecy->reveal());
91  $queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
92  $connectionPoolProphecy->getQueryBuilderForTable('testTable')->willReturn($queryBuilderProphecy->reveal());
93  $restrictionBuilderProphecy = $this->prophesize(QueryRestrictionContainerInterface::class);
94  $queryBuilderProphecy->getRestrictions()->willReturn($restrictionBuilderProphecy->reveal());
95  $queryBuilderProphecy->from('testTable');
96  $expressionBuilderProphecy = $this->prophesize(ExpressionBuilder::class);
97  $queryBuilderProphecy->expr()->willReturn($expressionBuilderProphecy->reveal());
98  $queryBuilderProphecy->createNamedParameter(Argument::cetera())->willReturnArgument(0);
99  $expressionBuilderProphecy->gt('sys_language_uid', 0);
100  $expressionBuilderProphecy->gt('l10n_parent', 0);
101  $queryBuilderProphecy->select('uid', 'l10n_parent')->willReturn($queryBuilderProphecy->reveal());
102  $queryBuilderProphecy->andWhere(Argument::cetera())->willReturn($queryBuilderProphecy->reveal());
103  $queryBuilderProphecy->execute()->willReturn([
104  [
105  'uid' => 23,
106  'l10n_parent' => 42,
107  ]
108  ]);
109 
110  $subject = new L10nModeUpdater();
111  $this->assertTrue($subject->hasPotentialUpdateForTable('testTable'));
112  }
113 
118  {
119  $GLOBALS['TCA'] = [
120  'testTable' => [
121  'ctrl' => [
122  'languageField' => 'sys_language_uid',
123  'transOrigPointerField' => 'l10n_parent',
124  ],
125  'columns' => [
126  'testField' => [
127  'label' => 'someLabel',
128  'config' => [
129  'type' => 'input',
130  'behaviour' => [
131  'allowLanguageSynchronization' => true,
132  ]
133  ],
134  ],
135  ],
136  ],
137  ];
138 
139  $connectionPoolProphecy = $this->prophesize(ConnectionPool::class);
140  GeneralUtility::addInstance(ConnectionPool::class, $connectionPoolProphecy->reveal());
141  $queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
142  $connectionPoolProphecy->getQueryBuilderForTable('testTable')->willReturn($queryBuilderProphecy->reveal());
143  $restrictionBuilderProphecy = $this->prophesize(QueryRestrictionContainerInterface::class);
144  $queryBuilderProphecy->getRestrictions()->willReturn($restrictionBuilderProphecy->reveal());
145  $queryBuilderProphecy->from('testTable');
146  $expressionBuilderProphecy = $this->prophesize(ExpressionBuilder::class);
147  $queryBuilderProphecy->expr()->willReturn($expressionBuilderProphecy->reveal());
148  $expressionBuilderProphecy = $this->prophesize(ExpressionBuilder::class);
149  $queryBuilderProphecy->expr()->willReturn($expressionBuilderProphecy->reveal());
150  $queryBuilderProphecy->createNamedParameter(Argument::cetera())->willReturnArgument(0);
151  $expressionBuilderProphecy->gt('sys_language_uid', 0);
152  $expressionBuilderProphecy->gt('l10n_parent', 0);
153  $queryBuilderProphecy->select('uid', 'l10n_parent')->willReturn($queryBuilderProphecy->reveal());
154  $queryBuilderProphecy->andWhere(Argument::cetera())->willReturn($queryBuilderProphecy->reveal());
155  $queryBuilderProphecy->execute()->willReturn([
156  [
157  'uid' => 23,
158  'l10n_parent' => 42,
159  ]
160  ]);
161 
162  $subject = new L10nModeUpdater();
163  $this->assertTrue($subject->hasPotentialUpdateForTable('testTable'));
164  }
165 }
static addInstance($className, $instance)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']