Commit 2fc9b4bc authored by Adrian Mot's avatar Adrian Mot Committed by Wouter Wolters
Browse files

[TASK] Deprecated methods in unit tests

- Use expectedException() and expectedExceptionCode() instead of
  deprecated setExpectedException()
- Fix a couple of incomplete tests in core/Http section, add some
  and slightly refactor a bit

Resolves: #76159
Releases: master
Change-Id: I3333f94494ce76601a61e4b5286cfef982867f8f
Reviewed-on: https://review.typo3.org/48091

Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Adrian Mot's avatarAdrian Mot <adrian.mot@gmail.com>
Tested-by: Adrian Mot's avatarAdrian Mot <adrian.mot@gmail.com>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent d8e9a943
......@@ -49,7 +49,8 @@ class FormDataCompilerTest extends UnitTestCase
$input = [
'foo' => 'bar',
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1440601540);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1440601540);
$this->subject->compile($input);
}
......@@ -61,7 +62,8 @@ class FormDataCompilerTest extends UnitTestCase
$input = [
'command' => 'unknownCommand',
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437653136);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437653136);
$this->subject->compile($input);
}
......@@ -73,7 +75,8 @@ class FormDataCompilerTest extends UnitTestCase
$input = [
'tableName' => '',
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437654409);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437654409);
$this->subject->compile($input);
}
......@@ -85,7 +88,8 @@ class FormDataCompilerTest extends UnitTestCase
$input = [
'vanillaUid' => 'foo123',
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437654247);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437654247);
$this->subject->compile($input);
}
......@@ -98,7 +102,8 @@ class FormDataCompilerTest extends UnitTestCase
'command' => 'edit',
'vanillaUid' => -100,
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437654332);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437654332);
$this->subject->compile($input);
}
......@@ -139,7 +144,8 @@ class FormDataCompilerTest extends UnitTestCase
public function compileThrowsExceptionIfFormDataGroupDoesNotReturnArray()
{
$this->formDataGroupProphecy->compile(Argument::cetera())->willReturn(null);
$this->setExpectedException(\UnexpectedValueException::class, '', 1446664764);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1446664764);
$this->subject->compile([]);
}
......@@ -153,7 +159,8 @@ class FormDataCompilerTest extends UnitTestCase
unset($result['tableName']);
return $result;
});
$this->setExpectedException(\UnexpectedValueException::class, '', 1438079402);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438079402);
$this->subject->compile([]);
}
......@@ -167,7 +174,8 @@ class FormDataCompilerTest extends UnitTestCase
$result['newKey'] = 'newData';
return $result;
});
$this->setExpectedException(\UnexpectedValueException::class, '', 1438079402);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438079402);
$this->subject->compile([]);
}
}
......@@ -93,7 +93,8 @@ class FlexFormSegmentTest extends UnitTestCase
);
GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
$this->setExpectedException(\UnexpectedValueException::class, '', 1437906441);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437906441);
$this->subject->compile([]);
}
......
......@@ -93,7 +93,8 @@ class InlineParentRecordTest extends UnitTestCase
);
GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
$this->setExpectedException(\UnexpectedValueException::class, '', 1444398947);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1444398947);
$this->subject->compile([]);
}
......
......@@ -41,7 +41,8 @@ class OnTheFlyTest extends UnitTestCase
*/
public function compileThrowsExceptionWithEmptyOnTheFlyList()
{
$this->setExpectedException(\UnexpectedValueException::class, '', 1441108674);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1441108674);
$this->subject->compile([]);
}
......@@ -98,7 +99,8 @@ class OnTheFlyTest extends UnitTestCase
];
$this->subject->setProviderList($providerList);
$this->setExpectedException(\UnexpectedValueException::class, '', 1441108719);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1441108719);
$this->subject->compile([]);
}
}
......@@ -93,7 +93,8 @@ class TcaDatabaseRecordTest extends UnitTestCase
);
GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
$this->setExpectedException(\UnexpectedValueException::class, '', 1437906440);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437906440);
$this->subject->compile([]);
}
......
......@@ -93,7 +93,8 @@ class TcaInputPlaceholderRecordTest extends UnitTestCase
);
GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
$this->setExpectedException(\UnexpectedValueException::class, '', 1443986127);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1443986127);
$this->subject->compile([]);
}
......
......@@ -83,7 +83,8 @@ class DatabaseEditRowTest extends UnitTestCase
$this->dbProphecy->quoteStr($input['tableName'], $input['tableName'])->willReturn($input['tableName']);
$this->dbProphecy->exec_SELECTgetSingleRow('*', 'tt_content', 'uid=' . $input['vanillaUid'])->willReturn($resultRow);
$this->setExpectedException(\UnexpectedValueException::class, '', 1437663061);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437663061);
$this->subject->addData($input);
}
......@@ -99,7 +100,8 @@ class DatabaseEditRowTest extends UnitTestCase
'vanillaUid' => -10,
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437656456);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437656456);
$this->subject->addData($input);
}
......@@ -115,7 +117,8 @@ class DatabaseEditRowTest extends UnitTestCase
'vanillaUid' => 10,
];
$this->setExpectedException(\RuntimeException::class, '', 1437655862);
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1437655862);
$this->subject->addData($input);
}
......@@ -133,7 +136,8 @@ class DatabaseEditRowTest extends UnitTestCase
$this->dbProphecy->quoteStr(Argument::cetera())->willReturn($input['tableName']);
$this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn(false);
$this->setExpectedException(DatabaseRecordException::class, '', 1437656081);
$this->expectException(DatabaseRecordException::class);
$this->expectExceptionCode(1437656081);
$this->subject->addData($input);
}
......@@ -172,7 +176,8 @@ class DatabaseEditRowTest extends UnitTestCase
$this->dbProphecy->quoteStr(Argument::cetera())->willReturn($input['tableName']);
$this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn('invalid result data');
$this->setExpectedException(\UnexpectedValueException::class, '', 1437656323);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437656323);
$this->subject->addData($input);
}
......
......@@ -98,7 +98,8 @@ class DatabaseLanguageRowsTest extends UnitTestCase
$GLOBALS['TCA']['tt_content'] = array('foo');
$this->dbProphecy->exec_SELECTgetSingleRow('*', 'tt_content', 'uid=23')->shouldBeCalled()->willReturn(null);
$this->setExpectedException(DatabaseDefaultLanguageException::class, '', 1438249426);
$this->expectException(DatabaseDefaultLanguageException::class);
$this->expectExceptionCode(1438249426);
$this->subject->addData($input);
}
......
......@@ -51,7 +51,8 @@ class DatabasePageLanguageOverlayRowsTest extends UnitTestCase
{
$this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn(null);
$this->dbProphecy->sql_error(Argument::cetera())->willReturn(null);
$this->setExpectedException(\UnexpectedValueException::class, '', 1440777705);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440777705);
$this->subject->addData(['effectivePid' => 1]);
}
......
......@@ -53,7 +53,8 @@ class DatabaseRecordTypeValueTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438185331);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438185331);
$this->subject->addData($input);
}
......@@ -113,7 +114,8 @@ class DatabaseRecordTypeValueTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438183881);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438183881);
$this->subject->addData($input);
}
......@@ -212,7 +214,8 @@ class DatabaseRecordTypeValueTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438185437);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438185437);
$this->subject->addData($input);
}
......@@ -345,7 +348,8 @@ class DatabaseRecordTypeValueTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1325862241);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1325862241);
$this->subject->addData($input);
}
......@@ -376,7 +380,8 @@ class DatabaseRecordTypeValueTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438253614);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438253614);
$this->subject->addData($input);
}
......
......@@ -70,7 +70,8 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
{
$this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn(null);
$this->dbProphecy->sql_error(Argument::cetera())->willReturn(null);
$this->setExpectedException(\UnexpectedValueException::class, '', 1438170741);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438170741);
$this->subject->addData([]);
}
......
......@@ -58,7 +58,8 @@ class DatabaseUniqueUidNewRowTest extends UnitTestCase
],
];
$this->setExpectedException(\InvalidArgumentException::class, '', 1437991120);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1437991120);
$this->subject->addData($input);
}
......
......@@ -75,7 +75,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->isAdmin()->willReturn(false);
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(false);
$this->setExpectedException(AccessDeniedTableModifyException::class, '', 1437683248);
$this->expectException(AccessDeniedTableModifyException::class);
$this->expectExceptionCode(1437683248);
$this->subject->addData($input);
}
......@@ -97,7 +98,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->beUserProphecy->calcPerms(['pid' => 321])->willReturn(Permission::NOTHING);
$this->setExpectedException(AccessDeniedContentEditException::class, '', 1437679657);
$this->expectException(AccessDeniedContentEditException::class);
$this->expectExceptionCode(1437679657);
$this->subject->addData($input);
}
......@@ -143,7 +145,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->beUserProphecy->calcPerms($input['databaseRow'])->willReturn(Permission::NOTHING);
$this->setExpectedException(AccessDeniedPageEditException::class, '', 1437679336);
$this->expectException(AccessDeniedPageEditException::class);
$this->expectExceptionCode(1437679336);
$this->subject->addData($input);
}
......@@ -214,7 +217,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->beUserProphecy->recordEditAccessInternals($input['tableName'], Argument::cetera())->willReturn(true);
$this->setExpectedException(AccessDeniedRootNodeException::class, '', 1437679856);
$this->expectException(AccessDeniedRootNodeException::class);
$this->expectExceptionCode(1437679856);
$this->subject->addData($input);
}
......@@ -238,7 +242,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->calcPerms($input['parentPageRow'])->willReturn(Permission::ALL);
$this->beUserProphecy->recordEditAccessInternals($input['tableName'], Argument::cetera())->willReturn(false);
$this->setExpectedException(AccessDeniedEditInternalsException::class, '', 1437687404);
$this->expectException(AccessDeniedEditInternalsException::class);
$this->expectExceptionCode(1437687404);
$this->subject->addData($input);
}
......@@ -261,7 +266,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->beUserProphecy->calcPerms($input['parentPageRow'])->willReturn(Permission::NOTHING);
$this->setExpectedException(AccessDeniedContentEditException::class, '', 1437745759);
$this->expectException(AccessDeniedContentEditException::class);
$this->expectExceptionCode(1437745759);
$this->subject->addData($input);
}
......@@ -284,7 +290,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->beUserProphecy->calcPerms($input['parentPageRow'])->willReturn(Permission::NOTHING);
$this->setExpectedException(AccessDeniedPageNewException::class, '', 1437745640);
$this->expectException(AccessDeniedPageNewException::class);
$this->expectExceptionCode(1437745640);
$this->subject->addData($input);
}
......@@ -314,7 +321,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
}
);
$this->setExpectedException(AccessDeniedHookException::class, '', 1437689705);
$this->expectException(AccessDeniedHookException::class);
$this->expectExceptionCode(1437689705);
$this->subject->addData($input);
}
......@@ -433,7 +441,8 @@ class DatabaseUserPermissionCheckTest extends UnitTestCase
$this->beUserProphecy->isAdmin()->willReturn(false);
$this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
$this->setExpectedException(AccessDeniedRootNodeException::class, '', 1437745221);
$this->expectException(AccessDeniedRootNodeException::class);
$this->expectExceptionCode(1437745221);
$this->subject->addData($input);
}
......
......@@ -45,7 +45,8 @@ class InitializeProcessedTcaTest extends UnitTestCase
],
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438594044);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438594044);
$this->subject->addData($input);
}
......@@ -74,7 +75,8 @@ class InitializeProcessedTcaTest extends UnitTestCase
'tableName' => 'aTable',
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1437914223);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437914223);
$this->subject->addData($input);
}
......@@ -88,7 +90,8 @@ class InitializeProcessedTcaTest extends UnitTestCase
'tableName' => 'aTable',
];
$GLOBALS['TCA'][$input['tableName']] = 'foo';
$this->setExpectedException(\UnexpectedValueException::class, '', 1437914223);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1437914223);
$this->subject->addData($input);
}
......
......@@ -101,7 +101,8 @@ class TcaCheckboxItemsTest extends UnitTestCase
],
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1440499337);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440499337);
$this->subject->addData($input);
}
......@@ -126,7 +127,8 @@ class TcaCheckboxItemsTest extends UnitTestCase
],
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1440499338);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440499338);
$this->subject->addData($input);
}
......
......@@ -50,7 +50,8 @@ class TcaColumnsProcessShowitemTest extends UnitTestCase
],
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438614542);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438614542);
$this->subject->addData($input);
}
......
......@@ -226,7 +226,8 @@ class TcaFlexFetchTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1440506893);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440506893);
$this->subject->addData($input);
}
......
......@@ -60,7 +60,8 @@ class TcaFlexPrepareTest extends UnitTestCase
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1440676540);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440676540);
$this->subject->addData($input);
}
......
......@@ -966,7 +966,8 @@ class TcaFlexProcessTest extends UnitTestCase
$this->backendUserProphecy->isAdmin()->willReturn(true);
$this->backendUserProphecy->checkLanguageAccess(Argument::cetera())->willReturn(true);
$this->setExpectedException(\UnexpectedValueException::class, '', 1440685208);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440685208);
$this->subject->addData($input);
}
......@@ -1013,7 +1014,8 @@ class TcaFlexProcessTest extends UnitTestCase
$this->backendUserProphecy->isAdmin()->willReturn(true);
$this->backendUserProphecy->checkLanguageAccess(Argument::cetera())->willReturn(true);
$this->setExpectedException(\UnexpectedValueException::class, '', 1440685208);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1440685208);
$this->subject->addData($input);
}
......@@ -1185,7 +1187,8 @@ class TcaFlexProcessTest extends UnitTestCase
'pageTsConfig' => [],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1458745468);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1458745468);
$this->subject->addData($input);
}
......@@ -1243,7 +1246,8 @@ class TcaFlexProcessTest extends UnitTestCase
'pageTsConfig' => [],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1458745712);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1458745712);
$this->subject->addData($input);
}
......
......@@ -89,7 +89,8 @@ class TcaGroupTest extends UnitTestCase
],
],
];
$this->setExpectedException(\UnexpectedValueException::class, '', 1438780511);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1438780511);
$this->subject->addData($input);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment