mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Add test for backtrace class checking method.
This commit is contained in:
parent
74e5a94b32
commit
86cf404944
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Dev\Tests;
|
namespace SilverStripe\Dev\Tests;
|
||||||
|
|
||||||
|
use ReflectionMethod;
|
||||||
|
use SilverStripe\Core\BaseKernel;
|
||||||
|
use SilverStripe\Core\CoreKernel;
|
||||||
|
use SilverStripe\Core\Kernel;
|
||||||
use SilverStripe\Dev\Backtrace;
|
use SilverStripe\Dev\Backtrace;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class BacktraceTest extends SapphireTest
|
class BacktraceTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -109,4 +114,56 @@ class BacktraceTest extends SapphireTest
|
|||||||
$this->assertEquals('<filtered>', $filtered[1]['args']['password']);
|
$this->assertEquals('<filtered>', $filtered[1]['args']['password']);
|
||||||
$this->assertEquals('myval', $filtered[2]['args']['myarg']);
|
$this->assertEquals('myval', $filtered[2]['args']['myarg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function matchesFilterableClassProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'anything',
|
||||||
|
'*',
|
||||||
|
true,
|
||||||
|
'Wildcard counts as a match',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
DataObject::class,
|
||||||
|
BaseKernel::class,
|
||||||
|
false,
|
||||||
|
'No match',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
DataObject::class,
|
||||||
|
DataObject::class,
|
||||||
|
true,
|
||||||
|
'Exact match',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
CoreKernel::class,
|
||||||
|
BaseKernel::class,
|
||||||
|
true,
|
||||||
|
'Subclass counts as a match',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
BaseKernel::class,
|
||||||
|
CoreKernel::class,
|
||||||
|
false,
|
||||||
|
'Superclass does not count as a match',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
CoreKernel::class,
|
||||||
|
Kernel::class,
|
||||||
|
true,
|
||||||
|
'Implements interface counts as a match',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider matchesFilterableClassProvider
|
||||||
|
*/
|
||||||
|
public function testMatchesFilterableClass(string $className, string $filterableClass, bool $expected, string $message): void
|
||||||
|
{
|
||||||
|
$reflectionMethod = new ReflectionMethod(Backtrace::class . '::matchesFilterableClass');
|
||||||
|
$reflectionMethod->setAccessible(true);
|
||||||
|
$this->assertSame($expected, $reflectionMethod->invoke(null, $className, $filterableClass), $message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user