Skip to content

Commit 36e9ace

Browse files
committed
Merge pull request #27 from phpcr/refactoring
Lots of refactoring and cleaning up before making a first alpha
2 parents e974c27 + bbb6531 commit 36e9ace

File tree

71 files changed

+605
-393
lines changed

Some content is hidden

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

71 files changed

+605
-393
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ Shell for PHPCR
55

66
Shell for PHPCR
77

8-
## Warning
9-
10-
This shell is currently under heavy development
11-
128
## Building
139

1410
The recommended way to use the PHPCR shell is as a phar archive.
1511

16-
Currently there is no stable release and so it is necessary to build it manually.
17-
1812
Install box: http://box-project.org
1913

2014
Build the PHAR:
@@ -29,7 +23,7 @@ This will produce the file `phpcr.phar`.
2923
Copy this file to your bin directory:
3024

3125
````bash
32-
$ sudo cp phpcr.sh /usr/bin
26+
$ sudo cp phpcrsh.phar /usr/bin/local/phpcrsh
3327
````
3428

3529
## Connecting
@@ -41,9 +35,8 @@ To connect to a doctrine-dbal PHPCR repository:
4135
Full definition:
4236

4337
````bash
44-
./bin/phpcr --help
4538
Usage:
46-
phpcr_shell [-h|--help] [-v|--verbose] [-V|--version] [--ansi] [--no-ansi] [-t|--transport="..."] [-pu|--phpcr-username="..."] [-pp|--phpcr-password[="..."]] [-pw|--phpcr-workspace[="..."]] [-du|--db-username="..."] [-dn|--db-name="..."] [-dp|--db-password[="..."]] [-dh|--db-host="..."] [-dd|--db-driver="..."] [-dP|--db-path="..."] [-url|--repo-url="..."]
39+
phpcr_shell [-h|--help] [-v|--verbose] [-V|--version] [--ansi] [--no-ansi] [-t|--transport="..."] [-pu|--phpcr-username="..."] [-pp|--phpcr-password[="..."]] [-pw|--phpcr-workspace[="..."]] [-du|--db-username="..."] [-dn|--db-name="..."] [-dp|--db-password[="..."]] [-dh|--db-host="..."] [-dd|--db-driver="..."] [-dP|--db-path="..."] [--no-interaction] [--unsupported] [-url|--repo-url="..."] [--command="..."]
4740

4841
Options:
4942
--help (-h) Display this help message.
@@ -61,12 +54,14 @@ Options:
6154
--db-host (-dh) Database Host. (default: "localhost")
6255
--db-driver (-dd) Database Transport. (default: "pdo_mysql")
6356
--db-path (-dP) Database Path.
57+
--no-interaction Turn off interaction (for testing purposes)
58+
--unsupported Show all commands, including commands not supported by the repository
6459
--repo-url (-url) URL of repository (e.g. for jackrabbit). (default: "http://localhost:8080/server/")
60+
--command Run the given command
6561
````
6662

67-
## TODO
68-
69-
- Versioning:
70-
- Activity
71-
- Configuration
63+
Todo:
7264

65+
- Better querying support
66+
- Better autocompletion
67+
- Directory aware configuration / configuration auto-detection

bin/phpcr renamed to bin/phpcrsh

File renamed without changes.
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\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
8+
class EditorHelperSpec extends ObjectBehavior
9+
{
10+
function it_is_initializable()
11+
{
12+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\EditorHelper');
13+
}
14+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use PHPCR\NodeInterface;
8+
use PHPCR\NodeType\NodeTypeInterface;
9+
10+
class NodeHelperSpec extends ObjectBehavior
11+
{
12+
function it_is_initializable()
13+
{
14+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\NodeHelper');
15+
}
16+
17+
function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin(
18+
NodeInterface $node,
19+
NodeTypeInterface $mixin1,
20+
NodeTypeInterface $mixin2,
21+
NodeTypeInterface $mixin3
22+
)
23+
{
24+
$node->getMixinNodeTypes()->willReturn(array(
25+
$mixin1, $mixin2, $mixin3
26+
));
27+
28+
$mixin1->getName()->willReturn('mixin1');
29+
$mixin2->getName()->willReturn('mixin1');
30+
$mixin3->getName()->willReturn('mixin3');
31+
32+
$this->nodeHasMixinType($node, 'mixin1')->shouldReturn(true);
33+
$this->nodeHasMixinType($node, 'mixin5')->shouldReturn(false);
34+
}
35+
36+
function it_should_provide_a_method_to_determine_if_a_node_is_versionable(
37+
NodeInterface $nodeVersionable,
38+
NodeInterface $nodeNotVersionable,
39+
NodeTypeInterface $mixin1,
40+
NodeTypeInterface $mixin2
41+
)
42+
{
43+
$nodeVersionable->getMixinNodeTypes()->willReturn(array(
44+
$mixin1, $mixin2
45+
));
46+
$nodeNotVersionable->getMixinNodeTypes()->willReturn(array(
47+
$mixin2
48+
));
49+
$nodeNotVersionable->getPath()->willReturn('foobar');
50+
$mixin1->getName()->willReturn('mix:versionable');
51+
$this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null);;
52+
53+
try {
54+
$this->assertNodeIsVersionable($nodeNotVersionable);
55+
} catch (\OutOfBoundsException $e) {
56+
}
57+
}
58+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
9+
class PhpcrHelperSpec extends ObjectBehavior
10+
{
11+
function let(
12+
InputInterface $input
13+
) {
14+
$this->beConstructedWith($input);
15+
}
16+
17+
function it_is_initializable()
18+
{
19+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\PhpcrHelper');
20+
}
21+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
use PHPCR\RepositoryInterface;
8+
use PHPCR\Shell\Console\Helper\PhpcrHelper;
9+
10+
class RepositoryHelperSpec extends ObjectBehavior
11+
{
12+
function let(
13+
PhpcrHelper $phpcrHelper
14+
) {
15+
$this->beConstructedWith($phpcrHelper);
16+
}
17+
18+
function it_is_initializable()
19+
{
20+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\RepositoryHelper');
21+
}
22+
23+
function it_provides_a_method_to_say_if_a_descriptor_exists_or_not(
24+
PhpcrHelper $phpcrHelper,
25+
RepositoryInterface $repository
26+
) {
27+
$phpcrHelper->getRepository()->willReturn($repository);
28+
$repository->getDescriptorKeys()->willReturn(array(
29+
'foo', 'bar'
30+
));
31+
$repository->getDescriptor('foo')->willReturn('foo');
32+
$repository->getDescriptor('bar')->willReturn('foo');
33+
34+
$this->hasDescriptor('foo')->shouldReturn(true);
35+
}
36+
}
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\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
8+
class ResultFormatterHelperSpec extends ObjectBehavior
9+
{
10+
function it_is_initializable()
11+
{
12+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\ResultFormatterHelper');
13+
}
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Helper;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
8+
class TextHelperSpec extends ObjectBehavior
9+
{
10+
function it_is_initializable()
11+
{
12+
$this->shouldHaveType('PHPCR\Shell\Console\Helper\TextHelper');
13+
}
14+
15+
function it_should_truncate_text()
16+
{
17+
$this->truncate('hello this is some text', 5)->shouldReturn('he...');
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace spec\PHPCR\Shell\Console\Input;
4+
5+
use PhpSpec\ObjectBehavior;
6+
use Prophecy\Argument;
7+
8+
class StringInputSpec extends ObjectBehavior
9+
{
10+
function let()
11+
{
12+
$this->beConstructedWith('foobar');
13+
}
14+
15+
function it_is_initializable()
16+
{
17+
$this->shouldHaveType('PHPCR\Shell\Console\Input\StringInput');
18+
}
19+
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
*/
1616
class SessionApplication extends BaseApplication
1717
{
18-
const APP_NAME = 'PHPCR';
19-
const APP_VERSION = '0.1';
18+
const APP_NAME = 'PHPCRSH';
19+
const APP_VERSION = '1.0.0-alpha1';
2020

2121
protected $shellApplication;
2222

23+
/**
24+
* Constructor - add the single command ShellCommand which
25+
* accepts the connection parameters for the shell.
26+
*/
2327
public function __construct()
2428
{
2529
parent::__construct(self::APP_NAME, self::APP_VERSION);
@@ -39,11 +43,22 @@ public function getDefaultInputDefinition()
3943
return new InputDefinition(array());
4044
}
4145

46+
/**
47+
* This application always runs the phpcr_shell command to connect
48+
* to the shell.
49+
*
50+
* {@inheritDoc}
51+
*/
4252
protected function getCommandName(InputInterface $input)
4353
{
4454
return 'phpcr_shell';
4555
}
4656

57+
/**
58+
* Return the shell application
59+
*
60+
* @return ShellApplication
61+
*/
4762
public function getShellApplication()
4863
{
4964
return $this->shellApplication;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ protected function getHeader()
8282
8383
Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
8484
85-
At the prompt, type <comment>help</comment> for some help,
86-
or <comment>list</comment> to get a list of available commands.
85+
At the prompt, type <comment>help</comment> for some help.
86+
87+
- To list all of the commands type <comment>list</comment>.
88+
- To list all of the registered command aliases, type <comment>aliases</comment>.
8789
8890
To exit the shell, type <comment>exit</comment>.
8991

0 commit comments

Comments
 (0)