Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
migrate_source_csv
Commits
ddd5bbfb
Commit
ddd5bbfb
authored
Apr 27, 2020
by
maacl
Committed by
heddn
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3076365
by k_a_l, maacl, heddn: A more graceful failure for a missing CSV source file?
parent
225f26e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
src/Plugin/migrate/source/CSV.php
src/Plugin/migrate/source/CSV.php
+8
-1
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
+2
-2
No files found.
src/Plugin/migrate/source/CSV.php
View file @
ddd5bbfb
...
...
@@ -259,7 +259,14 @@ class CSV extends SourcePluginBase implements ConfigurableInterface {
* The reader.
*/
protected
function
createReader
()
{
return
Reader
::
createFromStream
(
fopen
(
$this
->
configuration
[
'path'
],
'r'
));
if
(
!
file_exists
(
$this
->
configuration
[
'path'
]))
{
throw
new
\
RuntimeException
(
sprintf
(
'File "%s" was not found.'
,
$this
->
configuration
[
'path'
]));
}
$csv
=
fopen
(
$this
->
configuration
[
'path'
],
'r'
);
if
(
!
$csv
)
{
throw
new
\
RuntimeException
(
sprintf
(
'File "%s" could not be opened.'
,
$this
->
configuration
[
'path'
]));
}
return
Reader
::
createFromStream
(
$csv
);
}
}
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
View file @
ddd5bbfb
...
...
@@ -359,8 +359,8 @@ EOD;
];
$csv
=
new
CSV
(
$configuration
,
$this
->
pluginId
,
$this
->
pluginDefinition
,
$this
->
migration
);
$this
->
expectException
(
Warning
::
class
);
$this
->
expectExceptionMessage
(
'
fopen(
non-existent-path
): failed to open stream: No such file or directory
'
);
$this
->
expectException
(
\
RuntimeException
::
class
);
$this
->
expectExceptionMessage
(
'
File "
non-existent-path
" was not found.
'
);
$csv
->
initializeIterator
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment