Skip to content
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
30 changes: 29 additions & 1 deletion features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function beforeScenario()
/**
* Cleans test folders in the temporary directory.
*
* @BeforeSuite
* @AfterSuite
*/
public static function cleanTestFolders()
Expand Down Expand Up @@ -150,6 +149,17 @@ public function iExecuteTheCommand($args)
$this->executeCommand($args);
}

/**
* @Given /^I execute the following commands:$/
*/
public function iExecuteTheFollowingCommands(TableNode $table)
{
foreach ($table->getRows() as $row) {
$this->executeCommand($row[0]);
$this->theCommandShouldNotFail();
}
}

/**
* @Then /^I should see a table containing the following rows:$/
*/
Expand Down Expand Up @@ -190,6 +200,15 @@ public function iShouldSeeTheFollowing(PyStringNode $string)
PHPUnit_Framework_Assert::assertContains($string->getRaw(), $output);
}

/**
* @Then /^I should not see the following:$/
*/
public function iShouldNotSeeTheFollowing(PyStringNode $string)
{
$output = $this->getOutput();
PHPUnit_Framework_Assert::assertNotContains($string->getRaw(), $output);
}

/**
* @Given /^the "([^"]*)" fixtures are loaded$/
*/
Expand Down Expand Up @@ -765,4 +784,13 @@ public function theNodeShouldNotBeLocked($arg1)

PHPUnit_Framework_Assert::assertFalse($isLocked);
}

/**
* @Given /^I purge the current workspace$/
*/
public function iPurgeTheCurrentWorkspace()
{
$session = $this->getSession();
NodeHelper::purgeWorkspace($session);
}
}
2 changes: 1 addition & 1 deletion features/lock_token_remove.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Remove a lock token in the current session
Scenario: Create a new node
Given I execute the "lock:token:remove foobar" command
Then the command should fail
Then I should not see the following:
Then I should see the following:
"""
Not implemented
"""
2 changes: 1 addition & 1 deletion features/node_info.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Show information about node
| Index | 1 |
| Primary node type | nt:unstructured |
| Mixin node types | |
| Checked out? | [ERROR] Not implemented by jackalope |
| Checked out? | N/A |
| Locked? | [ERROR] Not implemented by jackalope |
+-------------------+--------------------------------------+
"""
8 changes: 7 additions & 1 deletion features/version_checkout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ Feature: Checkout a version
Scenario: Checkout a a given node
Given I execute the "version:checkout /tests_version_base/versioned" command
Then the command should not fail
And the node "/tests_version_base/verionable" should be checked out
And the current node is "/tests_version_base/versioned"
And I execute the "node:info" command
Then I should see the following:
"""
| Checked out? | yes
"""


Scenario: Checkout a non-versionable node
Given I execute the "version:checkout /tests_version_base" command
Expand Down
17 changes: 14 additions & 3 deletions features/version_checkpoint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ Feature: Checkpoint
And the "versionable.xml" fixtures are loaded

Scenario: Checkpoint a a given node
Given I execute the "version:checkpoint /tests_version_base/versioned" command
Given I execute the following commands:
| cd /tests_version_base/versioned |
| node:set foo bar |
| session:save |
| version:checkpoint /tests_version_base/versioned |
| node:set foo baz |
| session:save |
| version:checkpoint /tests_version_base/versioned |
Then the command should not fail
And the node "/tests_version_base/verionable" should be checked out
And I should see the following:
"""
Version:
Version: 1.1
"""
And I execute the "node:info" command
Then I should see the following:
"""
| Checked out? | yes
"""

Scenario: Checkpoint a non versionable node
Expand Down
21 changes: 17 additions & 4 deletions features/version_remove.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ Feature: Remove node version

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded
And the "versionable.xml" fixtures are loaded

Scenario: Checkout a a given node
Given the node "/tests_general_base" has a version with label "mylabel"
And I execute the "version:remove /tests_general_base mylabel" command
Given I execute the following commands:
| cd /tests_version_base/versioned |
| version:checkout /tests_version_base/versioned |
| node:set foo baz |
| session:save |
| version:checkin /tests_version_base/versioned |
| version:checkout /tests_version_base/versioned |
| node:set foo bar |
| session:save |
| version:checkin /tests_version_base/versioned |
And I execute the "version:remove /tests_version_base/versioned 1.0" command
Then the command should not fail
And the node "/tests_general_base" should have a node version labeled "mylabel"
And I execute the "version:history /tests_version_base/versioned" command
Then I should not see the following:
"""
| 1.0 |
"""
31 changes: 15 additions & 16 deletions features/version_restore.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ Feature: Restore a version

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded
And the "versionable.xml" fixtures are loaded

Scenario: Restore node version
Given there exists a node version "asd" for node "/tests_general_base"
And I execute the "version:restore --version=asd" command
Given I execute the following commands:
| cd /tests_version_base/versioned |
| node:set foo initalbar |
| session:save |
| version:checkpoint /tests_version_base/versioned |
| node:set foo baz |
| session:save |
| version:checkpoint /tests_version_base/versioned |
And I execute the "version:restore /tests_version_base/versioned 1.0" command
Then the command should not fail
And the version of "/tests_general_base" should be "asd"

Scenario: Restore node version by label
Given there exists a node version "asd" for node "/tests_general_base"
And I execute the "version:restore --label=asd" command
Then the command should not fail
And the version of "/tests_general_base" should be "asd"

Scenario: Restore multiple node versions
Given there exists a node version "asd" for node "/tests_general_base"
And I execute the "version:restore --version=asd --version=dsa" command
Then the command should not fail
And the version of "/tests_general_base" should be "asd"
And I execute the "ls" command
Then I should see the following:
"""
| foo | STRING | inital
"""
14 changes: 10 additions & 4 deletions features/workspace_namespace_register.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ Feature: Register a namespace on the workspace

Background:
Given that I am logged in as "testuser"
And the "clean.xml" system view fixtures are loaded

Scenario: List namespaces
Given I execute the "workspace:namespace:register dcms http://foobar.com/ns" command
Then the command should not fail
# We cannot test namespace registration because jackrabbit does not support
# namespace unregistration, so we simply try doing something which provokes
# to throw an exception.
Scenario: Attemp to register a default namespace
Given I execute the "workspace:namespace:register foo http\://www.jcp.org/jcr/nt/1.0" command
Then the command should fail
And I should see the following:
"""
Can not change default namespace
"""
11 changes: 6 additions & 5 deletions features/workspace_namespace_unregister.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Feature: Unregister a namespace on the workspace

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded

Scenario: List namespaces
Given the namespace "http://foobar.com/ns" with prefix "foo" exists
And I execute the "workspace:namespace:unregister http://foobar.com/ns" command
# We cannot test namespace registration because jackrabbit does not support
# namespace unregistration, so we simply try doing something which provokes
# to throw an exception.
Scenario: Attemp to unregister a default namespace
Given I execute the "workspace:namespace:unregister internal" command
Then the command should fail
And I should see the following:
"""
not supported by jackrabbit backend
Unregistering namespace not supported by jackrabbit backend
"""
16 changes: 10 additions & 6 deletions features/workspace_node_clone.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ Feature: Clone a node from a given workspace to the current workspace
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 "workspace:node:clone default_1 /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 node
Given the current workspace is "default"
And I execute the "workspace:node:clone default_1 /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 "workspace:node:clone default_1 /cms/articles/article1 /cms/articles" 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 "workspace:node:clone --remove-existing default_1 /cms/articles/article1 /cms/articles/article1" command
Expand Down
7 changes: 3 additions & 4 deletions features/workspace_node_copy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ Feature: Copy a node from a given workspace to the current workspace
Given that I am logged in as "testuser"
And the current workspace is "default_1"
And the "session_data.xml" fixtures are loaded
And the "all_property_types.xml" fixtures are loaded
And the current workspace is "default"
And I purge the current workspace

Scenario: Copy node from a different workspace
Given I execute the "workspace:node:copy /tests_general_base/index.txt /index.txt test" command
Given I execute the "workspace: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
And I execute the "workspace:node:copy /tests_general_base/index.txt /index.txt" command
And I execute the "workspace: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 "/index.txt"
And there should exist a node at "/tests_general_base/index.txt.2"
13 changes: 9 additions & 4 deletions src/PHPCR/Shell/Console/Command/NodeInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$nodeHelper = $this->getHelper('node');
$currentNode = $session->getCurrentNode();
$formatter = $this->getHelper('result_formatter');

Expand All @@ -36,10 +37,14 @@ public function execute(InputInterface $input, OutputInterface $output)
$mixinNodeTypeNames[] = $mixin->getName();
}

try {
$isCheckedOut = $currentNode->isCheckedOut() ? 'yes' : 'no';
} catch (\Exception $e) {
$isCheckedOut = $formatter->formatException($e);
if ($nodeHelper->nodeHasMixinType($currentNode, 'mix:versionable')) {
try {
$isCheckedOut = $currentNode->isCheckedOut() ? 'yes' : 'no';
} catch (\Exception $e) {
$isCheckedOut = $formatter->formatException($e);
}
} else {
$isCheckedOut = 'N/A';
}

try {
Expand Down
24 changes: 20 additions & 4 deletions src/PHPCR/Shell/Console/Command/VersionRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@ protected function configure()
$this->setName('version:remove');
$this->setDescription('Remove a node version');
$this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node');
$this->addArgument('versionName', null, InputArgument::REQUIRED, 'Name of version to remove');
$this->setHelp(<<<HERE
Removes the named version from this version history and automatically
repairs the version graph.

If the version to be removed is V, V's predecessor set is P and V's
successor set is S, then the version graph is repaired s follows:

- For each member of P, remove the reference to V from its successor
list and add references to each member of S.
- For each member of S, remove the reference to V from its predecessor
list and add references to each member of P.

<b>Note</b> that this change is made immediately; there is no need to
call save. In fact, since the the version storage is read-only with
respect to normal repository methods, save does not even function in
this context.
HERE
);
}

public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$absPath = $input->getArgument('absPath');
$versionName = $input->getArgument('versionName');
$session = $this->getHelper('phpcr')->getSession();
$workspace = $session->getWorkspace();

$versionManager = $workspace->getVersionManager();
$version = $versionManager->checkin($absPath);

$output->writeln('Version: ' . $version);
$history = $versionManager->getVersionHistory($absPath);
$history->removeVersion($versionName);
}
}
Loading