Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f19a97e3
Commit
f19a97e3
authored
May 30, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `yii\helpers\FileHelper::copyDirectory()` pattern not working
parent
243f0134
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
BaseFileHelper.php
framework/helpers/BaseFileHelper.php
+3
-0
FileHelperTest.php
tests/unit/framework/helpers/FileHelperTest.php
+38
-0
No files found.
framework/CHANGELOG.md
View file @
f19a97e3
...
@@ -25,6 +25,7 @@ Yii Framework 2 Change Log
...
@@ -25,6 +25,7 @@ Yii Framework 2 Change Log
-
Bug #3311: Fixed the bug that
`yii\di\Container::has()`
did not return correct value (mgrechanik, qiangxue)
-
Bug #3311: Fixed the bug that
`yii\di\Container::has()`
did not return correct value (mgrechanik, qiangxue)
-
Bug #3327: Fixed "Unable to find debug data" when logging objects with circular references (jarekkozak, samdark)
-
Bug #3327: Fixed "Unable to find debug data" when logging objects with circular references (jarekkozak, samdark)
-
Bug #3368: Fix for comparing numeric attributes in JavaScript (technixp)
-
Bug #3368: Fix for comparing numeric attributes in JavaScript (technixp)
-
Bug #3393: Fix
`yii\helpers\FileHelper::copyDirectory()`
pattern not working (klimov-paul)
-
Bug #3431: Allow using extended ErrorHandler class from the app namespace (cebe)
-
Bug #3431: Allow using extended ErrorHandler class from the app namespace (cebe)
-
Bug #3436: Fixed the issue that
`ServiceLocator`
still returns the old component after calling
`set()`
with a new definition (qiangxue)
-
Bug #3436: Fixed the issue that
`ServiceLocator`
still returns the old component after calling
`set()`
with a new definition (qiangxue)
-
Bug #3458: Fixed the bug that the image rendered by
`CaptchaAction`
was using a wrong content type (MDMunir, qiangxue)
-
Bug #3458: Fixed the bug that the image rendered by
`CaptchaAction`
was using a wrong content type (MDMunir, qiangxue)
...
...
framework/helpers/BaseFileHelper.php
View file @
f19a97e3
...
@@ -209,6 +209,9 @@ class BaseFileHelper
...
@@ -209,6 +209,9 @@ class BaseFileHelper
if
(
$handle
===
false
)
{
if
(
$handle
===
false
)
{
throw
new
InvalidParamException
(
'Unable to open directory: '
.
$src
);
throw
new
InvalidParamException
(
'Unable to open directory: '
.
$src
);
}
}
if
(
!
isset
(
$options
[
'basePath'
]))
{
$options
[
'basePath'
]
=
realpath
(
$src
);
}
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;
continue
;
...
...
tests/unit/framework/helpers/FileHelperTest.php
View file @
f19a97e3
...
@@ -407,4 +407,42 @@ class FileHelperTest extends TestCase
...
@@ -407,4 +407,42 @@ class FileHelperTest extends TestCase
FileHelper
::
localize
(
$viewFile
,
$currentLanguage
,
$sourceLanguage
)
FileHelper
::
localize
(
$viewFile
,
$currentLanguage
,
$sourceLanguage
)
);
);
}
}
/**
* @see https://github.com/yiisoft/yii2/issues/3393
*
* @depends testCopyDirectory
* @depends testFindFiles
*/
public
function
testCopyDirectoryExclude
()
{
$srcDirName
=
'test_src_dir'
;
$textFiles
=
[
'file1.txt'
=>
'text file 1 content'
,
'file2.txt'
=>
'text file 2 content'
,
];
$dataFiles
=
[
'file1.dat'
=>
'data file 1 content'
,
'file2.dat'
=>
'data file 2 content'
,
];
$this
->
createFileStructure
([
$srcDirName
=>
array_merge
(
$textFiles
,
$dataFiles
)
]);
$basePath
=
$this
->
testFilePath
;
$srcDirName
=
$basePath
.
DIRECTORY_SEPARATOR
.
$srcDirName
;
$dstDirName
=
$basePath
.
DIRECTORY_SEPARATOR
.
'test_dst_dir'
;
FileHelper
::
copyDirectory
(
$srcDirName
,
$dstDirName
,
[
'only'
=>
[
'*.dat'
]]);
$this
->
assertFileExists
(
$dstDirName
,
'Destination directory does not exist!'
);
$copiedFiles
=
FileHelper
::
findFiles
(
$dstDirName
);
$this
->
assertCount
(
2
,
$copiedFiles
,
'wrong files count copied'
);
foreach
(
$dataFiles
as
$name
=>
$content
)
{
$fileName
=
$dstDirName
.
DIRECTORY_SEPARATOR
.
$name
;
$this
->
assertFileExists
(
$fileName
);
$this
->
assertEquals
(
$content
,
file_get_contents
(
$fileName
),
'Incorrect file content!'
);
}
}
}
}
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