diff --git a/dev/Deprecation.php b/dev/Deprecation.php index 623b21a91..d52735dcc 100644 --- a/dev/Deprecation.php +++ b/dev/Deprecation.php @@ -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; diff --git a/tests/dev/DeprecationTest.php b/tests/dev/DeprecationTest.php index b36b05aa2..fb5247929 100644 --- a/tests/dev/DeprecationTest.php +++ b/tests/dev/DeprecationTest.php @@ -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() {