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
87 changes: 71 additions & 16 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FeatureContext extends BehatContext
protected $applicationTester;
protected $filesystem;
protected $workingDir;
protected $currentWorkspaceName = 'default';

/**
* Initializes context.
Expand All @@ -45,13 +46,13 @@ public function beforeScenario()
chdir($this->workingDir);
$this->filesystem = new Filesystem();

$session = $this->getSession();
$session->save();
$session = $this->getSession(null, true);

$this->applicationTester = new ApplicationTester($this->application);
$this->applicationTester->run(array(
'--transport' => 'jackrabbit',
'--no-interaction' => true,
'--unsupported' => true, // test all the commands, even if they are unsupported (we test for the fail)
), array(
'interactive' => true,
));
Expand All @@ -69,8 +70,19 @@ public static function cleanTestFolders()
$fs->remove(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phpcr-shell');
}

private function getSession($workspaceName = 'default')
private function getSession($workspaceName = null, $force = false)
{
if ($workspaceName === null) {
$workspaceName = $this->currentWorkspaceName;
}

static $sessions = array();

if (false === $force && isset($sessions[$workspaceName])) {
$session = $sessions[$workspaceName];
return $session;
}

$params = array(
'jackalope.jackrabbit_uri' => 'http://localhost:8080/server/',
);
Expand All @@ -79,9 +91,9 @@ private function getSession($workspaceName = 'default')
$repository = $factory->getRepository($params);
$credentials = new SimpleCredentials('admin', 'admin');

$session = $repository->login($credentials, $workspaceName);
$sessions[$workspaceName] = $repository->login($credentials, $workspaceName);

return $session;
return $sessions[$workspaceName];
}

private function getOutput()
Expand Down Expand Up @@ -184,7 +196,7 @@ public function iShouldSeeTheFollowing(PyStringNode $string)
public function theFixturesAreLoaded($arg1)
{
$fixtureFile = $this->getFixtureFilename($arg1);
$session = $this->getSession();
$session = $this->getSession(null, true);
NodeHelper::purgeWorkspace($session);
$session->save();
$session->importXml('/', $fixtureFile, 0);
Expand Down Expand Up @@ -407,7 +419,7 @@ public function theNodeAtShouldNotHaveTheMixin($arg1, $arg2)
*/
public function thereShouldNotExistANodeAt($arg1)
{
$session = $this->getSession();
$session = $this->getSession(null, true);

try {
$session->getNode($arg1);
Expand Down Expand Up @@ -506,7 +518,11 @@ public function thereExistsAWorkspace($arg1)
{
$session = $this->getSession();
$workspace = $session->getWorkspace();
$workspace->createWorkspace($arg1);
try {
$workspace->createWorkspace($arg1);
} catch (\Exception $e) {
// already exists..
}
}

/**
Expand All @@ -522,12 +538,13 @@ public function thereShouldNotExistAWorkspaceCalled($arg1)
}

/**
* @Given /^the "([^"]*)" fixtures are loaded into a workspace "([^"]*)"$/
* @Given /^the "([^"]*)" fixtures are loaded into workspace "([^"]*)"$/
*/
public function theFixturesAreLoadedIntoAWorkspace($arg1, $arg2)
public function theFixturesAreLoadedIntoWorkspace($arg1, $arg2)
{
$this->theCurrentWorkspaceIs($arg2);
$fixtureFile = $this->getFixtureFilename($arg1);
$session = $this->getSession($arg2);
$session = $this->getSession();
NodeHelper::purgeWorkspace($session);
$session->save();
$session->importXml('/', $fixtureFile, 0);
Expand All @@ -545,7 +562,6 @@ public function theNodeTypeIsLoaded($arg1)
$workspace = $session->getWorkspace();
$nodeTypeManager = $workspace->getNodeTypeManager();
$nodeTypeManager->registerNodeTypesCnd($cnd, true);
$session->save();
}

/**
Expand Down Expand Up @@ -603,6 +619,33 @@ public function theCurrentNodeIs($arg1)
$this->executeCommand(sprintf('cd %s', $arg1));
}

/**
* @Given /^the current workspace is "([^"]*)"$/
*/
public function theCurrentWorkspaceIs($arg1)
{
$this->thereExistsAWorkspace($arg1);
$this->currentWorkspaceName = $arg1;
}

/**
* @Given /^the current workspace is empty/
*/
public function theCurrentWorkspaceIsEmpty()
{
$session = $this->getSession();
NodeHelper::purgeWorkspace($session);
$session->save();
}

/**
* @Given /^I refresh the session/
*/
public function iRefreshTheSession()
{
$this->executeCommand('session:refresh');
}

/**
* @Given /^the primary type of "([^"]*)" should be "([^"]*)"$/
*/
Expand All @@ -615,17 +658,29 @@ public function thePrimaryTypeOfShouldBe($arg1, $arg2)
}

/**
* @Given /^the node at "([^"]*)" should have the property "([^"]*)" with type "([^"]*)"$/
* @Given /^the node at "([^"]*)" should have the property "([^"]*)" with value "([^"]*)"$/
*/
public function theNodeAtShouldHaveThePropertyWithType($arg1, $arg2, $arg3)
public function theNodeAtShouldHaveThePropertyWithValue($arg1, $arg2, $arg3)
{
$session = $this->getSession();
$node = $session->getNode($arg1);
$property = $node->getProperty($arg2);
$propertyType = $property->getType();
$propertyType = $property->getValue();
PHPUnit_Framework_Assert::assertEquals($arg3, $propertyType);
}

/**
* @Given /^I set the value of property "([^"]*)" on node "([^"]*)" to "([^"]*)"$/
*/
public function iSetTheValueOfPropertyOnNodeTo($arg1, $arg2, $arg3)
{
$session = $this->getSession();
$node = $session->getNode($arg2);
$property = $node->getProperty($arg1);
$property->setValue($arg3);
$session->save();
}

/**
* @Given /^the node at "([^"]*)" has the mixin "([^"]*)"$/
*/
Expand All @@ -644,7 +699,7 @@ public function iCloneNodeFromTo($arg1, $arg2, $arg3)
{
$session = $this->getSession();
$workspace = $session->getWorkspace();
$workspace->cloneFrom($arg2, $arg1, $arg3, false);
$workspace->cloneFrom($arg2, $arg1, $arg3, true);
}

/**
Expand Down
43 changes: 43 additions & 0 deletions features/fixtures/cms.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:crx="http://www.day.com/crx/1.0"
xmlns:lx="http://flux-cms.org/2.0"
xmlns:test="http://liip.to/jackalope"
xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:vlt="http://www.day.com/jcr/vault/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:new_prefix="http://a_new_namespace"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
xmlns:rep="internal"
sv:name="cms">

<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>

<sv:node sv:name="articles">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:node sv:name="article1">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
<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:property>
<sv:property sv:name="title" sv:type="String">
<sv:value>Article 1</sv:value>
</sv:property>
</sv:node>
</sv:node>
</sv:node>


4 changes: 3 additions & 1 deletion features/fixtures/example.cnd
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<ns ='http://namespace.com/ns'>
<ns='http://namespace.com/ns'>
<nt='http://www.jcp.org/jcr/nt/1.0'>
[ns:NodeType] > nt:unstructured
orderable query
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ Feature: Display the path of any corresponding node in a given workspace

Background:
Given that I am logged in as "testuser"
And the current workspace is "default"
And the "session_data.xml" fixtures are loaded
And the current workspace is "default_1"
And the "session_data.xml" fixtures are loaded
And the current workspace is "default"

Scenario: Rename a node
Given the current node is "/tests_general_base"
Given the current node is "/tests_general_base/idExample"
And I execute the "node:corresponding default" command
Then the command should not fail
And I should see the following:
"""
/foobar
/tests_general_base/idExample
"""
12 changes: 2 additions & 10 deletions features/node_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Feature: Create a node
And the primary type of "/testfile" should be "nt:folder"

Scenario: Create a new node at a non-root current node no matching child type
Given the current node is "/tests_general_base"
Given the current node is "/tests_general_base/emptyExample"
And I execute the "node:create testcreate" command
Then the command should fail
And I should see the following:
"""
No matching child node definition found for `testcreate' in type `nt:folder' for node '/tests_general_base'. Please specify the type explicitly
No matching child node definition found for `testcreate'
"""

Scenario: Create a new node at a non-root current node
Expand All @@ -37,11 +37,3 @@ Feature: Create a node
And I save the session
Then the command should not fail
And there should exist a node at "/tests_general_base/testcreate"

Scenario: Attempt to create an empty node
Given I execute the "node:create" command
Then the command should fail
And I should see the following:
"""
Name can not be empty
"""
4 changes: 2 additions & 2 deletions features/node_info.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Show information about node
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded

Scenario: Rename a node
Scenario: Show node information
Given the current node is "/tests_general_base"
And I execute the "node:info --no-ansi" command
Then the command should not fail
Expand All @@ -17,7 +17,7 @@ Feature: Show information about node
| Path | /tests_general_base |
| UUID | N/A |
| Index | 1 |
| Primary node type | nt:folder |
| Primary node type | nt:unstructured |
| Mixin node types | |
| Checked out? | [ERROR] Not implemented by jackalope |
| Locked? | [ERROR] Not implemented by jackalope |
Expand Down
6 changes: 2 additions & 4 deletions features/node_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ Feature: List properites and chidren of current node
| numberPropertyNode/ | nt:file | |
| NumberPropertyNodeToCompare1/ | nt:file | |
| NumberPropertyNodeToCompare2/ | nt:file | |
| jcr:createdBy | STRING | admin |
| jcr:primaryType | NAME | nt:folder |
| jcr:primaryType | NAME | nt:unstructured |

Scenario: List the properties
Given the current node is "/tests_general_base"
And I execute the "node:list --properties --no-ansi" command
Then the command should not fail
And I should see a table containing the following rows:
| jcr:createdBy | STRING | admin |
| jcr:primaryType | NAME | nt:folder |
| jcr:primaryType | NAME | nt:unstructured |

Scenario: List the children nodes
Given the current node is "/tests_general_base"
Expand Down
3 changes: 2 additions & 1 deletion features/node_rename.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Rename a node
And the "session_data.xml" fixtures are loaded

Scenario: Rename a node
Given the current node is "/tests_general_base"
Given the current node is "/tests_general_base/idExample"
And I execute the "node:rename foobar" command
And I save the session
Then the command should not fail
And there should exist a node at "/tests_general_base/foobar"
3 changes: 2 additions & 1 deletion features/node_set.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Feature: Set a node property
Scenario Outline: Set a property
Given I execute the "<command>" command
Then the command should not fail
And the node at "/properties" should have the property "<name>" with type "<type>"
And I save the session
And the node at "/properties" should have the property "<name>" with value "<type>"

Examples:
| command | name | type |
Expand Down
8 changes: 6 additions & 2 deletions features/node_set_primary_type.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ Feature: Set the nodes primary type

Scenario: List the properties and children of the current node
Given the current node is "/tests_general_base"
And I execute the "node:type:set-primary nt:unstructured --no-ansi" command
Then the command should not fail
And I execute the "node:set-primary-type nt:unstructured --no-ansi" command
Then the command should fail
And I should see the following:
"""
Not implemented
"""
9 changes: 5 additions & 4 deletions features/node_shared_remove.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ Feature: Remove the current node from any shared set to which it belongs

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded
And the node at "/tests_general_base/daniel/leech" has the mixin "mix:shareable"
And I clone node "/tests_general_base/daniel/leech" from "default" to "/tests_general_base/bar"
And the current workspace is "default_1"
And the "cms.xml" fixtures are loaded
And the current workspace is "default"
And I clone node "/cms/articles/article1" from "default_1" to "/foobar"

Scenario: Remove the current node and all of its shared paths
Given the current node is "/tests_general_base/daniel"
Given the current node is "/foobar"
And I execute the "node:shared:remove" command
Then the command should fail
And I should see the following:
Expand Down
9 changes: 5 additions & 4 deletions features/node_shared_show.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ Feature: Show the current nodes shared set

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded
And the node at "/tests_general_base/daniel/leech" has the mixin "mix:shareable"
And I clone node "/tests_general_base/daniel/leech" from "default" to "/tests_general_base/bar"
And the current workspace is "default_1"
And the "cms.xml" fixtures are loaded
And the current workspace is "default"
And I clone node "/cms/articles/article1" from "default_1" to "/foobar"

Scenario: Show the current nodes shared set
Given the current node is "/tests_general_base/daniel/leech"
Given the current node is "/foobar"
And I execute the "node:shared:show" command
Then the command should fail
And I should see the following:
Expand Down
Loading