Skip to content

Commit 8fda423

Browse files
committed
Fixed test for session:export:view, added CHANGELOG
1 parent 1a75901 commit 8fda423

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# alpha2 / dev-master
2+
3+
- Added `--pretty` option to `session:export:view` command to output formatted XML
4+
- Ask confirmation before overwriting file in `session:export:view`

features/phpcr_session_export_view.feature

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ Feature: Export the repository to an XML file
2828
Invalid path 'cms'
2929
"""
3030

31-
Scenario: Export to an existing file
31+
Scenario: Export to an existing file (should overwrite as --no-interaction is specified)
3232
Given the file "foobar.xml" exists
33-
And I execute the "session:export:view /tests_general_base foobar.xml" command
34-
Then the command should fail
35-
And the output should contain:
36-
"""
37-
File "foobar.xml" already exists.
38-
"""
33+
And I execute the "session:export:view /tests_general_base foobar.xml --no-interaction" command
34+
Then the command should not fail
3935

4036
Scenario: Export non recursive
4137
Given I execute the "session:export:view /tests_general_base foobar.xml --no-recurse" command
@@ -51,3 +47,10 @@ Feature: Export the repository to an XML file
5147
Scenario: Export the document view
5248
Given I execute the "session:export:view / foobar.xml --document" command
5349
Then the command should not fail
50+
51+
Scenario: Export the document view in pretty way
52+
Given I execute the "session:export:view / foobar.xml --pretty" command
53+
Then the command should not fail
54+
And the file "foobar.xml" should exist
55+
And the xpath count "/sv:node" is "1" in file "foobar.xml"
56+
And the xpath count "/sv:node/sv:node" is "1" in file "foobar.xml"

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ public function execute(InputInterface $input, OutputInterface $output)
6464
$dialog = $this->getHelper('dialog');
6565

6666
if (file_exists($file)) {
67-
$res = $dialog->askConfirmation($output, 'File already exists, overwrite?');
67+
$confirmed = true;
6868

69-
if (false === $res) {
69+
if (false === $input->getOption('no-interaction')) {
70+
$confirmed = $dialog->askConfirmation($output, 'File already exists, overwrite?');
71+
}
72+
73+
if (false === $confirmed) {
7074
return;
7175
}
7276
}

0 commit comments

Comments
 (0)