Skip to content

Commit 31b3a23

Browse files
committed
Fixing tests
1 parent 9ca701f commit 31b3a23

File tree

8 files changed

+62
-29
lines changed

8 files changed

+62
-29
lines changed

features/all/phpcr_node_move.feature

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1+
@annoying
12
Feature: Move a node in the current session
23
In order to move a single node in the current workspace
34
As a user logged into the shell
45
I want to move a node from one path to another
56

67
Background:
78
Given that I am logged in as "testuser"
8-
And the "session_data.xml" fixtures are loaded
9+
And the "cms.xml" fixtures are loaded
910

1011
Scenario: Move node
11-
Given I execute the "node:move /tests_general_base/index.txt /foobar" command
12+
Given I execute the "node:move /cms/test /foobar" command
1213
Then the command should not fail
1314
And I execute the "session:save" command
1415
And there should exist a node at "/foobar"
1516
And there should not exist a node at "/tests_general_base/index.txt"
1617

1718
Scenario: Move node relative paths
18-
Given the current node is "/tests_general_base/index.txt"
19+
Given the current node is "/cms/test"
1920
And I execute the "node:move . /barfoo" command
2021
Then the command should not fail
2122
And I execute the "session:save" command
2223
And there should exist a node at "/barfoo"
2324
And there should not exist a node at "/tests_general_base/index.txt"
2425

2526
Scenario: Move onto existing target
26-
Given the current node is "/tests_general_base/index.txt"
27-
And I execute the "node:move . /tests_general_base/daniel" command
27+
Given the current node is "/cms/test"
28+
And I execute the "node:move . /cms/products" command
2829
Then the command should not fail
2930
And I execute the "session:save" command
30-
And there should exist a node at "/tests_general_base/daniel/index.txt"
31+
And there should exist a node at "/cms/products/test"

features/all/phpcr_node_property_remove.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@annoying
12
Feature: Remove a single property at a specified path
23
In order to remove a single property at a specified path
34
As a user logged into the shell
@@ -14,7 +15,7 @@ Feature: Remove a single property at a specified path
1415
And there should not exist a property at "/cms/articles/article1/title"
1516

1617
Scenario: Try and remove a node
17-
And I execute the "node:property:remove /tests_general_base" command
18+
Given I execute the "node:property:remove /tests_general_base" command
1819
Then the command should fail
1920
And I should see the following:
2021
"""

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class ShellApplication extends Application
5656
*/
5757
protected $container;
5858

59+
/**
60+
* @var boolean
61+
*/
62+
protected $debug = false;
63+
5964
/**
6065
* Constructor - name and version inherited from SessionApplication
6166
*
@@ -254,7 +259,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
254259
try {
255260
$exitCode = parent::doRun($input, $output);
256261
} catch (\Exception $e) {
257-
$this->dispatcher->dispatch(PhpcrShellEvents::COMMAND_EXCEPTION, new Event\CommandExceptionEvent($e, $input, $output));
262+
$this->dispatcher->dispatch(PhpcrShellEvents::COMMAND_EXCEPTION, new Event\CommandExceptionEvent($e, $this, $output));
258263

259264
return 1;
260265
}
@@ -311,4 +316,21 @@ public function getContainer()
311316
{
312317
return $this->container;
313318
}
319+
320+
/**
321+
* Return if the shell is in debug mode
322+
*/
323+
public function isDebug()
324+
{
325+
return $this->debug;
326+
}
327+
328+
/**
329+
* Debug mode -- more verbose exceptions
330+
*/
331+
public function setDebug($debug)
332+
{
333+
$this->debug = $debug;
334+
}
335+
314336
}

src/PHPCR/Shell/Console/Command/ShellCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function execute(InputInterface $input, OutputInterface $output)
7878
$application->setShowUnsupported($showUnspported);
7979
$application->dispatchProfileInitEvent($input, $output);
8080

81+
if ($input->getOption('verbose')) {
82+
$application->setDebug(true);
83+
}
84+
8185
$noInteraction = $input->getOption('no-interaction');
8286

8387
if ($commands = $input->getOption('command')) {

src/PHPCR/Shell/Event/CommandExceptionEvent.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44

55
use Symfony\Component\EventDispatcher\Event;
66
use Symfony\Component\Console\Output\OutputInterface;
7-
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Application\ApplicationInterface;
8+
use PHPCR\Shell\Console\Application\ShellApplication;
89

910
class CommandExceptionEvent extends Event
1011
{
1112
protected $exception;
1213
protected $output;
13-
protected $input;
14+
protected $application;
1415

15-
public function __construct(\Exception $exception, InputInterface $input, OutputInterface $output)
16+
public function __construct(\Exception $exception, ShellApplication $application, OutputInterface $output)
1617
{
1718
$this->exception = $exception;
1819
$this->output = $output;
19-
$this->input = $input;
20+
$this->application = $application;
2021
}
2122

2223
public function getException()
@@ -29,8 +30,8 @@ public function getOutput()
2930
return $this->output;
3031
}
3132

32-
public function getInput()
33+
public function getApplication()
3334
{
34-
return $this->input;
35+
return $this->application;
3536
}
3637
}

src/PHPCR/Shell/PhpcrSession.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace PHPCR\Shell;
4+
5+
use PHPCR\Shell\Phpcr\PhpcrSession as RealPhpcrSession;
6+
7+
class PhpcrSession extends RealPhpcrSession
8+
{
9+
}

src/PHPCR/Shell/Subscriber/ExceptionSubscriber.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ public static function getSubscribedEvents()
2525
public function handleException(CommandExceptionEvent $event)
2626
{
2727
$exception = $event->getException();
28-
$input = $event->getInput();
2928
$output = $event->getOutput();
30-
31-
// if verbose, just throw the whole exception back
32-
if ($input->hasOption('verbose') && $input->getOption('verbose')) {
33-
throw $exception;
34-
}
35-
29+
$application = $event->getApplication();
3630

3731
if ($exception instanceof UnsupportedRepositoryOperationException) {
3832
$output->writeln('<error>Unsupported repository operation: This repository is not capable of performing the requested action</error>');
@@ -42,8 +36,10 @@ public function handleException(CommandExceptionEvent $event)
4236
$output->writeln('<error>Not implemented: ' . $exception->getMessage() . '</error>');
4337
}
4438

45-
$output->writeln($exception->getTraceAsString());
46-
4739
$output->writeln('<error>[' . get_class($exception) .'] ' . $exception->getMessage() . '</error>');
40+
41+
if ($application->isDebug()) {
42+
$output->writeln('<comment>' . $exception->getTraceAsString() . '</comment>');
43+
}
4844
}
4945
}

src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@ public function handleProfileInit(ProfileInitEvent $e)
7474
$output->writeln('<info>No connection parameters, given. Select an existing profile:</info>');
7575
$output->writeln('');
7676

77-
foreach ($profileNames as $i => $profileName) {
78-
$output->writeln(sprintf(' (%d) <comment>%s</comment>', $i, $profileName));
79-
}
80-
81-
$output->writeln('');
8277

8378
$selectedName = null;
8479
while (null === $selectedName) {
85-
$number = $this->questionHelper->ask($input, $output, new Question('<info>Enter profile number</info>: '));
80+
$number = $this->questionHelper->select(
81+
$output,
82+
'<info>Choose a profile</info>: ',
83+
$profileNames
84+
);
8685

8786
if (!isset($profileNames[$number])) {
8887
$output->writeln('<error>Invalid selection!</error>');

0 commit comments

Comments
 (0)