From b3a8bc10abb4199b800df9ea0aebc2a14bb63bf0 Mon Sep 17 00:00:00 2001 From: dantleech Date: Mon, 22 Aug 2016 22:14:50 +0100 Subject: [PATCH 1/7] Allow Symfony 3.0 --- .travis.yml | 3 +-- composer.json | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88cbe135..2e4e8703 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,12 @@ env: - BEHAT_SUITE=embedded - BEHAT_SUITE=cli - php: - 5.4 before_script: - composer self-update - - composer require "symfony/symfony" "2.6.*" --no-update + - composer require "symfony/symfony" "~3.0" --no-update - composer install - bash tests/bin/travis_jackrabbit.sh diff --git a/composer.json b/composer.json index 5dccd528..c43998f6 100644 --- a/composer.json +++ b/composer.json @@ -2,28 +2,25 @@ "name": "phpcr/phpcr-shell", "description": "Shell for PHPCR", "require": { - "symfony/console": "~2.4", + "symfony/console": "~2.4|~3.0", "jackalope/jackalope": "~1.1", "phpcr/phpcr": "~2.1", "phpcr/phpcr-utils": "~1.2", - "symfony/finder": "~2.3", - "symfony/serializer": "~2.3", - "symfony/yaml": "~2.3", - "symfony/dependency-injection": "~2.3", - "symfony/expression-language": "~2.4", - "dantleech/glob-finder": "~1.0" + "symfony/finder": "~2.3|~3.0", + "symfony/serializer": "~2.3|~3.0", + "symfony/yaml": "~2.3|~3.0", + "symfony/dependency-injection": "~2.3|~3.0", + "symfony/expression-language": "~2.4|~3.0", + "dantleech/glob-finder": "~1.0@dev" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require-dev": { - "symfony/symfony": "2.6", - "symfony/process": "~2.4", - "symfony/filesystem": "~2.4", + "symfony/symfony": "~2.6|~3.0", "phpunit/phpunit": "~3.7.28", - "behat/behat": "~3.0.0", - "phpspec/phpspec": "2.0", + "behat/behat": "~3.0", + "phpspec/phpspec": "3.0", "jackalope/jackalope-doctrine-dbal": "~1.1", - "jackalope/jackalope-jackrabbit": "~1.1", - "jackalope/jackalope-fs": "dev-master" + "jackalope/jackalope-jackrabbit": "~1.1" }, "suggest": { "jackalope/jackalope-doctrine-dbal": "To connect to jackalope doctrine-dbal", From 4cd1349786ca2b85f4e01d0790c7eae36e6a2787 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 14:53:04 +0100 Subject: [PATCH 2/7] Use new APIs --- composer.json | 4 +- .../Console/Application/ShellApplication.php | 2 +- .../AccessControlPrivilegeListCommand.php | 3 +- .../Console/Command/Phpcr/LockInfoCommand.php | 3 +- .../Command/Phpcr/LockTokenListCommand.php | 3 +- .../Console/Command/Phpcr/NodeInfoCommand.php | 3 +- .../Console/Command/Phpcr/NodeListCommand.php | 3 +- .../Command/Phpcr/NodeReferencesCommand.php | 5 +- .../Command/Phpcr/NodeTypeListCommand.php | 3 +- .../Phpcr/RepositoryDescriptorListCommand.php | 3 +- .../Phpcr/RetentionHoldListCommand.php | 3 +- .../Command/Phpcr/SessionInfoCommand.php | 3 +- .../Phpcr/SessionNamespaceListCommand.php | 3 +- .../Command/Phpcr/VersionHistoryCommand.php | 3 +- .../Command/Phpcr/WorkspaceListCommand.php | 3 +- .../Phpcr/WorkspaceNamespaceListCommand.php | 3 +- .../Command/Shell/AliasListCommand.php | 3 +- .../Command/Shell/ProfileShowCommand.php | 3 +- .../Console/Helper/ResultFormatterHelper.php | 7 ++- src/PHPCR/Shell/Console/Helper/Table.php | 21 ++++++++ .../Shell/Console/Helper/TableHelper.php | 48 ------------------- .../Shell/DependencyInjection/Container.php | 11 ++--- src/PHPCR/Shell/PhpcrShell.php | 2 +- .../Subscriber/ProfileLoaderSubscriber.php | 11 +++-- 24 files changed, 71 insertions(+), 85 deletions(-) create mode 100644 src/PHPCR/Shell/Console/Helper/Table.php delete mode 100644 src/PHPCR/Shell/Console/Helper/TableHelper.php diff --git a/composer.json b/composer.json index c43998f6..7d4b4ec4 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ }, "minimum-stability": "stable", "require-dev": { - "symfony/symfony": "~2.6|~3.0", - "phpunit/phpunit": "~3.7.28", + "symfony/symfony": "~3.0", + "phpunit/phpunit": "~4.0", "behat/behat": "~3.0", "phpspec/phpspec": "3.0", "jackalope/jackalope-doctrine-dbal": "~1.1", diff --git a/src/PHPCR/Shell/Console/Application/ShellApplication.php b/src/PHPCR/Shell/Console/Application/ShellApplication.php index 2433f6fa..691cb98c 100644 --- a/src/PHPCR/Shell/Console/Application/ShellApplication.php +++ b/src/PHPCR/Shell/Console/Application/ShellApplication.php @@ -272,7 +272,7 @@ protected function getDefaultCommand() * * {@inheritDoc} */ - public function renderException($exception, $output) + public function renderException(\Exception $exception, OutputInterface $output) { $output->writeln(sprintf('%s', $exception->getMessage())); } diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php index ac8d27fc..969c2c88 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use PHPCR\RepositoryInterface; +use PHPCR\Shell\Console\Helper\Table; class AccessControlPrivilegeListCommand extends BasePhpcrCommand { @@ -65,7 +66,7 @@ public function execute(InputInterface $input, OutputInterface $output) $privileges = $acm->getPrivileges($absPath); } - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Name')); foreach ($privileges as $privilege) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php index b08e710f..563bc5f8 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockInfoCommand.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; +use PHPCR\Shell\Console\Helper\Table; class LockInfoCommand extends BasePhpcrCommand { @@ -55,7 +56,7 @@ public function execute(InputInterface $input, OutputInterface $output) 'Session scoped?' => $lock->isSessionScoped() ? 'yes' : 'no', ); - $table = $this->get('helper.table')->create(); + $table = new Table($output); foreach ($info as $label => $value) { $table->addRow(array($label, $value)); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php index ce59a7c2..a253bbd7 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenListCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use PHPCR\RepositoryInterface; +use PHPCR\Shell\Console\Helper\Table; class LockTokenListCommand extends BasePhpcrCommand { @@ -41,7 +42,7 @@ public function execute(InputInterface $input, OutputInterface $output) $lockTokens = $lockManager->getLockTokens(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Token')); foreach ($lockTokens as $token) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php index dda41313..7f9f90b7 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use PHPCR\Shell\Console\Helper\Table; class NodeInfoCommand extends BasePhpcrCommand { @@ -75,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output) ); $output->writeln('' . $node->getPath() . ''); - $table = $this->get('helper.table')->create(); + $table = new Table($output); foreach ($info as $label => $value) { $table->addRow(array($label, $value)); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index 126f1e6f..a04cff70 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -20,6 +20,7 @@ use PHPCR\ItemNotFoundException; use PHPCR\PropertyInterface; use PHPCR\NodeInterface; +use PHPCR\Shell\Console\Helper\Table; class NodeListCommand extends BasePhpcrCommand { @@ -116,7 +117,7 @@ public function execute(InputInterface $input, OutputInterface $output) } foreach ($nodes as $node) { - $table = $this->get('helper.table')->create(); + $table = new Table($output); $this->renderNode($node, $table, array(), $filter); if ($table->getNumberOfRows() > 0) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php index 0c4a3941..dad26366 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeReferencesCommand.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use PHPCR\Shell\Console\Helper\Table; class NodeReferencesCommand extends BasePhpcrCommand { @@ -32,7 +33,7 @@ protected function configure() If the name parameter is null then all referring REFERENCES are returned regardless of name. HERE - ); + ); } public function execute(InputInterface $input, OutputInterface $output) @@ -52,7 +53,7 @@ public function execute(InputInterface $input, OutputInterface $output) $references['weak'] = $node->getWeakReferences($name ?: null); $references['strong'] = $node->getReferences($name ?: null); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array( 'Path', 'Property', 'Type', )); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php index 7d42d505..0fc9da8d 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeListCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use PHPCR\Shell\Console\Helper\Table; class NodeTypeListCommand extends BasePhpcrCommand { @@ -40,7 +41,7 @@ public function execute(InputInterface $input, OutputInterface $output) $nodeTypes = $nodeTypeManager->getAllNodeTypes(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Name', 'Primary Item Name', 'Abstract?', 'Mixin?', 'Queryable?')); foreach ($nodeTypes as $nodeType) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php index e5c4e905..d810d2f7 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RepositoryDescriptorListCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class RepositoryDescriptorListCommand extends BasePhpcrCommand { @@ -34,7 +35,7 @@ public function execute(InputInterface $input, OutputInterface $output) $repository = $session->getRepository(); $keys = $repository->getDescriptorKeys(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Key', 'Value', 'Standard?')); foreach ($keys as $key) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php index b2286254..01416452 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/RetentionHoldListCommand.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; +use PHPCR\Shell\Console\Helper\Table; class RetentionHoldListCommand extends BasePhpcrCommand { @@ -39,7 +40,7 @@ public function execute(InputInterface $input, OutputInterface $output) $absPath = $input->getArgument('absPath'); $holds = $retentionManager->getHolds($absPath); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Name')); foreach ($holds as $hold) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php index 6960b363..4b09d0a4 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionInfoCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class SessionInfoCommand extends BasePhpcrCommand { @@ -45,7 +46,7 @@ public function execute(InputInterface $input, OutputInterface $output) $attribute = $session->getAttribute($attributeName); } - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Key', 'Value')); foreach ($info as $key => $value) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php index d56f5173..e85d9552 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/SessionNamespaceListCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class SessionNamespaceListCommand extends BasePhpcrCommand { @@ -31,7 +32,7 @@ public function execute(InputInterface $input, OutputInterface $output) $session = $this->get('phpcr.session'); $prefixes = $session->getNamespacePrefixes(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Prefix', 'URI')); foreach ($prefixes as $prefix) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php index 1a65531e..6282bc22 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use PHPCR\RepositoryInterface; +use PHPCR\Shell\Console\Helper\Table; class VersionHistoryCommand extends BasePhpcrCommand { @@ -34,7 +35,7 @@ public function execute(InputInterface $input, OutputInterface $output) { $session = $this->get('phpcr.session'); $nodeHelper = $this->get('helper.node'); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $path = $input->getArgument('path'); $workspace = $session->getWorkspace(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php index 24cd4dae..384d0bf6 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceListCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use PHPCR\Shell\Console\Helper\Table; class WorkspaceListCommand extends BasePhpcrCommand { @@ -44,7 +45,7 @@ public function execute(InputInterface $input, OutputInterface $output) $workspace = $session->getWorkspace(); $availableWorkspaces = $workspace->getAccessibleWorkspaceNames(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Name')); foreach ($availableWorkspaces as $availableWorkspace) { if ($availableWorkspace == $workspace->getName()) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php index cfdeea0c..bfbd4b56 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceNamespaceListCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class WorkspaceNamespaceListCommand extends BasePhpcrCommand { @@ -34,7 +35,7 @@ public function execute(InputInterface $input, OutputInterface $output) $prefixes = $namespaceRegistry->getPrefixes(); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Prefix', 'URI')); foreach ($prefixes as $prefix) { diff --git a/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php b/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php index aa34f616..c7925e12 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/AliasListCommand.php @@ -14,6 +14,7 @@ use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class AliasListCommand extends BaseCommand { @@ -32,7 +33,7 @@ public function execute(InputInterface $input, OutputInterface $output) $config = $this->get('config.manager'); $aliases = $config->getConfig('alias'); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Alias', 'Command')); foreach ($aliases as $alias => $command) { diff --git a/src/PHPCR/Shell/Console/Command/Shell/ProfileShowCommand.php b/src/PHPCR/Shell/Console/Command/Shell/ProfileShowCommand.php index eea6594a..c3b19b42 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/ProfileShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/ProfileShowCommand.php @@ -14,6 +14,7 @@ use PHPCR\Shell\Console\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use PHPCR\Shell\Console\Helper\Table; class ProfileShowCommand extends BaseCommand { @@ -38,7 +39,7 @@ public function execute(InputInterface $input, OutputInterface $output) $output->writeln(''); foreach ($profile->toArray() as $domain => $config) { $output->writeln('' . $domain . ''); - $table = $this->get('helper.table')->create(); + $table = new Table($output); $table->setHeaders(array('Key', 'Value')); foreach ($config as $key => $value) { diff --git a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php index 71900664..44f35819 100644 --- a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php +++ b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php @@ -18,6 +18,7 @@ use PHPCR\NodeInterface; use PHPCR\PropertyInterface; use PHPCR\Shell\Config\Config; +use PHPCR\Shell\Console\Helper\Table; /** * Provide methods for formatting PHPCR objects @@ -27,13 +28,11 @@ class ResultFormatterHelper extends Helper { protected $textHelper; - protected $tableHelper; protected $config; - public function __construct(TextHelper $textHelper, TableHelper $tableHelper, Config $config) + public function __construct(TextHelper $textHelper, Config $config) { $this->textHelper = $textHelper; - $this->tableHelper = $tableHelper; $this->config = $config; } @@ -66,7 +65,7 @@ public function getPropertyTypeName($typeInteger) */ public function formatQueryResult(QueryResultInterface $result, OutputInterface $output, $elapsed) { - $table = $this->tableHelper->create(); + $table = new Table($output); $table->setHeaders(array_merge(array( 'Path', 'Index', diff --git a/src/PHPCR/Shell/Console/Helper/Table.php b/src/PHPCR/Shell/Console/Helper/Table.php new file mode 100644 index 00000000..25d269fe --- /dev/null +++ b/src/PHPCR/Shell/Console/Helper/Table.php @@ -0,0 +1,21 @@ +nbRows++; + parent::addRow($row); + } + + public function getNumberOfRows() + { + return $this->nbRows; + } +} diff --git a/src/PHPCR/Shell/Console/Helper/TableHelper.php b/src/PHPCR/Shell/Console/Helper/TableHelper.php deleted file mode 100644 index 50ad8e7a..00000000 --- a/src/PHPCR/Shell/Console/Helper/TableHelper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PHPCR\Shell\Console\Helper; - -use Symfony\Component\Console\Helper\TableHelper as OriginalTableHelper; - -/** - * Factory wrapper for Table class. - * - * This avoids the user of the "clone" hack, which doesn't work - * as of Symfony 2.5. - * - * @author Daniel Leech - */ -class TableHelper extends OriginalTableHelper -{ - private $numberOfRows = 0; - - public function __construct() - { - parent::__construct(false); - } - - public function create() - { - return new self(false); - } - - public function addRow(array $row) - { - parent::addRow($row); - $this->numberOfRows++; - } - - public function getNumberOfRows() - { - return $this->numberOfRows; - } -} diff --git a/src/PHPCR/Shell/DependencyInjection/Container.php b/src/PHPCR/Shell/DependencyInjection/Container.php index e6ee0ba2..e54e71a1 100644 --- a/src/PHPCR/Shell/DependencyInjection/Container.php +++ b/src/PHPCR/Shell/DependencyInjection/Container.php @@ -45,7 +45,7 @@ public function __construct($mode = PhpcrShell::MODE_STANDALONE) public function registerHelpers() { - $this->register('helper.question', 'Symfony\Component\Console\Helper\DialogHelper'); + $this->register('helper.question', 'Symfony\Component\Console\Helper\QuestionHelper'); $this->register('helper.editor', 'PHPCR\Shell\Console\Helper\EditorHelper'); $this->register('helper.path', 'PHPCR\Shell\Console\Helper\PathHelper'); $this->register('helper.repository', 'PHPCR\Shell\Console\Helper\RepositoryHelper') @@ -54,9 +54,7 @@ public function registerHelpers() $this->register('helper.node', 'PHPCR\Shell\Console\Helper\NodeHelper'); $this->register('helper.result_formatter', 'PHPCR\Shell\Console\Helper\ResultFormatterHelper') ->addArgument(new Reference('helper.text')) - ->addArgument(new Reference('helper.table')) ->addArgument(new Reference('config.config.phpcrsh')); - $this->register('helper.table', 'PHPCR\Shell\Console\Helper\TableHelper'); } public function registerConfig() @@ -68,8 +66,7 @@ public function registerConfig() $this->register('config.profile_loader', 'PHPCR\Shell\Config\ProfileLoader') ->addArgument(new Reference('config.manager')); $this->register('config.config.phpcrsh', 'PHPCR\Shell\Config\Config') - ->setFactoryService('config.manager') - ->setFactoryMethod('getPhpcrshConfig'); + ->setFactory([ new Reference('config.manager'), 'getPhpcrshConfig' ]); } public function registerPhpcr() @@ -98,8 +95,8 @@ public function registerPhpcr() $repositoryDefinition = $this->register('phpcr.repository'); $sessionDefinition = $this->register('phpcr.session'); - $repositoryDefinition->setFactoryService('phpcr.session_manager')->setFactoryMethod('getRepository'); - $sessionDefinition->setFactoryService('phpcr.session_manager')->setFactoryMethod('getSession'); + $repositoryDefinition->setFactory([ new Reference('phpcr.session_manager'), 'getRepository' ]); + $sessionDefinition->setFactory([ new Reference('phpcr.session_manager'), 'getSession' ]); $this->register('dtl.glob.helper', 'DTL\Glob\GlobHelper'); } diff --git a/src/PHPCR/Shell/PhpcrShell.php b/src/PHPCR/Shell/PhpcrShell.php index df5911cb..1246c0d1 100644 --- a/src/PHPCR/Shell/PhpcrShell.php +++ b/src/PHPCR/Shell/PhpcrShell.php @@ -25,7 +25,7 @@ class PhpcrShell { const APP_NAME = 'PHPCRSH'; - const APP_VERSION = 'dev-master'; + const APP_VERSION = '1.0.0-beta4'; const MODE_EMBEDDED_SHELL = 'shell'; const MODE_EMBEDDED_COMMAND = 'command'; diff --git a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php index 83de07cf..5fc16ea7 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php @@ -5,15 +5,16 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ProfileInitEvent; -use Symfony\Component\Console\Helper\DialogHelper; +use Symfony\Component\Console\Helper\QuestionHelper; use PHPCR\Shell\Config\ProfileLoader; use Symfony\Component\Console\Output\OutputInterface; use PHPCR\Shell\Config\Profile; +use Symfony\Component\Console\Question\Question; class ProfileLoaderSubscriber implements EventSubscriberInterface { protected $profileLoader; - protected $dialogHelper; + protected $questionHelper; public static function getSubscribedEvents() { @@ -22,10 +23,10 @@ public static function getSubscribedEvents() ); } - public function __construct(ProfileLoader $profileLoader, $dialogHelper) + public function __construct(ProfileLoader $profileLoader, $questionHelper) { $this->profileLoader = $profileLoader; - $this->dialogHelper = $dialogHelper; + $this->questionHelper = $questionHelper; } public function handleProfileInit(ProfileInitEvent $e) @@ -81,7 +82,7 @@ public function handleProfileInit(ProfileInitEvent $e) $selectedName = null; while (null === $selectedName) { - $number = $this->dialogHelper->ask($output, 'Enter profile number: '); + $number = $this->questionHelper->ask($input, $output, new Question('Enter profile number: ')); if (!isset($profileNames[$number])) { $output->writeln('Invalid selection!'); From 608ef63615065e873a4667ec7b915b85efec5dc3 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 14:58:21 +0100 Subject: [PATCH 3/7] Bumped deps --- .travis.yml | 4 ++-- composer.json | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e4e8703..cdc77ec6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,11 @@ env: - BEHAT_SUITE=cli php: - - 5.4 + - 5.6 before_script: - composer self-update - - composer require "symfony/symfony" "~3.0" --no-update + - composer require "symfony/symfony" "~2.8" --no-update - composer install - bash tests/bin/travis_jackrabbit.sh diff --git a/composer.json b/composer.json index 7d4b4ec4..d661b0cd 100644 --- a/composer.json +++ b/composer.json @@ -2,20 +2,20 @@ "name": "phpcr/phpcr-shell", "description": "Shell for PHPCR", "require": { - "symfony/console": "~2.4|~3.0", + "symfony/console": "~2.8|~3.0", "jackalope/jackalope": "~1.1", "phpcr/phpcr": "~2.1", "phpcr/phpcr-utils": "~1.2", - "symfony/finder": "~2.3|~3.0", - "symfony/serializer": "~2.3|~3.0", - "symfony/yaml": "~2.3|~3.0", - "symfony/dependency-injection": "~2.3|~3.0", - "symfony/expression-language": "~2.4|~3.0", + "symfony/finder": "~2.8|~3.0", + "symfony/serializer": "~2.8|~3.0", + "symfony/yaml": "~2.8|~3.0", + "symfony/dependency-injection": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", "dantleech/glob-finder": "~1.0@dev" }, "minimum-stability": "stable", "require-dev": { - "symfony/symfony": "~3.0", + "symfony/symfony": "~2.8|~3.0", "phpunit/phpunit": "~4.0", "behat/behat": "~3.0", "phpspec/phpspec": "3.0", From 45d1d626534ef5c2d49d2ff9f8b5bedf8f51d7f9 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 15:20:50 +0100 Subject: [PATCH 4/7] Fixed tests --- .../Helper/ResultFormatterHelperSpec.php | 3 +- .../Application/SessionApplicationTest.php | 29 ------------------- tests/PHPCR/Shell/Helper/NodeHelperTest.php | 26 ++++++++--------- tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php | 13 ++++----- 4 files changed, 18 insertions(+), 53 deletions(-) delete mode 100644 tests/PHPCR/Shell/Application/SessionApplicationTest.php diff --git a/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php index 0c2056d4..3ab0c63e 100644 --- a/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php +++ b/spec/PHPCR/Shell/Console/Helper/ResultFormatterHelperSpec.php @@ -20,11 +20,10 @@ class ResultFormatterHelperSpec extends ObjectBehavior { public function let( TextHelper $textHelper, - TableHelper $tableHelper, Config $config ) { - $this->beConstructedWith($textHelper, $tableHelper, $config); + $this->beConstructedWith($textHelper, $config); } public function it_is_initializable() diff --git a/tests/PHPCR/Shell/Application/SessionApplicationTest.php b/tests/PHPCR/Shell/Application/SessionApplicationTest.php deleted file mode 100644 index a672a10b..00000000 --- a/tests/PHPCR/Shell/Application/SessionApplicationTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PHPCR\Shell\Application; - -use PHPCR\Shell\Console\Application\SessionApplication; - -class SessionApplicationTest extends \PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->transport = $this->getMock( - 'PHPCR\Shell\Console\TransportInterface' - ); - $this->application = new SessionApplication(); - } - - public function testShellApplication() - { - } -} diff --git a/tests/PHPCR/Shell/Helper/NodeHelperTest.php b/tests/PHPCR/Shell/Helper/NodeHelperTest.php index d7a25cfb..1a97a36b 100644 --- a/tests/PHPCR/Shell/Helper/NodeHelperTest.php +++ b/tests/PHPCR/Shell/Helper/NodeHelperTest.php @@ -11,18 +11,19 @@ namespace PHPCR\Shell\Console\Helper; +use PHPCR\NodeInterface; + class NodeHelperTest extends \PHPUnit_Framework_TestCase { protected $nodeHelper; public function setUp() { - $this->session = $this->getMock('PHPCR\SessionInterface'); - $this->helper = new NodeHelper($this->session); - $this->node = $this->getMockBuilder('Jackalope\Node') - ->disableOriginalConstructor()->getMock(); + $this->session = $this->prophesize('PHPCR\SessionInterface'); + $this->helper = new NodeHelper($this->session->reveal()); + $this->node = $this->prophesize(NodeInterface::class); - $this->nodeType1 = $this->getMock('PHPCR\NodeType\NodeTypeInterface'); + $this->nodeType1 = $this->prophesize('PHPCR\NodeType\NodeTypeInterface'); } public function provideAssertNodeIsVersionable() @@ -38,21 +39,18 @@ public function provideAssertNodeIsVersionable() */ public function testAssertNodeIsVersionable($isVersionable) { - $this->node->expects($this->once()) - ->method('getMixinNodeTypes') - ->will($this->returnValue(array( - $this->nodeType1, - ))); + $this->node->getMixinNodeTypes()->willReturn([ + $this->nodeType1->reveal() + ]); + $this->node->getPath()->willReturn('/'); $nodeTypeName = $isVersionable ? 'mix:versionable' : 'nt:foobar'; - $this->nodeType1->expects($this->once()) - ->method('getName') - ->will($this->returnValue($nodeTypeName)); + $this->nodeType1->getName()->willReturn($nodeTypeName); if (false == $isVersionable) { $this->setExpectedException('\OutOfBoundsException', 'is not versionable'); } - $this->helper->assertNodeIsVersionable($this->node); + $this->helper->assertNodeIsVersionable($this->node->reveal()); } } diff --git a/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php b/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php index 0e6713bf..9f4a3741 100644 --- a/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php +++ b/tests/PHPCR/Shell/Phpcr/PhpcrSessionTest.php @@ -18,8 +18,8 @@ class PhpcrSessionTest extends \Phpunit_Framework_TestCase { public function setUp() { - $this->phpcr = $this->getMock('PHPCR\SessionInterface'); - $this->session = new PhpcrSession($this->phpcr); + $this->phpcr = $this->prophesize('PHPCR\SessionInterface'); + $this->session = new PhpcrSession($this->phpcr->reveal()); } public function provideChdir() @@ -80,12 +80,9 @@ public function provideMv() */ public function testMv($cwd, $relSrc, $relTar, $expSrc, $expTar) { - $this->phpcr->expects($this->once()) - ->method('move') - ->with($expSrc, $expTar); - $this->phpcr->expects($this->once()) - ->method('getNode') - ->will($this->throwException(new PathNotFoundException())); + $this->phpcr->move($expSrc, $expTar)->shouldBeCalled(); + + $this->phpcr->getNode('/bar', -1)->willThrow(new PathNotFoundException()); $this->session->setCwd($cwd); $this->session->move($relSrc, $relTar); } From cd6fcc6e95274d1ce138a646eac67c7f11773bc9 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 15:35:30 +0100 Subject: [PATCH 5/7] Falback to original exception rendering Different method signature on 2.8 and 3.0 makes overriding this tricky, and I am unsure of the benefits anyway. --- .../Shell/Console/Application/ShellApplication.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/PHPCR/Shell/Console/Application/ShellApplication.php b/src/PHPCR/Shell/Console/Application/ShellApplication.php index 691cb98c..1a75f906 100644 --- a/src/PHPCR/Shell/Console/Application/ShellApplication.php +++ b/src/PHPCR/Shell/Console/Application/ShellApplication.php @@ -267,16 +267,6 @@ protected function getDefaultCommand() return 'shell:path:show'; } - /** - * Render an exception to the console - * - * {@inheritDoc} - */ - public function renderException(\Exception $exception, OutputInterface $output) - { - $output->writeln(sprintf('%s', $exception->getMessage())); - } - /** * Wrap the add method and do not register commands which are unsupported by * the current transport. From 716f4f3ac42bfcfd91822634b5644adeae9431b8 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 15:51:05 +0100 Subject: [PATCH 6/7] Bumped glob finder --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d661b0cd..eef38927 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "symfony/yaml": "~2.8|~3.0", "symfony/dependency-injection": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", - "dantleech/glob-finder": "~1.0@dev" + "dantleech/glob-finder": "~1.0" }, "minimum-stability": "stable", "require-dev": { From 85a22a46e4a03712e44993fd6c004bad540c6d32 Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 23 Aug 2016 15:53:30 +0100 Subject: [PATCH 7/7] Bumped shell version --- src/PHPCR/Shell/PhpcrShell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PHPCR/Shell/PhpcrShell.php b/src/PHPCR/Shell/PhpcrShell.php index 1246c0d1..d9fae152 100644 --- a/src/PHPCR/Shell/PhpcrShell.php +++ b/src/PHPCR/Shell/PhpcrShell.php @@ -25,7 +25,7 @@ class PhpcrShell { const APP_NAME = 'PHPCRSH'; - const APP_VERSION = '1.0.0-beta4'; + const APP_VERSION = '1.0.0'; const MODE_EMBEDDED_SHELL = 'shell'; const MODE_EMBEDDED_COMMAND = 'command';