wiki.techinc.nl/tests/phpunit/unit/includes/libs/DebugInfo/PlaceholderTest.php
Tim Starling 94e20db64b Add some helpers to filter properties out of var_dump()
Dumping many kinds of object with var_dump() leads to dumping the whole
address space, because a chain of references leads to MediaWikiServices.

So, introduce a trait which replaces the problematic properties with a
placeholder, if their doc comment contains @noVarDump.

Bug: T277618
Change-Id: Ifa685c26fbc5317d0359544289ec3f433ec4fedf
2022-10-12 12:42:23 -04:00

34 lines
626 B
PHP

<?php
namespace Wikimedia\DebugInfo;
/**
* @covers \Wikimedia\DebugInfo\Placeholder
*/
class PlaceholderTest extends \PHPUnit\Framework\TestCase {
public function provideConstruct() {
return [
[
new \stdClass,
'/^stdClass#[0-9]*$/'
],
[
1,
'/^integer$/'
],
[
'test',
'/^string$/',
]
];
}
/**
* @dataProvider provideConstruct
*/
public function testConstruct( $input, $expected ) {
$placeholder = new Placeholder( $input );
$this->assertInstanceOf( Placeholder::class, $placeholder );
$this->assertMatchesRegularExpression( $expected, $placeholder->desc );
}
}