mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
3ee8f505b7
The main benefit of this is so that authors who make use of .editorconfig don't end up with whitespace changes in their PRs. Spaces vs. tabs has been left alone, although that could do with a tidy-up in SS4 after the switch to PSR-1/2. The command used was this: for match in '*.ss' '*.css' '*.scss' '*.html' '*.yml' '*.php' '*.js' '*.csv' '*.inc' '*.php5'; do find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" -exec sed -E -i '' 's/[[:space:]]+$//' {} \+ find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" | xargs perl -pi -e 's/ +$//' done
110 lines
3.3 KiB
PHP
110 lines
3.3 KiB
PHP
<?php
|
|
|
|
class DeprecationTest_Deprecation extends Deprecation {
|
|
public static function get_module() {
|
|
return self::get_calling_module_from_trace(debug_backtrace(0));
|
|
}
|
|
|
|
public static function get_method() {
|
|
return self::get_called_method_from_trace(debug_backtrace(0));
|
|
}
|
|
}
|
|
|
|
class DeprecationTest extends SapphireTest {
|
|
|
|
static $originalVersionInfo;
|
|
|
|
public function setUp() {
|
|
parent::setUp();
|
|
|
|
self::$originalVersionInfo = Deprecation::dump_settings();
|
|
Deprecation::$notice_level = E_USER_NOTICE;
|
|
Deprecation::set_enabled(true);
|
|
}
|
|
|
|
public function tearDown() {
|
|
Deprecation::restore_settings(self::$originalVersionInfo);
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function testLesserVersionTriggersNoNotice() {
|
|
Deprecation::notification_version('1.0.0');
|
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
*/
|
|
public function testEqualVersionTriggersNotice() {
|
|
Deprecation::notification_version('2.0.0');
|
|
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
|
}
|
|
|
|
public function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum() {
|
|
Deprecation::notification_version('2.0.0-beta1');
|
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
|
$this->assertNull(Deprecation::notice('2.0.0', 'Deprecation test failed'));
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
*/
|
|
public function testGreaterVersionTriggersNotice() {
|
|
Deprecation::notification_version('3.0.0');
|
|
Deprecation::notice('2.0', 'Deprecation test passed');
|
|
}
|
|
|
|
public function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
|
Deprecation::notification_version('1.0.0');
|
|
global $project;
|
|
Deprecation::notification_version('3.0.0', $project);
|
|
$this->callThatOriginatesFromFramework();
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
*/
|
|
public function testMatchingModuleNotifcationVersionAffectsNotice() {
|
|
Deprecation::notification_version('1.0.0');
|
|
Deprecation::notification_version('3.0.0', FRAMEWORK_DIR);
|
|
$this->callThatOriginatesFromFramework();
|
|
}
|
|
|
|
public function testMethodNameCalculation() {
|
|
$this->assertEquals(DeprecationTest_Deprecation::get_method(), 'DeprecationTest->testMethodNameCalculation');
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
* @expectedExceptionMessage DeprecationTest->testScopeMethod is deprecated. Method scope
|
|
*/
|
|
public function testScopeMethod() {
|
|
Deprecation::notification_version('2.0.0');
|
|
Deprecation::notice('2.0.0', 'Method scope', Deprecation::SCOPE_METHOD);
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
* @expectedExceptionMessage DeprecationTest is deprecated. Class scope
|
|
*/
|
|
public function testScopeClass() {
|
|
Deprecation::notification_version('2.0.0');
|
|
Deprecation::notice('2.0.0', 'Class scope', Deprecation::SCOPE_CLASS);
|
|
}
|
|
|
|
/**
|
|
* @expectedException PHPUnit_Framework_Error
|
|
* @expectedExceptionMessage Global scope
|
|
*/
|
|
public function testScopeGlobal() {
|
|
Deprecation::notification_version('2.0.0');
|
|
Deprecation::notice('2.0.0', 'Global scope', Deprecation::SCOPE_GLOBAL);
|
|
}
|
|
|
|
protected function callThatOriginatesFromFramework() {
|
|
$this->assertEquals(DeprecationTest_Deprecation::get_module(), FRAMEWORK_DIR);
|
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test passed'));
|
|
}
|
|
|
|
}
|