51 $this->backEndUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
52 $this->mockDatabaseConnection = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(),
'', FALSE);
54 $this->subject = new \TYPO3\CMS\Core\DataHandling\DataHandler();
55 $this->subject->start(array(),
'', $this->backEndUser);
70 $this->assertTrue($this->subject instanceof \
TYPO3\CMS\Core\DataHandling\
DataHandler);
80 $this->subject->admin = TRUE;
81 $this->assertTrue($this->subject->checkModifyAccessList(
'tt_content'));
88 $this->subject->admin = FALSE;
89 $this->assertFalse($this->subject->checkModifyAccessList(
'tt_content'));
96 $this->subject->admin = FALSE;
97 $this->backEndUser->groupData[
'tables_modify'] =
'tt_content';
98 $this->assertTrue($this->subject->checkModifyAccessList(
'tt_content'));
105 $this->subject->admin = TRUE;
106 $this->assertTrue($this->subject->checkModifyAccessList(
'be_users'));
113 $this->subject->admin = FALSE;
114 $this->assertFalse($this->subject->checkModifyAccessList(
'be_users'));
129 $this->subject->admin = FALSE;
130 $this->backEndUser->groupData[
'tables_modify'] = $tableName;
131 $this->assertFalse($this->subject->checkModifyAccessList($tableName));
141 '1000,10' =>
'1000.10',
142 '1000,0' =>
'1000.00',
143 '600.000.000,00' =>
'600000000.00',
144 '60aaa00' =>
'6000.00' 146 foreach ($testData as $value => $expectedReturnValue) {
147 $returnValue = $this->subject->checkValue_input_Eval($value, array(
'double2'),
'');
148 $this->assertSame($returnValue[
'value'], $expectedReturnValue);
159 '"0" returns zero as integer' => array(
163 '"-1999999" is interpreted correctly as -1999999 and is lot lower then -200000' => array(
167 '"3000000" is interpreted correctly as 3000000 but is higher then 200000 and set to 200000' => array(
179 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(),
'', FALSE);
180 $tcaFieldConf = array(
184 'lower' =>
'-2000000',
188 $returnValue = $this->subject->checkValue_input(array(), $value, $tcaFieldConf, array());
189 $this->assertSame($returnValue[
'value'], $expectedReturnValue);
197 'dbType = date' => array(
200 'dbType = datetime' => array(
212 $tcaFieldConf = array(
216 $this->mockDatabaseConnection->expects($this->never())->method(
'getDateTimeFormats');
217 $this->subject->checkValue_input(array(),
'', $tcaFieldConf, array());
226 $dateTimeFormats = array(
228 'empty' =>
'0000-00-00',
232 'empty' =>
'0000-00-00 00:00:00',
233 'format' =>
'Y-m-d H:i:s' 236 $tcaFieldConf = array(
240 $this->mockDatabaseConnection->expects($this->once())->method(
'getDateTimeFormats')->willReturn($dateTimeFormats);
241 $this->subject->checkValue_input(array(), $dateTimeFormats[$dbType][
'empty'], $tcaFieldConf,
'', 0,
'');
249 'tca without dbType' => array(
254 'tca with dbType != date/datetime' => array(
269 $this->mockDatabaseConnection->expects($this->never())->method(
'getDateTimeFormats');
270 $this->subject->checkValue_input(array(),
'', $tcaFieldConf, array());
286 eval(
'class ' . $hookClass .
' {}');
287 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'][] = $hookClass;
288 $this->subject->checkModifyAccessList(
'tt_content');
298 $hookMock = $this->getMock(
'TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface', array(
'checkModifyAccessList'), array(), $hookClass);
299 $hookMock->expects($this->once())->method(
'checkModifyAccessList');
300 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'][] = $hookClass;
301 $GLOBALS[
'T3_VAR'][
'getUserObj'][$hookClass] = $hookMock;
302 $this->subject->checkModifyAccessList(
'tt_content');
313 class ' . $hookClass .
' implements \\TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface { 314 public function checkModifyAccessList(&$accessAllowed, $table, \\TYPO3\\CMS\\Core\\DataHandling\\DataHandler $parent) { $accessAllowed = TRUE; } 317 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'][] = $hookClass;
318 $this->assertTrue($this->subject->checkModifyAccessList(
'tt_content'));
328 $fixture = $this->getMock(
'TYPO3\\CMS\\Core\\DataHandling\\DataHandler', array(
'newlog'));
329 $this->backEndUser->workspace = 1;
330 $this->backEndUser->workspaceRec = array(
'freeze' => TRUE);
332 $this->assertFalse($fixture->process_datamap());
338 public function processDatamapWhenEditingRecordInWorkspaceCreatesNewRecordInWorkspace() {
341 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processDatamapClass'] = array();
343 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
347 'columns' => array(),
353 'TYPO3\\CMS\\Core\\DataHandling\\DataHandler',
354 array(
'newlog',
'checkModifyAccessList',
'tableReadOnly',
'checkRecordUpdateAccess')
356 $subject->bypassWorkspaceRestrictions = FALSE;
364 $subject->expects($this->once())->method(
'checkModifyAccessList')->with(
'pages')->will($this->returnValue(TRUE));
365 $subject->expects($this->once())->method(
'tableReadOnly')->with(
'pages')->will($this->returnValue(FALSE));
366 $subject->expects($this->once())->method(
'checkRecordUpdateAccess')->will($this->returnValue(TRUE));
367 $backEndUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
370 $backEndUser->expects($this->once())->method(
'workspaceAllowAutoCreation')->will($this->returnValue(TRUE));
371 $backEndUser->expects($this->once())->method(
'workspaceCannotEditRecord')->will($this->returnValue(TRUE));
372 $backEndUser->expects($this->once())->method(
'recordEditAccessInternals')->with(
'pages', 1)->will($this->returnValue(TRUE));
374 $createdTceMain = $this->getMock(
'TYPO3\\CMS\\Core\\DataHandling\\DataHandler', array());
375 $createdTceMain->expects($this->once())->method(
'start')->with(array(), array(
381 'label' =>
'Auto-created for WS #1' 386 $createdTceMain->expects($this->never())->method(
'process_datamap');
387 $createdTceMain->expects($this->once())->method(
'process_cmdmap');
396 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(),
'', FALSE);
398 $hookMock = $this->getMock($hookClass, array(
'checkFlexFormValue_beforeMerge'));
399 $hookMock->expects($this->once())->method(
'checkFlexFormValue_beforeMerge');
400 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkFlexFormValue'][] = $hookClass;
401 $GLOBALS[
'T3_VAR'][
'getUserObj'][$hookClass] = $hookMock;
402 $this->subject->checkValue_flex(array(), array(), array(), array(), array(),
'');
412 $backendUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
413 $backendUser->expects($this->once())->method(
'writelog');
414 $this->subject->enableLogging = TRUE;
415 $this->subject->BE_USER = $backendUser;
416 $this->subject->log(
'', 23, 0, 42, 0,
'details');
423 $backendUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
424 $backendUser->expects($this->never())->method(
'writelog');
425 $this->subject->enableLogging = FALSE;
426 $this->subject->BE_USER = $backendUser;
427 $this->subject->log(
'', 23, 0, 42, 0,
'details');
434 $backendUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
435 $this->subject->BE_USER = $backendUser;
436 $this->subject->enableLogging = TRUE;
437 $this->subject->errorLog = array();
439 $this->subject->log(
'', 23, 0, 42, 1, $logDetailsUnique);
440 $this->assertStringEndsWith($logDetailsUnique, $this->subject->errorLog[0]);
447 $backendUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
448 $this->subject->BE_USER = $backendUser;
449 $this->subject->enableLogging = TRUE;
450 $this->subject->errorLog = array();
452 $this->subject->log(
'', 23, 0, 42, 1,
'%1$s' . $logDetails .
'%2$s', -1, array(
'foo',
'bar'));
453 $expected =
'foo' . $logDetails .
'bar';
454 $this->assertStringEndsWith($expected, $this->subject->errorLog[0]);
470 'isSubmittedValueEqualToStoredValue',
471 $submittedValue, $storedValue, $storedType, $allowNull
473 $this->assertEquals($expected,
$result);
482 'string value "" vs. ""' => array(
484 '',
'',
'string', FALSE
486 'string value 0 vs. "0"' => array(
488 0,
'0',
'string', FALSE
490 'string value 1 vs. "1"' => array(
492 1,
'1',
'string', FALSE
494 'string value "0" vs. ""' => array(
496 '0',
'',
'string', FALSE
498 'string value 0 vs. ""' => array(
500 0,
'',
'string', FALSE
502 'string value null vs. ""' => array(
504 NULL,
'',
'string', FALSE
507 'integer value 0 vs. 0' => array(
511 'integer value "0" vs. "0"' => array(
513 '0',
'0',
'int', FALSE
515 'integer value 0 vs. "0"' => array(
519 'integer value "" vs. "0"' => array(
521 '',
'0',
'int', FALSE
523 'integer value "" vs. 0' => array(
527 'integer value "0" vs. 0' => array(
531 'integer value 1 vs. 1' => array(
535 'integer value 1 vs. "1"' => array(
539 'integer value "1" vs. "1"' => array(
541 '1',
'1',
'int', FALSE
543 'integer value "1" vs. 1' => array(
547 'integer value "0" vs. "1"' => array(
549 '0',
'1',
'int', FALSE
552 'string with allowed null value "" vs. ""' => array(
554 '',
'',
'string', TRUE
556 'string with allowed null value 0 vs. "0"' => array(
558 0,
'0',
'string', TRUE
560 'string with allowed null value 1 vs. "1"' => array(
562 1,
'1',
'string', TRUE
564 'string with allowed null value "0" vs. ""' => array(
566 '0',
'',
'string', TRUE
568 'string with allowed null value 0 vs. ""' => array(
570 0,
'',
'string', TRUE
572 'string with allowed null value null vs. ""' => array(
574 NULL,
'',
'string', TRUE
576 'string with allowed null value "" vs. null' => array(
578 '', NULL,
'string', TRUE
580 'string with allowed null value null vs. null' => array(
582 NULL, NULL,
'string', TRUE
585 'integer with allowed null value 0 vs. 0' => array(
589 'integer with allowed null value "0" vs. "0"' => array(
591 '0',
'0',
'int', TRUE
593 'integer with allowed null value 0 vs. "0"' => array(
597 'integer with allowed null value "" vs. "0"' => array(
601 'integer with allowed null value "" vs. 0' => array(
605 'integer with allowed null value "0" vs. 0' => array(
609 'integer with allowed null value 1 vs. 1' => array(
613 'integer with allowed null value "1" vs. "1"' => array(
615 '1',
'1',
'int', TRUE
617 'integer with allowed null value "1" vs. 1' => array(
621 'integer with allowed null value 1 vs. "1"' => array(
625 'integer with allowed null value "0" vs. "1"' => array(
627 '0',
'1',
'int', TRUE
629 'integer with allowed null value null vs. ""' => array(
631 NULL,
'',
'int', TRUE
633 'integer with allowed null value "" vs. null' => array(
635 '', NULL,
'int', TRUE
637 'integer with allowed null value null vs. null' => array(
639 NULL, NULL,
'int', TRUE
641 'integer with allowed null value null vs. "0"' => array(
643 NULL,
'0',
'int', TRUE
645 'integer with allowed null value null vs. 0' => array(
649 'integer with allowed null value "0" vs. null' => array(
651 '0', NULL,
'int', TRUE
663 $table =
'phpunit_dummy';
666 'TYPO3\\CMS\\Core\\DataHandling\\DataHandler',
670 $backendUser = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
675 $GLOBALS[
'TCA'][$table][
'ctrl'] = array(
'label' =>
'dummy');
676 $GLOBALS[
'TCA'][$table][
'columns'] = array(
684 $this->assertEquals($expected,
$subject->_call(
'getPlaceholderTitleForTableLabel', $table));
705 '[PLACEHOLDER, WS#1]',
714 public function deletePagesOnRootLevelIsDenied() {
716 $dataHandlerMock = $this->getMock(
'TYPO3\\CMS\\Core\\DataHandling\\DataHandler', array(
'canDeletePage',
'newlog2'));
718 ->expects($this->never())
719 ->method(
'canDeletePage');
721 ->expects($this->once())
723 ->with(
'Deleting all pages starting from the root-page is disabled.',
'pages', 0, 0, 2);
725 $dataHandlerMock->deletePages(0);
731 public function deleteRecord_procBasedOnFieldTypeRespectsEnableCascadingDelete() {
735 'foreign_table' => $this->
getUniqueId(
'foreign_foo_'),
736 'behaviour' => array(
737 'enableCascadingDelete' => 0,
742 $mockRelationHandler = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\RelationHandler', array(), array(),
'', FALSE);
743 $mockRelationHandler->itemArray = array(
744 '1' => array(
'table' => $this->
getUniqueId(
'bar_'),
'id' => 67)
748 $mockDataHandler = $this->
getAccessibleMock(
'TYPO3\\CMS\\Core\\DataHandling\\DataHandler', array(
'getInlineFieldType',
'deleteAction',
'createRelationHandlerInstance'), array(),
'', FALSE);
749 $mockDataHandler->expects($this->once())->method(
'getInlineFieldType')->will($this->returnValue(
'field'));
750 $mockDataHandler->expects($this->once())->method(
'createRelationHandlerInstance')->will($this->returnValue($mockRelationHandler));
751 $mockDataHandler->expects($this->never())->method(
'deleteAction');
752 $mockDataHandler->deleteRecord_procBasedOnFieldType($table, 42,
'foo',
'bar', $conf);
760 'None item selected' => array(
764 'All items selected' => array(
768 'Item 1 and 2 are selected' => array(
772 'Value is higher than allowed' => array(
776 'Negative value' => array(
791 $expectedResult = array(
792 'value' => $expectedValue
795 $tcaFieldConfiguration = array(
802 $this->assertSame($expectedResult, $this->subject->checkValue_check(
$result, $value, $tcaFieldConfiguration, array()));
static getSingletonInstances()
inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFields($tcaFieldConf)
checkValue_checkReturnsExpectedValuesDataProvider()
static addInstance($className, $instance)
inputValueCheckCallsNotGetDateTimeFormatsForDatetimeFieldsWithEmptyValue($dbType)
logDoesNotCallWriteLogOfBackendUserIfLoggingIsDisabled()
nonAdminIsNotAllowedToModifyAdminTable()
checkValue_checkReturnsExpectedValues($value, $expectedValue)
adminIsAllowedToModifyNonAdminTable()
inputValueCheckCallsGetDateTimeFormatsForDatetimeFieldsDataProvider()
callInaccessibleMethod($object, $name)
equalSubmittedAndStoredValuesAreDeterminedDataProvider()
nonAdminWithTableModifyAccessIsNotAllowedToModifyAdminTable()
doesCheckModifyAccessListHookModifyAccessAllowed()
equalSubmittedAndStoredValuesAreDetermined($expected, $submittedValue, $storedValue, $storedType, $allowNull)
static resetSingletonInstances(array $newSingletonInstances)
getPlaceholderTitleForTableLabelReturnsLabelThatsMatchesLabelFieldConditions($expected, $eval)
doesCheckModifyAccessListHookGetsCalled()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
nonAdminIsNorAllowedToModifyNonAdminTable()
inputValueCheckRecognizesStringValuesAsIntegerValuesCorrectly($value, $expectedReturnValue)
logFormatsDetailMessageWithAdditionalDataInLocalErrorArray()
inputValuesStringsDataProvider()
inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFieldsDataProvider()
doesCheckModifyAccessListThrowExceptionOnWrongHookInterface()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
logCallsWriteLogOfBackendUserIfLoggingIsEnabled()
getPlaceholderTitleForTableLabelReturnsLabelThatsMatchesLabelFieldConditionsDataProvider()
inputValueCheckCallsGetDateTimeFormatsForDatetimeFieldsWithNonEmptyValue($dbType)
adminIsAllowedToModifyAdminTable()
doesCheckFlexFormValueHookGetsCalled()
logAddsEntryToLocalErrorLogArray()
nonAdminWithTableModifyAccessIsAllowedToModifyNonAdminTable()
processDatamapForFrozenNonZeroWorkspaceReturnsFalse()