Skip to content

Fixed fixtures and update node (workspace) commands #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: php

php:
- 5.3
- 5.4
- 5.5

before_script:
- composer self-update
Expand All @@ -12,5 +10,5 @@ before_script:

script:
- phpunit --coverage-text
- php vendor/behat/behat/bin/behat
- php vendor/behat/behat/bin/behat --format=failed
- php vendor/bin/phpspec run
2 changes: 1 addition & 1 deletion features/fixtures/cms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>13543fc6-1abf-4708-bfcc-e49511754b40</sv:value>
<sv:value>66666fc6-1abf-4708-bfcc-e49511754b40</sv:value>
</sv:property>
<sv:property sv:name="title" sv:type="String">
<sv:value>Article 1</sv:value>
Expand Down
21 changes: 7 additions & 14 deletions features/node_clone.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ Feature: Clone a node from a given workspace to the current workspace
Background:
Given that I am logged in as "testuser"
And the current workspace is "default_1"
And the "cms.xml" fixtures are loaded
And the "session_data.xml" fixtures are loaded
And the current workspace is "default"
And the "cms.xml" fixtures are loaded

Scenario: Clone node
Given the current workspace is "default"
And I execute the "node:clone /cms/articles/article1 /cms/clone default_1" command
Scenario: Clone node no workspace (symlink)
Given I execute the "node:clone /cms/articles/article1 /cms/clone" command
Then the command should not fail
And I save the session
And there should exist a node at "/cms/clone"

Scenario: Clone onto existing
Given I execute the "node:clone /cms/articles/article1 /cms/articles default_1" command
Then the command should fail
And I should see the following:
"""
Node already exists at destination
"""

Scenario: Clone onto existing but remove
Given I execute the "node:clone --remove-existing /cms/articles/article1 /cms/articles/article1 default_1" command
Scenario: Clone node
Given I execute the "node:clone /tests_general_base /cms/foobar default_1" command
Then the command should not fail
And I save the session
And there should exist a node at "/cms/foobar"
14 changes: 7 additions & 7 deletions features/node_copy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Feature: Copy a node from a given workspace to the current workspace
And the current workspace is "default_1"
And the "session_data.xml" fixtures are loaded
And the current workspace is "default"
And I purge the current workspace
And the "session_data.xml" fixtures are loaded

Scenario: Copy node in the same workspace
Given I execute the "node:copy /tests_general_base/index.txt /foo" command
Then the command should not fail
And I save the session
And there should exist a node at "/foo"

Scenario: Copy node from a different workspace
Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command
Then the command should not fail
And there should exist a node at "/index.txt"

Scenario: Copy node in the same workspace
Given I execute the "node:copy /tests_general_base/index.txt /tests_general_base/index.txt.2" command
Then the command should not fail
And I save the session
And there should exist a node at "/tests_general_base/index.txt.2"
13 changes: 0 additions & 13 deletions features/session_namespace_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,4 @@ Feature: List all namepsaces mapped to prefixes in the current session
And I should see a table containing the following rows:
| Prefix | URI |
| jcr | http://www.jcp.org/jcr/1.0 |
| sv | http://www.jcp.org/jcr/sv/1.0 |
| nt | http://www.jcp.org/jcr/nt/1.0 |
| mix | http://www.jcp.org/jcr/mix/1.0 |
| xml | http://www.w3.org/XML/1998/namespace |
| test | http://liip.to/jackalope |
| xs | http://www.w3.org/2001/XMLSchema |
| fn_old | http://www.w3.org/2004/10/xpath-functions |
| crx | http://www.day.com/crx/1.0 |
| lx | http://flux-cms.org/2.0 |
| sling | http://sling.apache.org/jcr/sling/1.0 |
| new_prefix | http://a_new_namespace |
| vlt | http://www.day.com/jcr/vault/1.0 |
| fn | http://www.w3.org/2005/xpath-functions |
| rep | internal |
12 changes: 8 additions & 4 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ protected function configure()
{
$this->setName('node:clone');
$this->setDescription('Copy a node from one workspace to another');
$this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node');
$this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node');
$this->addArgument('srcPath', InputArgument::REQUIRED, 'Path to source node');
$this->addArgument('destPath', InputArgument::REQUIRED, 'Path to destination node');
$this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace');
$this->addOption('remove-existing', null, InputOption::VALUE_NONE, 'Remove existing nodes');
$this->setHelp(<<<HERE
Expand Down Expand Up @@ -58,12 +58,16 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$srcWorkspace = $input->getArgument('srcWorkspace');
$srcAbsPath = $input->getArgument('srcAbsPath');
$destAbsPath = $input->getArgument('destAbsPath');
$srcAbsPath = $session->getAbsPath($input->getArgument('srcPath'));
$destAbsPath = $session->getAbsPath($input->getArgument('destPath'));
$removeExisting = $input->getOption('remove-existing');

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

if (!$srcWorkspace) {
$srcWorkspace = $session->getWorkspace()->getName();
}

$workspace = $session->getWorkspace();
$workspace->cloneFrom($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting);
}
Expand Down
9 changes: 5 additions & 4 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ protected function configure()
{
$this->setName('node:copy');
$this->setDescription('Copy a node');
$this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node');
$this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node');
$this->addArgument('srcPath', InputArgument::REQUIRED, 'Path to source node');
$this->addArgument('destPath', InputArgument::REQUIRED, 'Path to destination node');
$this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace');
$this->setHelp(<<<HERE
Copies a Node including its children to a new location to the given workspace.
Expand Down Expand Up @@ -87,11 +87,12 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$srcAbsPath = $input->getArgument('srcAbsPath');
$destAbsPath = $input->getArgument('destAbsPath');
$srcAbsPath = $session->getAbsPath($input->getArgument('srcPath'));
$destAbsPath = $session->getAbsPath($input->getArgument('destPath'));
$srcWorkspace = $input->getArgument('srcWorkspace');

$workspace = $session->getWorkspace();

$workspace->copy($srcAbsPath, $destAbsPath, $srcWorkspace);
}
}