2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\CMS\Core\Tests\UnitTestCase;
71 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1438594829);
72 $this->subject->addData($input);
97 $languageService = $this->prophesize(LanguageService::class);
98 $GLOBALS[
'LANG'] = $languageService->reveal();
99 $languageService->sL(Argument::cetera())->willReturnArgument(0);
102 $this->assertSame($expected, $this->subject->addData($input));
124 $this->setExpectedException(\UnexpectedValueException::class, $this->any(), 1438607163);
125 $this->subject->addData($input);
141 'funnyKey' =>
'funnyValue',
149 $this->setExpectedException(\UnexpectedValueException::class, $this->any(), 1438607164);
150 $this->subject->addData($input);
174 $this->setExpectedException(\UnexpectedValueException::class, $this->any(), 1438607165);
175 $this->subject->addData($input);
181 public function addDataTranslatesItemLabels()
202 $languageService = $this->prophesize(LanguageService::class);
203 $GLOBALS[
'LANG'] = $languageService->reveal();
205 $languageService->sL(
'aLabel')->shouldBeCalled()->willReturn(
'translated');
208 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][0] =
'translated';
210 $this->assertSame($expected, $this->subject->addData($input));
211 $this->subject->addData($input);
220 'tableName' =>
'aTable',
228 'itemsProcFunc' =>
function (array $parameters, $pObj) {
229 $parameters[
'items'] = [
239 $expected[
'processedTca'][
'columns'][
'aField'][
'config'] = [
245 $this->assertSame($expected, $this->subject->addData($input));
251 public function addDataItemsProcFuncReceivesParameters()
254 'tableName' =>
'aTable',
256 'aField' =>
'aValue',
262 'itemsProcFunc.' => [
263 'itemParamKey' =>
'itemParamValue',
281 'itemsProcFunc' =>
function (array $parameters, $pObj) {
282 if ($parameters[
'items'] !== [ 0 => [
'foo',
'bar'] ]
283 || $parameters[
'config'][
'aKey'] !==
'aValue'
284 || $parameters[
'TSconfig'] !== [
'itemParamKey' =>
'itemParamValue' ]
285 || $parameters[
'table'] !==
'aTable'
286 || $parameters[
'row'] !== [
'aField' =>
'aValue' ]
287 || $parameters[
'field'] !==
'aField'
289 throw new \UnexpectedValueException(
'broken', 1438604329);
298 $languageService = $this->prophesize(LanguageService::class);
299 $GLOBALS[
'LANG'] = $languageService->reveal();
300 $languageService->sL(Argument::cetera())->willReturnArgument(0);
302 $flashMessage = $this->prophesize(FlashMessage::class);
305 $flashMessageService = $this->prophesize(FlashMessageService::class);
308 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
309 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
312 $flashMessageQueue->enqueue($flashMessage)->shouldNotBeCalled();
314 $this->subject->addData($input);
320 public function addDataItemsProcFuncEnqueuesFlashMessageOnException()
323 'tableName' =>
'aTable',
325 'aField' =>
'aValue',
331 'itemsProcFunc.' => [
332 'itemParamKey' =>
'itemParamValue',
350 'itemsProcFunc' =>
function (array $parameters, $pObj) {
351 throw new \UnexpectedValueException(
'anException', 1438604329);
359 $languageService = $this->prophesize(LanguageService::class);
360 $GLOBALS[
'LANG'] = $languageService->reveal();
362 $flashMessage = $this->prophesize(FlashMessage::class);
365 $flashMessageService = $this->prophesize(FlashMessageService::class);
368 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
369 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
371 $flashMessageQueue->enqueue($flashMessage)->shouldBeCalled();
373 $this->subject->addData($input);
379 public function addDataTranslatesItemLabelsFromPageTsConfig()
382 'tableName' =>
'aTable',
403 0 =>
'labelOverride',
412 $languageService = $this->prophesize(LanguageService::class);
413 $GLOBALS[
'LANG'] = $languageService->reveal();
414 $languageService->sL(
'aLabel')->willReturnArgument(0);
416 $languageService->sL(
'labelOverride')->shouldBeCalled()->willReturnArgument(0);
419 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][0] =
'labelOverride';
421 $this->assertSame($expected, $this->subject->addData($input));
422 $this->subject->addData($input);