Skip to content

Lots of refactoring and cleaning up before making a first alpha #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2014
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
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ Shell for PHPCR

Shell for PHPCR

## Warning

This shell is currently under heavy development

## Building

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

Currently there is no stable release and so it is necessary to build it manually.

Install box: http://box-project.org

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

````bash
$ sudo cp phpcr.sh /usr/bin
$ sudo cp phpcrsh.phar /usr/bin/local/phpcrsh
````

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

````bash
./bin/phpcr --help
Usage:
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="..."]
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="..."]

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

## TODO

- Versioning:
- Activity
- Configuration
Todo:

- Better querying support
- Better autocompletion
- Directory aware configuration / configuration auto-detection
File renamed without changes.
14 changes: 14 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/EditorHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class EditorHelperSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\EditorHelper');
}
}
58 changes: 58 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/NodeHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use PHPCR\NodeInterface;
use PHPCR\NodeType\NodeTypeInterface;

class NodeHelperSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\NodeHelper');
}

function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin(
NodeInterface $node,
NodeTypeInterface $mixin1,
NodeTypeInterface $mixin2,
NodeTypeInterface $mixin3
)
{
$node->getMixinNodeTypes()->willReturn(array(
$mixin1, $mixin2, $mixin3
));

$mixin1->getName()->willReturn('mixin1');
$mixin2->getName()->willReturn('mixin1');
$mixin3->getName()->willReturn('mixin3');

$this->nodeHasMixinType($node, 'mixin1')->shouldReturn(true);
$this->nodeHasMixinType($node, 'mixin5')->shouldReturn(false);
}

function it_should_provide_a_method_to_determine_if_a_node_is_versionable(
NodeInterface $nodeVersionable,
NodeInterface $nodeNotVersionable,
NodeTypeInterface $mixin1,
NodeTypeInterface $mixin2
)
{
$nodeVersionable->getMixinNodeTypes()->willReturn(array(
$mixin1, $mixin2
));
$nodeNotVersionable->getMixinNodeTypes()->willReturn(array(
$mixin2
));
$nodeNotVersionable->getPath()->willReturn('foobar');
$mixin1->getName()->willReturn('mix:versionable');
$this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null);;

try {
$this->assertNodeIsVersionable($nodeNotVersionable);
} catch (\OutOfBoundsException $e) {
}
}
}
21 changes: 21 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/PhpcrHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Console\Input\InputInterface;

class PhpcrHelperSpec extends ObjectBehavior
{
function let(
InputInterface $input
) {
$this->beConstructedWith($input);
}

function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\PhpcrHelper');
}
}
36 changes: 36 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/RepositoryHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use PHPCR\RepositoryInterface;
use PHPCR\Shell\Console\Helper\PhpcrHelper;

class RepositoryHelperSpec extends ObjectBehavior
{
function let(
PhpcrHelper $phpcrHelper
) {
$this->beConstructedWith($phpcrHelper);
}

function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\RepositoryHelper');
}

function it_provides_a_method_to_say_if_a_descriptor_exists_or_not(
PhpcrHelper $phpcrHelper,
RepositoryInterface $repository
) {
$phpcrHelper->getRepository()->willReturn($repository);
$repository->getDescriptorKeys()->willReturn(array(
'foo', 'bar'
));
$repository->getDescriptor('foo')->willReturn('foo');
$repository->getDescriptor('bar')->willReturn('foo');

$this->hasDescriptor('foo')->shouldReturn(true);
}
}
14 changes: 14 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class ResultFormatterHelperSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\ResultFormatterHelper');
}
}
19 changes: 19 additions & 0 deletions spec/PHPCR/Shell/Console/Helper/TextHelperSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace spec\PHPCR\Shell\Console\Helper;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class TextHelperSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Helper\TextHelper');
}

function it_should_truncate_text()
{
$this->truncate('hello this is some text', 5)->shouldReturn('he...');
}
}
19 changes: 19 additions & 0 deletions spec/PHPCR/Shell/Console/Input/StringInputSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace spec\PHPCR\Shell\Console\Input;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class StringInputSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('foobar');
}

function it_is_initializable()
{
$this->shouldHaveType('PHPCR\Shell\Console\Input\StringInput');
}
}
19 changes: 17 additions & 2 deletions src/PHPCR/Shell/Console/Application/SessionApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
*/
class SessionApplication extends BaseApplication
{
const APP_NAME = 'PHPCR';
const APP_VERSION = '0.1';
const APP_NAME = 'PHPCRSH';
const APP_VERSION = '1.0.0-alpha1';

protected $shellApplication;

/**
* Constructor - add the single command ShellCommand which
* accepts the connection parameters for the shell.
*/
public function __construct()
{
parent::__construct(self::APP_NAME, self::APP_VERSION);
Expand All @@ -39,11 +43,22 @@ public function getDefaultInputDefinition()
return new InputDefinition(array());
}

/**
* This application always runs the phpcr_shell command to connect
* to the shell.
*
* {@inheritDoc}
*/
protected function getCommandName(InputInterface $input)
{
return 'phpcr_shell';
}

/**
* Return the shell application
*
* @return ShellApplication
*/
public function getShellApplication()
{
return $this->shellApplication;
Expand Down
6 changes: 4 additions & 2 deletions src/PHPCR/Shell/Console/Application/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ protected function getHeader()

Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).

At the prompt, type <comment>help</comment> for some help,
or <comment>list</comment> to get a list of available commands.
At the prompt, type <comment>help</comment> for some help.

- To list all of the commands type <comment>list</comment>.
- To list all of the registered command aliases, type <comment>aliases</comment>.

To exit the shell, type <comment>exit</comment>.

Expand Down
Loading