2011-10-27 23:45:12 +02:00
|
|
|
<?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;
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
self::$originalVersionInfo = Deprecation::dump_settings();
|
|
|
|
Deprecation::$notice_level = E_USER_NOTICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
function tearDown() {
|
|
|
|
Deprecation::restore_settings(self::$originalVersionInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLesserVersionTriggersNoNotice() {
|
|
|
|
Deprecation::notification_version('1.0.0');
|
2011-10-29 00:59:41 +02:00
|
|
|
Deprecation::notice('2.0', 'Deprecation test failed');
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-14 02:43:45 +01:00
|
|
|
* @expectedException PHPUnit_Framework_Error
|
2011-10-27 23:45:12 +02:00
|
|
|
*/
|
|
|
|
function testEqualVersionTriggersNotice() {
|
|
|
|
Deprecation::notification_version('2.0.0');
|
|
|
|
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
|
|
|
}
|
|
|
|
|
2011-10-29 00:59:41 +02:00
|
|
|
function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum() {
|
|
|
|
Deprecation::notification_version('2.0.0-beta1');
|
|
|
|
Deprecation::notice('2.0', 'Deprecation test failed');
|
|
|
|
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
|
|
|
}
|
|
|
|
|
2011-10-27 23:45:12 +02:00
|
|
|
/**
|
2012-03-14 02:43:45 +01:00
|
|
|
* @expectedException PHPUnit_Framework_Error
|
2011-10-27 23:45:12 +02:00
|
|
|
*/
|
|
|
|
function testGreaterVersionTriggersNotice() {
|
|
|
|
Deprecation::notification_version('3.0.0');
|
2011-10-29 00:59:41 +02:00
|
|
|
Deprecation::notice('2.0', 'Deprecation test passed');
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
|
|
|
Deprecation::notification_version('1.0.0');
|
2012-04-14 03:25:40 +02:00
|
|
|
global $project;
|
|
|
|
Deprecation::notification_version('3.0.0', $project);
|
2012-03-24 04:38:57 +01:00
|
|
|
$this->callThatOriginatesFromFramework();
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-14 02:43:45 +01:00
|
|
|
* @expectedException PHPUnit_Framework_Error
|
2011-10-27 23:45:12 +02:00
|
|
|
*/
|
|
|
|
function testMatchingModuleNotifcationVersionAffectsNotice() {
|
|
|
|
Deprecation::notification_version('1.0.0');
|
2012-04-14 03:25:40 +02:00
|
|
|
Deprecation::notification_version('3.0.0', FRAMEWORK_DIR);
|
2012-03-24 04:38:57 +01:00
|
|
|
$this->callThatOriginatesFromFramework();
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|
|
|
|
|
2012-03-24 04:38:57 +01:00
|
|
|
protected function callThatOriginatesFromFramework() {
|
2012-04-14 03:25:40 +02:00
|
|
|
$this->assertEquals(DeprecationTest_Deprecation::get_module(), FRAMEWORK_DIR);
|
2011-10-29 00:59:41 +02:00
|
|
|
Deprecation::notice('2.0', 'Deprecation test passed');
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testMethodNameCalculation() {
|
|
|
|
$this->assertEquals(DeprecationTest_Deprecation::get_method(), 'DeprecationTest->testMethodNameCalculation');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|