Skip to content

Commit e974c27

Browse files
committed
Merge pull request #25 from phpcr/alias_and_config
Alias and config
2 parents 468e233 + 475a2ac commit e974c27

File tree

101 files changed

+1123
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1123
-345
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ before_script:
1010

1111
script:
1212
- phpunit --coverage-text
13-
- php vendor/behat/behat/bin/behat --format=failed
13+
- php vendor/behat/behat/bin/behat
1414
- php vendor/bin/phpspec run

features/fixtures/cms.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@
1919
<sv:value>nt:unstructured</sv:value>
2020
</sv:property>
2121

22+
<sv:node sv:name="test">
23+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
24+
<sv:value>nt:unstructured</sv:value>
25+
</sv:property>
26+
</sv:node>
27+
2228
<sv:node sv:name="articles">
2329
<sv:property sv:name="jcr:primaryType" sv:type="Name">
2430
<sv:value>nt:unstructured</sv:value>
2531
</sv:property>
32+
<sv:property sv:name="jcr:mixinTypes" sv:type="name">
33+
<sv:value>mix:shareable</sv:value>
34+
</sv:property>
2635
<sv:node sv:name="article1">
2736
<sv:property sv:name="jcr:primaryType" sv:type="Name">
2837
<sv:value>nt:unstructured</sv:value>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

features/node_copy.feature renamed to features/phpcr_node_copy.feature

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Feature: Copy a node from a given workspace to the current workspace
1616
And I save the session
1717
And there should exist a node at "/foo"
1818

19-
Scenario: Copy node from a different workspace
20-
Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command
21-
Then the command should not fail
22-
And there should exist a node at "/index.txt"
19+
# Does not currently work with jackrabbit..
20+
#Scenario: Copy node from a different workspace
21+
# Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command
22+
# Then the command should not fail
23+
# And there should exist a node at "/index.txt"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

features/node_property_set.feature renamed to features/phpcr_node_property_set.feature

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@ Feature: Set a node property
2222
| node:property:set thisisnew foobar --type=string | /properties/thisisnew | foobar |
2323

2424
Scenario: Update a property but do not specify the type
25-
Given I execute the "node:set /properties/decimal 1234" command
25+
Given I execute the "node:property:set /properties/decimal 1234" command
2626
And I execute the "node:list /properties" command
2727
Then I should see the following:
2828
"""
2929
decimal | DECIMAL
3030
"""
31+
32+
Scenario: Create a new property
33+
Given I execute the "node:property:set /properties/new 1234" command
34+
Then the command should not fail
35+
And I execute the "node:list /properties" command
36+
Then I should see the following:
37+
"""
38+
new | STRING
39+
"""

features/node_property_show.feature renamed to features/phpcr_node_property_show.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ hello world
3636
2011-04-21T14:34:20+01:00
3737
"""
3838

39+
Scenario: Attempt to show a node
40+
Given I execute the "node:property:show /tests_general_base" command
41+
Then the command should fail
42+
And I should see the following:
43+
"""
44+
Item at "/tests_general_base" is not a property
45+
"""
46+
3947
Scenario: Try to show non-existing property
4048
Given I execute the "node:property:show /this/path/does/not/exist" command
4149
Then the command should fail
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

features/shell_alias.feature

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Feature: Command aliases
2+
In order to be more effective when using the shell
3+
As a user
4+
I want to be able to use the default command aliases
5+
6+
Background:
7+
Given that I am logged in as "testuser"
8+
And the "cms.xml" fixtures are loaded
9+
10+
Scenario Outline: Execute an alias
11+
Given I execute the "<command>" command
12+
Then the command should not fail
13+
14+
Examples:
15+
| command |
16+
| use default |
17+
| select * from [nt:unstructured] |
18+
| cd cms |
19+
| rm cms |
20+
| mv cms smc |
21+
| ls |
22+
| ls cms |
23+
| sl cms/articles cms/test/foobar |
24+
| cat cms/articles/article1/title |
25+
26+
Scenario: List aliases
27+
Given I execute the "shell:alias:list" command
28+
Then the command should not fail
29+
And I should see a table containing the following rows:
30+
| Alias | Command |
31+
| cd | shell:path:change {arg1} |
32+
| ls | node:list {arg1} |
33+
34+
35+

features/shell_config_init.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Initialize a new local configuration
2+
In order to create a default configuration
3+
As a user
4+
I want to be able to execute a command which does that
5+
6+
Scenario: Initialize configuration
7+
Given I execute the "shell:config:init --no-ansi --no-interaction" command
8+
Then the command should not fail
9+
And I should see the following:
10+
"""
11+
alias.yml
12+
"""

features/shell_config_reload.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Feature: Reload the configuration
2+
In order to reload the configuration
3+
As a user
4+
I want to be able to execute a command which does that
5+
6+
Scenario: Reload configuration
7+
Given I execute the "shell:config:reload" command
8+
Then the command should not fail
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Application;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
8+
class ShellApplicationSpec extends ObjectBehavior
9+
{
10+
function it_is_initializable()
11+
{
12+
$this->shouldHaveType('PHPCR\Shell\Console\Application\ShellApplication');
13+
}
14+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use Symfony\Component\Filesystem\Filesystem;
8+
9+
class ConfigHelperSpec extends ObjectBehavior
10+
{
11+
function let(
12+
Filesystem $filesystem
13+
)
14+
{
15+
$this->beConstructedWith($filesystem);
16+
}
17+
18+
function it_is_initializable()
19+
{
20+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\ConfigHelper');
21+
}
22+
23+
function it_should_have_a_method_to_get_the_users_config_directory()
24+
{
25+
putenv('PHPCRSH_HOME=/home/foobar');
26+
$this->getConfigDir()->shouldReturn('/home/foobar');
27+
}
28+
29+
function it_should_be_able_to_parse_a_config_file_and_return_the_config_as_an_array(
30+
Filesystem $filesystem
31+
)
32+
{
33+
$dir = __DIR__ . '/fixtures/config';
34+
putenv('PHPCRSH_HOME=' . $dir);
35+
$filesystem->exists(Argument::any())->willReturn(true);
36+
37+
$config = $this->getConfig('alias')->shouldReturn(array(
38+
'foobar' => 'barfoo',
39+
'barfoo' => 'foobar',
40+
));
41+
42+
}
43+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foobar: barfoo
2+
barfoo: foobar
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Event;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use Symfony\Component\Console\Application;
8+
9+
class ApplicationInitEventSpec extends ObjectBehavior
10+
{
11+
function it_is_initializable()
12+
{
13+
$this->shouldHaveType('PHPCR\Shell\Event\ApplicationInitEvent');
14+
}
15+
16+
function let(
17+
Application $application
18+
)
19+
{
20+
$this->beConstructedWith($application);
21+
}
22+
23+
function it_will_return_the_application(
24+
Application $application
25+
)
26+
{
27+
$this->getApplication()->shouldReturn($application);
28+
}
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Event;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class CommandExceptionEventSpec extends ObjectBehavior
10+
{
11+
function it_is_initializable()
12+
{
13+
$this->shouldHaveType('PHPCR\Shell\Event\CommandExceptionEvent');
14+
}
15+
16+
function let(
17+
\Exception $exception,
18+
OutputInterface $output
19+
) {
20+
$this->beConstructedWith($exception, $output);
21+
}
22+
23+
function it_should_provide_access_to_event_parameters(
24+
\Exception $exception,
25+
OutputInterface $output
26+
) {
27+
$this->getException()->shouldReturn($exception);
28+
$this->getOutput()->shouldReturn($output);
29+
}
30+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Subscriber;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use PHPCR\Shell\Console\Helper\ConfigHelper;
8+
use PHPCR\Shell\Console\Input\StringInput;
9+
use PHPCR\Shell\Event\CommandPreRunEvent;
10+
11+
class AliasSubscriberSpec extends ObjectBehavior
12+
{
13+
function it_is_initializable()
14+
{
15+
$this->shouldHaveType('PHPCR\Shell\Subscriber\AliasSubscriber');
16+
}
17+
18+
function let(
19+
ConfigHelper $config
20+
) {
21+
$this->beConstructedWith(
22+
$config
23+
);
24+
25+
$config->getConfig('alias')->willReturn(array(
26+
'ls' => 'list:command {arg1}',
27+
'mv' => 'move {arg1} {arg2}',
28+
));
29+
}
30+
31+
function it_should_convert_an_aliased_input_into_a_real_command_input(
32+
CommandPreRunEvent $event,
33+
ConfigHelper $config,
34+
StringInput $input
35+
) {
36+
$event->getInput()->willReturn($input);
37+
$input->getFirstArgument()->willReturn('ls');
38+
$input->getTokens()->willReturn(array(
39+
'ls', 'me'
40+
));
41+
$event->setInput(Argument::type('PHPCR\Shell\Console\Input\StringInput'))->shouldBeCalled();
42+
43+
$this->handleAlias($event)->shouldReturn('list:command me');
44+
}
45+
46+
function it_should_ommit_missing_arguments(
47+
CommandPreRunEvent $event,
48+
ConfigHelper $config,
49+
StringInput $input
50+
) {
51+
$event->getInput()->willReturn($input);
52+
$input->getFirstArgument()->willReturn('ls');
53+
$input->getTokens()->willReturn(array(
54+
'ls'
55+
));
56+
$event->setInput(Argument::type('PHPCR\Shell\Console\Input\StringInput'))->shouldBeCalled();
57+
58+
$this->handleAlias($event)->shouldReturn('list:command');
59+
}
60+
}

0 commit comments

Comments
 (0)