Skip to content

Commit e61492f

Browse files
committed
Merge pull request #128 from phpcr/various
Various
2 parents 2829b4e + d985b73 commit e61492f

16 files changed

+58
-54
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ dev-master
1111

1212
### Bug fixes
1313

14+
- [capability] Commands not being disabled based on capability
1415
- [config] Do not override CLI options with profile options
1516
- [node:remove] Cannot `node:remove` by UUID
1617
- [node:edit] Serialization of single value references doesn't work
18+
- [file:import] Irregular files are accepted
1719

1820
### Enhancements
1921

features/all/phpcr_file_import.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Feature: Import an external file as to a node
2727
And I execute the "file:import . phpcr.png" command
2828
Then the command should fail
2929

30+
Scenario: Import non-regular file onto existing file, force not specified
31+
Given I execute the "file:import foo ." command
32+
Then the command should fail
33+
3034
Scenario: Import a file onto existing file, force specified
3135
Given I execute the "file:import . phpcr.png" command
3236
And I execute the "file:import . phpcr.png --force" command

features/all/phpcr_query_update.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,16 @@ Feature: Execute a a raw UPDATE query in JCR_SQL2
140140
And the node at "/cms/articles/article1" should have the mixin "mix:mimeType"
141141
Then the node at "/cms/articles/article1" should have the mixin "mix:lockable"
142142

143+
Scenario Outline: Execute an invalid query
144+
Given I execute the "<query>" command
145+
Then the command should fail
146+
And I should see the following:
147+
"""
148+
InvalidQueryException
149+
"""
150+
Examples:
151+
| query |
152+
| UPDATE foo FOR fi |
153+
| UPDATE [nt:unstructured] mixin_foo('bar') |
154+
| UPDATE [nt:unstructured] APPLY mixin_foo('bar') |
155+
| UPDATE [nt:unstructured] mixin_foo'bar') |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use PHPCR\Shell\DependencyInjection\Container;
66
use PHPCR\Shell\Console\Helper\PhpcrHelper;
77
use PHPCR\Shell\PhpcrShell;
8+
use PHPCR\SessionInterface;
9+
use PHPCR\Shell\Phpcr\PhpcrSession;
810

911
/**
1012
* Subclass of the full ShellApplication for running as an EmbeddedApplication

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPCR\Shell\Console\Command\Phpcr\PhpcrShellCommand;
2222
use PHPCR\Shell\Config\Profile;
2323
use PHPCR\Shell\PhpcrShell;
24+
use PHPCR\Shell\Console\Command\Phpcr\BasePhpcrCommand;
2425

2526
/**
2627
* Main application for PHPCRSH
@@ -44,6 +45,11 @@ class ShellApplication extends Application
4445
*/
4546
protected $debug = false;
4647

48+
/**
49+
* @var boolean
50+
*/
51+
protected $initialized = false;
52+
4753
/**
4854
* Constructor - name and version inherited from SessionApplication
4955
*
@@ -55,7 +61,6 @@ public function __construct($container)
5561
$this->dispatcher = $container->get('event.dispatcher') ? : new EventDispatcher();
5662
$this->setDispatcher($this->dispatcher);
5763
$this->container = $container;
58-
$this->init();
5964
}
6065

6166
/**
@@ -74,12 +79,17 @@ public function setShowUnsupported($boolean)
7479
*/
7580
public function init()
7681
{
82+
if (true === $this->initialized) {
83+
return;
84+
}
85+
7786
$this->registerPhpcrCommands();
7887
$this->registerPhpcrStandaloneCommands();
7988
$this->registerShellCommands();
8089

8190
$event = new ApplicationInitEvent($this);
8291
$this->dispatcher->dispatch(PhpcrShellEvents::APPLICATION_INIT, $event);
92+
$this->initialized = true;
8393
}
8494

8595
/**
@@ -218,6 +228,8 @@ private function configureFormatter(OutputFormatter $formatter)
218228
*/
219229
public function doRun(InputInterface $input, OutputInterface $output)
220230
{
231+
$this->init();
232+
221233
// configure the formatter for the output
222234
$this->configureFormatter($output->getFormatter());
223235

@@ -272,7 +284,7 @@ public function add(Command $command)
272284
$command->setContainer($this->container);
273285
}
274286

275-
if ($command instanceof PhpcrShellCommand) {
287+
if ($command instanceof BasePhpcrCommand) {
276288
if ($this->showUnsupported || $command->isSupported()) {
277289
parent::add($command);
278290
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeFileImportCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ public function execute(InputInterface $input, OutputInterface $output)
7070
));
7171
}
7272

73+
if (!is_file($filePath)) {
74+
throw new \InvalidArgumentException(sprintf(
75+
'File "%s" is not a regular file.',
76+
$filePath
77+
));
78+
}
79+
7380
try {
7481
// first assume the user specified the path to the parent node
7582
$parentNode = $this->session->getNode($path);

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use PHPCR\RepositoryInterface;
910

1011
class VersionCheckinCommand extends BasePhpcrCommand
1112
{
@@ -42,7 +43,9 @@ protected function configure()
4243
If checkin succeeds, the change to the <comment>jcr:isCheckedOut</comment> property is
4344
dispatched immediately.
4445
HERE
45-
);
46+
);
47+
48+
$this->requiresDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED, true);
4649
}
4750

4851
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use PHPCR\RepositoryInterface;
910

1011
class VersionCheckoutCommand extends BasePhpcrCommand
1112
{
@@ -31,6 +32,7 @@ protected function configure()
3132
If this node is already checked-out, this method has no effect.
3233
HERE
3334
);
35+
$this->requiresDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED, true);
3436
}
3537

3638
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use PHPCR\RepositoryInterface;
910

1011
class VersionCheckpointCommand extends BasePhpcrCommand
1112
{
@@ -21,6 +22,7 @@ protected function configure()
2122
If this node is already checked-in, this method is equivalent to <info>version:checkout</info>.
2223
HERE
2324
);
25+
$this->requiresDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED, true);
2426
}
2527

2628
public function execute(InputInterface $input, OutputInterface $output)

src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use PHPCR\RepositoryInterface;
910

1011
class VersionHistoryCommand extends BasePhpcrCommand
1112
{
@@ -18,6 +19,7 @@ protected function configure()
1819
Lists the version history of the node given at <info>path</info>.
1920
HERE
2021
);
22+
$this->requiresDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED, true);
2123
}
2224

2325
public function execute(InputInterface $input, OutputInterface $output)

0 commit comments

Comments
 (0)