mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: Allow Deprecation::notice() to be called without passing release number.
This commit is contained in:
parent
95b6490ffa
commit
4c93c3be19
@ -110,6 +110,9 @@ class Deprecation {
|
||||
public static function notice($atVersion, $string = '') {
|
||||
if(!Director::isDev()) return;
|
||||
|
||||
// If you pass #.#, assume #.#.0
|
||||
if(preg_match('/^[0-9]+\.[0-9]+$/', $atVersion)) $atVersion .= '.0';
|
||||
|
||||
$checkVersion = self::$version;
|
||||
// Getting a backtrace is slow, so we only do it if we need it
|
||||
$backtrace = null;
|
||||
|
@ -25,23 +25,29 @@ class DeprecationTest extends SapphireTest {
|
||||
|
||||
function testLesserVersionTriggersNoNotice() {
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
||||
Deprecation::notice('2.0', 'Deprecation test failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
*/
|
||||
function testEqualVersionTriggersNotice() {
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum() {
|
||||
Deprecation::notification_version('2.0.0-beta1');
|
||||
Deprecation::notice('2.0', 'Deprecation test failed');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
*/
|
||||
function testGreaterVersionTriggersNotice() {
|
||||
Deprecation::notification_version('3.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
Deprecation::notice('2.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
||||
@ -61,7 +67,7 @@ class DeprecationTest extends SapphireTest {
|
||||
|
||||
protected function callThatOriginatesFromSapphire() {
|
||||
$this->assertEquals(DeprecationTest_Deprecation::get_module(), 'sapphire');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
Deprecation::notice('2.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
function testMethodNameCalculation() {
|
||||
|
Loading…
Reference in New Issue
Block a user