Skip to content

Commit d4c8c02

Browse files
committed
Add ignore-existing option to create workspace command
1 parent e840edd commit d4c8c02

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/PHPCR/Util/Console/Command/WorkspaceCreateCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function configure()
3030
->setName('phpcr:workspace:create')
3131
->addArgument('name', InputArgument::REQUIRED, 'Name of the workspace to create')
3232
->addOption(
33-
'silent-on-exist',
33+
'ignore-existing',
3434
null,
3535
InputOption::VALUE_NONE,
3636
'If set, an existing workspace will return a success code'
@@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7272
sprintf('<comment>This repository already has a workspace called "%s"</comment>', $workspaceName)
7373
);
7474

75-
return $input->getOption('silent-on-exist') ? 0 : 2;
75+
return $input->getOption('ignore-existing') ? 0 : 2;
7676
}
7777

7878
$workspace->createWorkspace($workspaceName);

tests/PHPCR/Tests/Util/Console/Command/WorkspaceCreateCommandTest.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ public function testCreate()
4949
*/
5050
public function testCreateExisting()
5151
{
52-
$this->session->expects($this->once())
52+
$this->session->expects($this->exactly(2))
5353
->method('getWorkspace')
5454
->will($this->returnValue($this->workspace))
5555
;
56-
$this->session->expects($this->once())
56+
$this->session->expects($this->exactly(2))
5757
->method('getRepository')
5858
->will($this->returnValue($this->repository));
59-
$this->repository->expects($this->once())
59+
$this->repository->expects($this->exactly(2))
6060
->method('getDescriptor')
6161
->with(RepositoryInterface::OPTION_WORKSPACE_MANAGEMENT_SUPPORTED)
6262
->will($this->returnValue(true))
6363
;
64-
$this->workspace->expects($this->once())
64+
$this->workspace->expects($this->exactly(2))
6565
->method('getAccessibleWorkspaceNames')
6666
->will($this->returnValue(array('default', 'test')))
6767
;
@@ -73,5 +73,16 @@ public function testCreateExisting()
7373
);
7474

7575
$this->assertContains('already has a workspace called "test"', $tester->getDisplay());
76+
77+
$tester = $this->executeCommand(
78+
'phpcr:workspace:create',
79+
array(
80+
'name' => 'test',
81+
'--ignore-existing' => true
82+
),
83+
0
84+
);
85+
86+
$this->assertContains('already has a workspace called "test"', $tester->getDisplay());
7687
}
7788
}

0 commit comments

Comments
 (0)