-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathNodeDumpCommandTest.php
More file actions
92 lines (73 loc) · 2.44 KB
/
NodeDumpCommandTest.php
File metadata and controls
92 lines (73 loc) · 2.44 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
declare(strict_types=1);
namespace PHPCR\Tests\Util\Console\Command;
use PHPCR\ItemNotFoundException;
use PHPCR\Util\Console\Command\NodeDumpCommand;
use PHPCR\Util\TreeWalker;
use PHPCR\Util\UUIDHelper;
use PHPUnit\Framework\MockObject\MockObject;
class NodeDumpCommandTest extends BaseCommandTest
{
/** @var TreeWalker&MockObject */
protected $treeWalker;
public function setUp(): void
{
parent::setUp();
$this->treeWalker = $this->getMockBuilder(TreeWalker::class)
->disableOriginalConstructor()
->getMock();
$ndCommand = new NodeDumpCommand();
$this->addCommand($ndCommand);
}
public function testCommand(): void
{
$this->dumperHelper
->expects($this->once())
->method('getTreeWalker')
->willReturn($this->treeWalker);
$this->session
->expects($this->once())
->method('getNode')
->with('/')
->willReturn($this->node1);
$this->treeWalker
->expects($this->once())
->method('traverse')
->with($this->node1);
$this->executeCommand('phpcr:node:dump', []);
}
public function testCommandIdentifier(): void
{
$uuid = UUIDHelper::generateUUID();
$this->dumperHelper
->expects($this->once())
->method('getTreeWalker')
->willReturn($this->treeWalker);
$this->session
->expects($this->once())
->method('getNodeByIdentifier')
->with($uuid)
->willReturn($this->node1);
$this->treeWalker
->expects($this->once())
->method('traverse')
->with($this->node1);
$this->executeCommand('phpcr:node:dump', ['identifier' => $uuid]);
}
public function testInvalidRefFormat(): void
{
$this->expectException(\Exception::class);
$this->executeCommand('phpcr:node:dump', ['--ref-format' => 'xy']);
$this->fail('invalid ref-format did not produce exception');
}
public function testNotFound(): void
{
$this->session
->expects($this->once())
->method('getNode')
->with('/')
->will($this->throwException(new ItemNotFoundException()));
$ct = $this->executeCommand('phpcr:node:dump', [], 1);
$this->assertStringContainsString('does not exist', $ct->getDisplay());
}
}