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 = '') {
|
public static function notice($atVersion, $string = '') {
|
||||||
if(!Director::isDev()) return;
|
if(!Director::isDev()) return;
|
||||||
|
|
||||||
|
// If you pass #.#, assume #.#.0
|
||||||
|
if(preg_match('/^[0-9]+\.[0-9]+$/', $atVersion)) $atVersion .= '.0';
|
||||||
|
|
||||||
$checkVersion = self::$version;
|
$checkVersion = self::$version;
|
||||||
// Getting a backtrace is slow, so we only do it if we need it
|
// Getting a backtrace is slow, so we only do it if we need it
|
||||||
$backtrace = null;
|
$backtrace = null;
|
||||||
|
@ -25,7 +25,7 @@ class DeprecationTest extends SapphireTest {
|
|||||||
|
|
||||||
function testLesserVersionTriggersNoNotice() {
|
function testLesserVersionTriggersNoNotice() {
|
||||||
Deprecation::notification_version('1.0.0');
|
Deprecation::notification_version('1.0.0');
|
||||||
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
Deprecation::notice('2.0', 'Deprecation test failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,12 +36,18 @@ class DeprecationTest extends SapphireTest {
|
|||||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
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
|
* @expectedException PHPUnit_Framework_Error_Notice
|
||||||
*/
|
*/
|
||||||
function testGreaterVersionTriggersNotice() {
|
function testGreaterVersionTriggersNotice() {
|
||||||
Deprecation::notification_version('3.0.0');
|
Deprecation::notification_version('3.0.0');
|
||||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
Deprecation::notice('2.0', 'Deprecation test passed');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
||||||
@ -61,7 +67,7 @@ class DeprecationTest extends SapphireTest {
|
|||||||
|
|
||||||
protected function callThatOriginatesFromSapphire() {
|
protected function callThatOriginatesFromSapphire() {
|
||||||
$this->assertEquals(DeprecationTest_Deprecation::get_module(), 'sapphire');
|
$this->assertEquals(DeprecationTest_Deprecation::get_module(), 'sapphire');
|
||||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
Deprecation::notice('2.0', 'Deprecation test passed');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMethodNameCalculation() {
|
function testMethodNameCalculation() {
|
||||||
|
Loading…
Reference in New Issue
Block a user