2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Prophecy\ObjectProphecy;
20 use TYPO3\CMS\Core\Tests\UnitTestCase;
48 'recordTypeValue' =>
'aType',
52 'showitem' =>
'--palette--;aPalette;2,bField,cField'
57 'showitem' =>
'aField',
58 'canNotCollapse' =>
true
63 'displayCond' =>
'FIELD:cField:=:0',
69 'displayCond' =>
'FIELD:cField:=:1',
84 unset($expected[
'processedTca'][
'columns'][
'aField']);
86 $this->assertSame($expected, $this->subject->addData($input));
138 'displayCond' =>
'FIELD:mmType:!=:audio',
146 'sheetTitle' =>
'sGeneral',
153 'sheetTitle' =>
'sVideo',
154 'displayCond' =>
'FIELD:sGeneral.mmType:!=:audio',
161 'sheetTitle' =>
'sAudio',
162 'displayCond' =>
'FIELD:sGeneral.mmType:=:audio',
174 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'ds'][
'sheets'][
'sAudio']);
175 $this->assertSame($expected, $this->subject->addData($input));
207 'ds_pointerField' =>
'list_type,CType',
222 'displayCond' =>
'FIELD:mmType:!=:audio',
230 'displayCond' =>
'FIELD:mmType:=:audio',
238 'sheetTitle' =>
'aTitle',
252 'sheetTitle' =>
'bTitle',
264 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'ds'][
'sheets'][
'sGeneral'][
'ROOT'][
'el'][
'mmUseHTML5']);
266 $this->assertSame($expected, $this->subject->addData($input));
272 public function matchHideForNonAdminsReturnsTrueIfBackendUserIsAdmin()
279 'displayCond' =>
'HIDE_FOR_NON_ADMINS',
289 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
290 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
291 $backendUserProphecy->isAdmin()->shouldBeCalled()->willReturn(
true);
295 $this->assertSame($expected, $this->subject->addData($input));
301 public function matchHideForNonAdminsReturnsFalseIfBackendUserIsNotAdmin()
308 'displayCond' =>
'HIDE_FOR_NON_ADMINS',
318 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
319 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
320 $backendUserProphecy->isAdmin()->shouldBeCalled()->willReturn(
false);
323 unset($expected[
'processedTca'][
'columns'][
'aField']);
324 $this->assertSame($expected, $this->subject->addData($input));
339 'displayCond' =>
'HIDE_L10N_SIBLINGS',
350 $this->assertSame($expected, $this->subject->addData($input));
363 'displayCond' =>
'HIDE_L10N_SIBLINGS:except_admin',
374 $this->assertSame($expected, $this->subject->addData($input));
389 'Invalid condition string' => [
394 'Not loaded extension compares to loaded as FALSE' => [
395 'EXT:neverloadedext:LOADED:TRUE',
399 'Not loaded extension compares to not loaded as TRUE' => [
400 'EXT:neverloadedext:LOADED:FALSE',
404 'Loaded extension compares to TRUE' => [
405 'EXT:backend:LOADED:TRUE',
409 'Loaded extension compares to FALSE' => [
410 'EXT:backend:LOADED:FALSE',
414 'Field is not greater zero if not given' => [
419 'Field is not equal 0 if not given' => [
424 'Field value string comparison' => [
429 'Field value string comparison against list' => [
430 'FIELD:foo:IN:bar,baz',
434 'Field value comparison of 1 against multi-value field of 5 returns true' => [
435 'FIELD:content:BIT:1',
439 'Field value comparison of 2 against multi-value field of 5 returns false' => [
440 'FIELD:content:BIT:2',
444 'Field value of 5 negated comparison against multi-value field of 5 returns false' => [
445 'FIELD:content:!BIT:5',
449 'Field value comparison for required value is false for different value' => [
450 'FIELD:foo:REQ:FALSE',
454 'Field value string not equal comparison' => [
459 'Field value string not equal comparison against list' => [
460 'FIELD:foo:!IN:bar,baz',
464 'Field value in range' => [
469 'Field value greater than' => [
474 'Field is value for default language without flexform' => [
475 'HIDE_L10N_SIBLINGS',
479 'New is TRUE for new comparison with TRUE' => [
484 'New is FALSE for new comparison with FALSE' => [
489 'New is FALSE for not new element' => [
494 'New is TRUE for not new element compared to FALSE' => [
499 'Version is TRUE for versioned row' => [
507 'Version is TRUE for not versioned row compared with FALSE' => [
515 'Version is TRUE for NULL row compared with TRUE' => [
523 'Multiple conditions with AND compare to TRUE if all are OK' => [
526 'FIELD:testField:>:9',
527 'FIELD:testField:<:11',
535 'Multiple conditions with AND compare to FALSE if one fails' => [
538 'FIELD:testField:>:9',
539 'FIELD:testField:<:11',
547 'Multiple conditions with OR compare to TRUE if one is OK' => [
550 'FIELD:testField:<:9',
551 'FIELD:testField:<:11',
559 'Multiple conditions with OR compare to FALSE is all fail' => [
562 'FIELD:testField:<:9',
563 'FIELD:testField:<:11',
571 'Multiple conditions without operator due to misconfiguration compare to TRUE' => [
574 'FIELD:testField:<:9',
575 'FIELD:testField:>:11',
583 'Multiple nested conditions evaluate to TRUE' => [
586 'FIELD:testField:>:9',
588 'FIELD:testField:<:100',
589 'FIELD:testField:>:-100',
598 'Multiple nested conditions evaluate to FALSE' => [
601 'FIELD:testField:>:9',
603 'FIELD:testField:<:100',
604 'FIELD:testField:>:-100',
626 'databaseRow' => $record,
630 'displayCond' => $condition,
640 if (!$expectedResult) {
641 unset($expected[
'processedTca'][
'columns'][
'testField']);
643 $this->assertSame($expected, $this->subject->addData($input));
660 'displayCond' => $condition,
668 $input[
'databaseRow'] = $record ?: [
'testField' => [
'key' => $record[
'testField']]];
671 if (!$expectedResult) {
672 unset($expected[
'processedTca'][
'columns'][
'testField']);
674 $this->assertSame($expected, $this->subject->addData($input));
689 'Flexform value invalid comparison' => [
703 'Flexform value valid comparison' => [
704 'FIELD:parentRec.foo:=:bar',
730 'databaseRow' => $record,
744 'displayCond' => $condition,
761 if (!$expectedResult) {
762 unset($expected[
'processedTca'][
'columns'][
'testField'][
'config'][
'ds'][
'sheets'][
'sDEF'][
'ROOT'][
'el'][
'flexTestField']);
764 $this->assertSame($expected, $this->subject->addData($input));
779 'flex.TestField' => [
801 'flex.TestField' => [
813 'sheetTitle' =>
'sVideo',
814 'displayCond' =>
'FIELD:sDEF.flex.TestField:!=:0',
826 unset($expected[
'processedTca'][
'columns'][
'testField'][
'config'][
'ds'][
'sheets'][
'sTest']);
827 $this->assertSame($expected, $this->subject->addData($input));