mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-29 16:09:40 +02:00
FIX Remove deprecation tests, bump deprecation version to 5.0
This commit is contained in:
parent
0927e54780
commit
cf3a74ec57
|
@ -2736,7 +2736,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
} elseif (class_exists($candidate = sprintf('%s_Controller', $class))) {
|
} elseif (class_exists($candidate = sprintf('%s_Controller', $class))) {
|
||||||
// Support the legacy underscored filename, but raise a deprecation notice
|
// Support the legacy underscored filename, but raise a deprecation notice
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'4.0',
|
'5.0',
|
||||||
'Underscored controller class names are deprecated. Use "MyController" instead of "My_Controller".',
|
'Underscored controller class names are deprecated. Use "MyController" instead of "My_Controller".',
|
||||||
Deprecation::SCOPE_GLOBAL
|
Deprecation::SCOPE_GLOBAL
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,6 @@ use SilverStripe\Control\Session;
|
||||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\View\Parsers\HTMLCleaner;
|
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
|
* Test that underscored class names (legacy) are still supported (deprecation notice is issued though).
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
public function testGetControllerNameWithUnderscoresIsSupported()
|
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;
|
$class = new SiteTreeTest_LegacyControllerName;
|
||||||
$notice = '';
|
|
||||||
try {
|
|
||||||
$this->assertSame('SiteTreeTest_LegacyControllerName_Controller', $class->getControllerName());
|
$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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user