-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathPhpcrConsoleDumperHelperTest.php
More file actions
71 lines (61 loc) · 1.86 KB
/
PhpcrConsoleDumperHelperTest.php
File metadata and controls
71 lines (61 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace PHPCR\Tests\Util\Console\Helper;
use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper;
use PHPCR\Util\Console\Helper\TreeDumper\ConsoleDumperPropertyVisitor;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\OutputInterface;
class PhpcrConsoleDumperHelperTest extends TestCase
{
/**
* @var MockObject&OutputInterface
*/
private $outputMock;
/**
* @var PhpcrConsoleDumperHelper
*/
private $helper;
public function setUp(): void
{
$this->outputMock = $this->createMock(OutputInterface::class);
$this->helper = new PhpcrConsoleDumperHelper();
}
/**
* @return array<array<array<string, bool>>>
*/
public function provideHelper(): array
{
return [
[[]],
[['show_props' => true]],
];
}
/**
* @dataProvider provideHelper
*
* @param array<string, bool> $options
*/
public function testGetTreeWalker(array $options): void
{
$options = array_merge([
'dump_uuids' => false,
'ref_format' => 'uuid',
'show_props' => false,
'show_sys_nodes' => false,
], $options);
$tw = $this->helper->getTreeWalker($this->outputMock, $options);
$reflection = new \ReflectionClass($tw);
$propVisitorProp = $reflection->getProperty('propertyVisitor');
// remove when we drop PHP 8.0 support
if (PHP_VERSION_ID < 80100) {
$propVisitorProp->setAccessible(true);
}
$propVisitor = $propVisitorProp->getValue($tw);
if (true === $options['show_props']) {
$this->assertInstanceOf(ConsoleDumperPropertyVisitor::class, $propVisitor);
} else {
$this->assertNull($propVisitor);
}
}
}