Skip to content

Commit 468e233

Browse files
committed
Merge pull request #24 from phpcr/fixing_commands
Fixed fixtures and update node (workspace) commands
2 parents d16fe4b + 372c670 commit 468e233

File tree

7 files changed

+29
-46
lines changed

7 files changed

+29
-46
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
language: php
22

33
php:
4-
- 5.3
54
- 5.4
6-
- 5.5
75

86
before_script:
97
- composer self-update
@@ -12,5 +10,5 @@ before_script:
1210

1311
script:
1412
- phpunit --coverage-text
15-
- php vendor/behat/behat/bin/behat
13+
- php vendor/behat/behat/bin/behat --format=failed
1614
- php vendor/bin/phpspec run

features/fixtures/cms.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<sv:value>mix:referenceable</sv:value>
3232
</sv:property>
3333
<sv:property sv:name="jcr:uuid" sv:type="String">
34-
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
34+
<sv:value>66666fc6-1abf-4708-bfcc-e49511754b40</sv:value>
3535
</sv:property>
3636
<sv:property sv:name="title" sv:type="String">
3737
<sv:value>Article 1</sv:value>

features/node_clone.feature

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@ Feature: Clone a node from a given workspace to the current workspace
66
Background:
77
Given that I am logged in as "testuser"
88
And the current workspace is "default_1"
9-
And the "cms.xml" fixtures are loaded
9+
And the "session_data.xml" fixtures are loaded
1010
And the current workspace is "default"
1111
And the "cms.xml" fixtures are loaded
1212

13-
Scenario: Clone node
14-
Given the current workspace is "default"
15-
And I execute the "node:clone /cms/articles/article1 /cms/clone default_1" command
13+
Scenario: Clone node no workspace (symlink)
14+
Given I execute the "node:clone /cms/articles/article1 /cms/clone" command
1615
Then the command should not fail
1716
And I save the session
1817
And there should exist a node at "/cms/clone"
1918

20-
Scenario: Clone onto existing
21-
Given I execute the "node:clone /cms/articles/article1 /cms/articles default_1" command
22-
Then the command should fail
23-
And I should see the following:
24-
"""
25-
Node already exists at destination
26-
"""
27-
28-
Scenario: Clone onto existing but remove
29-
Given I execute the "node:clone --remove-existing /cms/articles/article1 /cms/articles/article1 default_1" command
19+
Scenario: Clone node
20+
Given I execute the "node:clone /tests_general_base /cms/foobar default_1" command
3021
Then the command should not fail
22+
And I save the session
23+
And there should exist a node at "/cms/foobar"

features/node_copy.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Feature: Copy a node from a given workspace to the current workspace
88
And the current workspace is "default_1"
99
And the "session_data.xml" fixtures are loaded
1010
And the current workspace is "default"
11-
And I purge the current workspace
11+
And the "session_data.xml" fixtures are loaded
12+
13+
Scenario: Copy node in the same workspace
14+
Given I execute the "node:copy /tests_general_base/index.txt /foo" command
15+
Then the command should not fail
16+
And I save the session
17+
And there should exist a node at "/foo"
1218

1319
Scenario: Copy node from a different workspace
1420
Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command
1521
Then the command should not fail
1622
And there should exist a node at "/index.txt"
17-
18-
Scenario: Copy node in the same workspace
19-
Given I execute the "node:copy /tests_general_base/index.txt /tests_general_base/index.txt.2" command
20-
Then the command should not fail
21-
And I save the session
22-
And there should exist a node at "/tests_general_base/index.txt.2"

features/session_namespace_list.feature

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,4 @@ Feature: List all namepsaces mapped to prefixes in the current session
1212
And I should see a table containing the following rows:
1313
| Prefix | URI |
1414
| jcr | http://www.jcp.org/jcr/1.0 |
15-
| sv | http://www.jcp.org/jcr/sv/1.0 |
16-
| nt | http://www.jcp.org/jcr/nt/1.0 |
17-
| mix | http://www.jcp.org/jcr/mix/1.0 |
18-
| xml | http://www.w3.org/XML/1998/namespace |
19-
| test | http://liip.to/jackalope |
20-
| xs | http://www.w3.org/2001/XMLSchema |
21-
| fn_old | http://www.w3.org/2004/10/xpath-functions |
22-
| crx | http://www.day.com/crx/1.0 |
23-
| lx | http://flux-cms.org/2.0 |
24-
| sling | http://sling.apache.org/jcr/sling/1.0 |
25-
| new_prefix | http://a_new_namespace |
26-
| vlt | http://www.day.com/jcr/vault/1.0 |
27-
| fn | http://www.w3.org/2005/xpath-functions |
2815
| rep | internal |

src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ protected function configure()
1414
{
1515
$this->setName('node:clone');
1616
$this->setDescription('Copy a node from one workspace to another');
17-
$this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node');
18-
$this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node');
17+
$this->addArgument('srcPath', InputArgument::REQUIRED, 'Path to source node');
18+
$this->addArgument('destPath', InputArgument::REQUIRED, 'Path to destination node');
1919
$this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace');
2020
$this->addOption('remove-existing', null, InputOption::VALUE_NONE, 'Remove existing nodes');
2121
$this->setHelp(<<<HERE
@@ -58,12 +58,16 @@ public function execute(InputInterface $input, OutputInterface $output)
5858
{
5959
$session = $this->getHelper('phpcr')->getSession();
6060
$srcWorkspace = $input->getArgument('srcWorkspace');
61-
$srcAbsPath = $input->getArgument('srcAbsPath');
62-
$destAbsPath = $input->getArgument('destAbsPath');
61+
$srcAbsPath = $session->getAbsPath($input->getArgument('srcPath'));
62+
$destAbsPath = $session->getAbsPath($input->getArgument('destPath'));
6363
$removeExisting = $input->getOption('remove-existing');
6464

6565
// todo: Check to ensure that source node has the referenceable mixin
6666

67+
if (!$srcWorkspace) {
68+
$srcWorkspace = $session->getWorkspace()->getName();
69+
}
70+
6771
$workspace = $session->getWorkspace();
6872
$workspace->cloneFrom($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting);
6973
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ protected function configure()
1313
{
1414
$this->setName('node:copy');
1515
$this->setDescription('Copy a node');
16-
$this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node');
17-
$this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node');
16+
$this->addArgument('srcPath', InputArgument::REQUIRED, 'Path to source node');
17+
$this->addArgument('destPath', InputArgument::REQUIRED, 'Path to destination node');
1818
$this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace');
1919
$this->setHelp(<<<HERE
2020
Copies a Node including its children to a new location to the given workspace.
@@ -87,11 +87,12 @@ protected function configure()
8787
public function execute(InputInterface $input, OutputInterface $output)
8888
{
8989
$session = $this->getHelper('phpcr')->getSession();
90-
$srcAbsPath = $input->getArgument('srcAbsPath');
91-
$destAbsPath = $input->getArgument('destAbsPath');
90+
$srcAbsPath = $session->getAbsPath($input->getArgument('srcPath'));
91+
$destAbsPath = $session->getAbsPath($input->getArgument('destPath'));
9292
$srcWorkspace = $input->getArgument('srcWorkspace');
9393

9494
$workspace = $session->getWorkspace();
95+
9596
$workspace->copy($srcAbsPath, $destAbsPath, $srcWorkspace);
9697
}
9798
}

0 commit comments

Comments
 (0)