-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathWorkspaceCreateCommandTest.php
More file actions
88 lines (69 loc) · 2.5 KB
/
WorkspaceCreateCommandTest.php
File metadata and controls
88 lines (69 loc) · 2.5 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
<?php
declare(strict_types=1);
namespace PHPCR\Tests\Util\Console\Command;
use PHPCR\RepositoryInterface;
use PHPCR\Util\Console\Command\WorkspaceCreateCommand;
class WorkspaceCreateCommandTest extends BaseCommandTest
{
public function setUp(): void
{
parent::setUp();
$this->addCommand(new WorkspaceCreateCommand());
}
public function testCreate(): void
{
$this->session->expects($this->once())
->method('getWorkspace')
->willReturn($this->workspace);
$this->session->expects($this->once())
->method('getRepository')
->willReturn($this->repository);
$this->repository->expects($this->once())
->method('getDescriptor')
->with(RepositoryInterface::OPTION_WORKSPACE_MANAGEMENT_SUPPORTED)
->willReturn(true);
$this->workspace->expects($this->once())
->method('createWorkspace')
->with('test_workspace');
$this->workspace->expects($this->once())
->method('getAccessibleWorkspaceNames')
->willReturn(['default']);
$this->executeCommand('phpcr:workspace:create', [
'name' => 'test_workspace',
]);
}
/**
* Handle trying to create existing workspace.
*/
public function testCreateExisting(): void
{
$this->session->expects($this->exactly(2))
->method('getWorkspace')
->willReturn($this->workspace);
$this->session->expects($this->exactly(2))
->method('getRepository')
->willReturn($this->repository);
$this->repository->expects($this->exactly(2))
->method('getDescriptor')
->with(RepositoryInterface::OPTION_WORKSPACE_MANAGEMENT_SUPPORTED)
->willReturn(true);
$this->workspace->expects($this->exactly(2))
->method('getAccessibleWorkspaceNames')
->willReturn(['default', 'test']);
$tester = $this->executeCommand(
'phpcr:workspace:create',
['name' => 'test'],
2
);
$this->assertStringContainsString('already has a workspace called "test"', $tester->getDisplay());
$tester = $this->executeCommand(
'phpcr:workspace:create',
[
'name' => 'test',
'--ignore-existing' => true,
],
0
);
$this->assertStringContainsString('already has a workspace called "test"', $tester->getDisplay());
}
}