FIX Remove deprecation tests, bump deprecation version to 5.0

This commit is contained in:
Robbie Averill 2017-01-05 13:01:46 +13:00
parent 0927e54780
commit cf3a74ec57
2 changed files with 3 additions and 33 deletions

View File

@ -2736,7 +2736,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
} elseif (class_exists($candidate = sprintf('%s_Controller', $class))) {
// Support the legacy underscored filename, but raise a deprecation notice
Deprecation::notice(
'4.0',
'5.0',
'Underscored controller class names are deprecated. Use "MyController" instead of "My_Controller".',
Deprecation::SCOPE_GLOBAL
);

View File

@ -17,7 +17,6 @@ use SilverStripe\Control\Session;
use SilverStripe\View\Parsers\ShortcodeParser;
use SilverStripe\Control\Director;
use SilverStripe\i18n\i18n;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Dev\TestOnly;
use SilverStripe\View\Parsers\HTMLCleaner;
@ -1344,41 +1343,12 @@ class SiteTreeTest extends SapphireTest {
}
/**
* Test that underscored class names (legacy) are still supported, but raise a deprecation notice. The exception and
* manual catching is in place to ensure that we can (A) detect that a deprecation notice was raised and (B) that
* we can restore the old error handling after catching the exception we threw from this test. Simply asserting that
* an exception is thrown will not allow further logic to execute after the exception is thrown.
* Test that underscored class names (legacy) are still supported (deprecation notice is issued though).
*/
public function testGetControllerNameWithUnderscoresIsSupported()
{
$defaultEnabled = Deprecation::get_enabled();
Deprecation::set_enabled(true);
Deprecation::notification_version('4.0.0');
// Catch user_errors thrown by deprecation
set_error_handler(
function ($errno, $errstr) {
throw new \Exception($errstr);
},
E_USER_DEPRECATED
);
$class = new SiteTreeTest_LegacyControllerName;
$notice = '';
try {
$this->assertSame('SiteTreeTest_LegacyControllerName_Controller', $class->getControllerName());
} catch (\Exception $ex) {
$notice = $ex->getMessage();
}
restore_error_handler();
$this->assertContains(
'Underscored controller class names are deprecated. Use "MyController" instead '
. 'of "My_Controller".',
$notice,
'A deprecation notice should have been raised.'
);
Deprecation::set_enabled($defaultEnabled);
$this->assertSame('SiteTreeTest_LegacyControllerName_Controller', $class->getControllerName());
}
}