Skip to content

Commit e8793d8

Browse files
committed
Added lock commands
1 parent e72689d commit e8793d8

17 files changed

+526
-0
lines changed

features/bootstrap/FeatureContext.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,54 @@ public function iCloneNodeFromTo($arg1, $arg2, $arg3)
646646
$workspace = $session->getWorkspace();
647647
$workspace->cloneFrom($arg2, $arg1, $arg3, false);
648648
}
649+
650+
/**
651+
* @Given /^the node "([^"]*)" is locked$/
652+
*/
653+
public function theNodeIsLocked($arg1)
654+
{
655+
$session = $this->getSession();
656+
$workspace = $session->getWorkspace();
657+
$lockManager = $workspace->getLockManager();
658+
$lockManager->lock($arg1, true, true);
659+
}
660+
661+
/**
662+
* @Given /^the node "([^"]*)" is not locked$/
663+
*/
664+
public function theNodeIsNotLocked($arg1)
665+
{
666+
$session = $this->getSession();
667+
$workspace = $session->getWorkspace();
668+
$lockManager = $workspace->getLockManager();
669+
if ($lockManager->isLocked($arg1)) {
670+
$lockManager->unlock($arg1);
671+
}
672+
}
673+
674+
/**
675+
* @Given /^the node "([^"]*)" should be locked$/
676+
*/
677+
public function theNodeShouldBeLocked($arg1)
678+
{
679+
$session = $this->getSession();
680+
$workspace = $session->getWorkspace();
681+
$lockManager = $workspace->getLockManager();
682+
$isLocked = $lockManager->isLocked($arg1);
683+
684+
PHPUnit_Framework_Assert::assertTrue($isLocked);
685+
}
686+
687+
/**
688+
* @Given /^the node "([^"]*)" should not be locked$/
689+
*/
690+
public function theNodeShouldNotBeLocked($arg1)
691+
{
692+
$session = $this->getSession();
693+
$workspace = $session->getWorkspace();
694+
$lockManager = $workspace->getLockManager();
695+
$isLocked = $lockManager->isLocked($arg1);
696+
697+
PHPUnit_Framework_Assert::assertFalse($isLocked);
698+
}
649699
}

features/lock_info.feature

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Feature: Show the details of a lock
2+
In order to show the details of a lock
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "session_data.xml" fixtures are loaded
9+
And the node at "/tests_general_base" has the mixin "mix:lockable"
10+
And the node "/tests_general_base" is locked
11+
12+
Scenario: Create a new node
13+
Given I execute the "lock:info /tests_general_base" command
14+
Then the command should fail
15+
And I should see the following:
16+
"""
17+
Not implemented
18+
"""
19+
# And I should see the following:
20+
# """
21+
# Lock Owner: admin
22+
# Lock Token: foobar
23+
# Seconds Remaining: 123
24+
# Deep?: yes
25+
# Live?: yes
26+
# Owned by current session?: no
27+
# Session Scoped?: no
28+
# """
29+

features/lock_lock.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Feature: Lock the node at a given path
2+
In order to lock a node at a given path
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "session_data.xml" fixtures are loaded
9+
And the node at "/tests_general_base" has the mixin "mix:lockable"
10+
11+
Scenario: Create a new lock
12+
Given I execute the "lock:lock /tests_general_base --deep --session-scoped --timeout=30 --owner-info=random" command
13+
Then the command should not fail
14+
And the node "/tests_general_base" should be locked

features/lock_refresh.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Feature: Refresh the TTL of a lock
2+
In order to reset the TTL on the lock of a given node path
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And I execute the "lock:lock /tests_general_base --session-scoped --timeout=10" command
9+
10+
Scenario: Create a new node
11+
And I execute the "lock:refresh /tests_general_base" command
12+
Then the command should fail
13+
And I should see the following:
14+
"""
15+
Not implemented
16+
"""

features/lock_token_add.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Feature: Add a lock token in the current session
2+
In order to create a new lock token
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
9+
Scenario: Create a new node
10+
Given I execute the "lock:token:add foobar" command
11+
Then the command should fail
12+
Then I should see the following:
13+
"""
14+
Not implemented
15+
"""
16+

features/lock_token_list.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Feature: List the lock tokens registered with the current session
2+
In order to list the lock tokens registered in the current session
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
9+
Scenario: List lock tokens
10+
Given I execute the "lock:token:add foobar" command
11+
Then the command should fail
12+
"""
13+
Not implemented
14+
"""

features/lock_token_remove.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Remove a lock token in the current session
2+
In order to create a new lock token
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
9+
Scenario: Create a new node
10+
Given I execute the "lock:token:remove foobar" command
11+
Then the command should fail
12+
Then I should not see the following:
13+
"""
14+
Not implemented
15+
"""

features/lock_unlock.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Unlock the node at a given path
2+
In order to unlock a node at a given path
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "session_data.xml" fixtures are loaded
9+
And the node at "/tests_general_base" has the mixin "mix:lockable"
10+
11+
Scenario: Create a new node
12+
Given I execute the "lock:lock /tests_general_base --session-scoped" command
13+
And I execute the "lock:unlock /tests_general_base" command
14+
Then the command should not fail
15+
And the node "/tests_general_base" should not be locked

features/node_remove.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Remove a node
2+
In order to remove a node
3+
As a user that is logged into the shell
4+
I should be able to run a command which does that
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "session_data.xml" fixtures are loaded
9+
10+
Scenario: Remove a node
11+
Given the current node is "/tests_general_base"
12+
And I execute the "node:remove" command
13+
Then the command should not fail
14+
And I save the session
15+
And there should not exist a node at "/tests_general_base"

src/PHPCR/Shell/Console/Application/ShellApplication.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@
8383
use PHPCR\Shell\Console\Command\NodeSharedShowCommand;
8484
use PHPCR\Shell\Console\Command\NodeSharedRemoveCommand;
8585
use PHPCR\Shell\Console\Command\NodeRemoveCommand;
86+
use PHPCR\Shell\Console\Command\LockLockCommand;
87+
use PHPCR\Shell\Console\Command\LockInfoCommand;
88+
use PHPCR\Shell\Console\Command\LockRefreshCommand;
89+
use PHPCR\Shell\Console\Command\LockTokenAddCommand;
90+
use PHPCR\Shell\Console\Command\LockTokenListCommand;
91+
use PHPCR\Shell\Console\Command\LockTokenRemoveCommand;
92+
use PHPCR\Shell\Console\Command\LockUnlockCommand;
8693

8794
use Jackalope\NotImplementedException;
8895
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
@@ -181,6 +188,13 @@ public function init()
181188
$this->add(new NodeSharedShowCommand());
182189
$this->add(new NodeSharedRemoveCommand());
183190
$this->add(new NodeRemoveCommand());
191+
$this->add(new LockLockCommand());
192+
$this->add(new LockInfoCommand());
193+
$this->add(new LockRefreshCommand());
194+
$this->add(new LockTokenAddCommand());
195+
$this->add(new LockTokenListCommand());
196+
$this->add(new LockTokenRemoveCommand());
197+
$this->add(new LockUnlockCommand());
184198

185199
// add shell-specific commands
186200
$this->add(new ChangePathCommand());

0 commit comments

Comments
 (0)