2011-10-27 23:45:12 +02:00
|
|
|
<?php
|
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\Dev\Tests;
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\Deprecation;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
2016-10-14 03:30:05 +02:00
|
|
|
use SilverStripe\Dev\Tests\DeprecationTest\TestDeprecation;
|
2011-10-27 23:45:12 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
class DeprecationTest extends SapphireTest
|
|
|
|
{
|
2021-10-27 04:39:47 +02:00
|
|
|
protected function tearDown(): void
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
2022-10-20 02:14:58 +02:00
|
|
|
Deprecation::$notice_level = E_USER_DEPRECATED;
|
|
|
|
Deprecation::disable();
|
2016-12-16 05:34:21 +01:00
|
|
|
parent::tearDown();
|
|
|
|
}
|
2011-10-27 23:45:12 +02:00
|
|
|
|
2022-10-20 02:14:58 +02:00
|
|
|
public function testNotice()
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
2022-10-20 02:14:58 +02:00
|
|
|
$message = implode(' ', [
|
|
|
|
'SilverStripe\Dev\Tests\DeprecationTest->testNotice is deprecated.',
|
|
|
|
'My message.',
|
|
|
|
'Called from PHPUnit\Framework\TestCase->runTest.'
|
|
|
|
]);
|
2021-10-27 04:39:47 +02:00
|
|
|
$this->expectError();
|
2022-10-20 02:14:58 +02:00
|
|
|
$this->expectErrorMessage($message);
|
|
|
|
Deprecation::$notice_level = E_USER_NOTICE;
|
|
|
|
Deprecation::enable();
|
|
|
|
Deprecation::notice('1.2.3', 'My message');
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
|
|
|
|
2022-10-20 02:14:58 +02:00
|
|
|
/**
|
|
|
|
* @doesNotPerformAssertions
|
|
|
|
*/
|
|
|
|
public function testDisabled()
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
2022-10-20 02:14:58 +02:00
|
|
|
Deprecation::$notice_level = E_USER_NOTICE;
|
|
|
|
// test that no error error is raised because by default Deprecation is disabled
|
|
|
|
Deprecation::notice('4.5.6', 'My message');
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
2011-10-27 23:45:12 +02:00
|
|
|
}
|