Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
f27e61a6
Commit
f27e61a6
authored
Jan 09, 2017
by
Vincent Petry
Committed by
GitHub
Jan 09, 2017
Browse files
Merge pull request #26888 from owncloud/fix-26870
Fix warnings for ExcludeFileByNameFilterIterator test
parents
5a10d044
99e0a5a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php
View file @
f27e61a6
...
@@ -58,11 +58,14 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator {
...
@@ -58,11 +58,14 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator {
* @return bool
* @return bool
*/
*/
public
function
accept
()
{
public
function
accept
()
{
if
(
$this
->
isDir
())
{
/** @var \SplFileInfo $current */
$current
=
$this
->
current
();
if
(
$current
->
isDir
())
{
return
true
;
return
true
;
}
}
$currentFileName
=
$
this
->
current
()
->
getFilename
();
$currentFileName
=
$current
->
getFilename
();
if
(
in_array
(
$currentFileName
,
$this
->
excludedFilenames
,
true
)){
if
(
in_array
(
$currentFileName
,
$this
->
excludedFilenames
,
true
)){
return
false
;
return
false
;
}
}
...
...
tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
View file @
f27e61a6
...
@@ -25,13 +25,14 @@ use \OC\IntegrityCheck\Iterator\ExcludeFileByNameFilterIterator;
...
@@ -25,13 +25,14 @@ use \OC\IntegrityCheck\Iterator\ExcludeFileByNameFilterIterator;
use
Test\TestCase
;
use
Test\TestCase
;
class
ExcludeFileByNameFilterIteratorTest
extends
TestCase
{
class
ExcludeFileByNameFilterIteratorTest
extends
TestCase
{
/** @var
ExcludeFileByNameFilterIterato
r */
/** @var
\PHPUnit_Framework_MockObject_MockBuilde
r */
protected
$filter
;
protected
$filter
;
public
function
setUp
()
{
public
function
setUp
()
{
parent
::
setUp
();
parent
::
setUp
();
$this
->
filter
=
$this
->
getMockBuilder
(
ExcludeFileByNameFilterIterator
::
class
)
$this
->
filter
=
$this
->
getMockBuilder
(
ExcludeFileByNameFilterIterator
::
class
)
->
disableOriginalConstructor
()
->
disableOriginalConstructor
()
->
setMethods
([
'current'
])
->
getMock
()
->
getMock
()
;
;
...
@@ -54,13 +55,17 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
...
@@ -54,13 +55,17 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
* @param bool $expectedResult
* @param bool $expectedResult
*/
*/
public
function
testAcceptForFiles
(
$fileName
,
$expectedResult
){
public
function
testAcceptForFiles
(
$fileName
,
$expectedResult
){
$iteratorMock
=
$this
->
createMock
(
\
DirectoryIterator
::
class
);
$iteratorMock
=
$this
->
getMockBuilder
(
\
RecursiveDirectoryIterator
::
class
)
->
disableOriginalConstructor
()
->
setMethods
([
'getFilename'
,
'isDir'
])
->
getMock
()
;
$iteratorMock
->
method
(
'getFilename'
)
$iteratorMock
->
method
(
'getFilename'
)
->
will
(
$this
->
returnValue
(
$fileName
))
->
will
(
$this
->
returnValue
(
$fileName
))
;
;
$iteratorMock
->
method
(
'isDir'
)
$this
->
filter
->
method
(
'isDir'
)
->
will
(
$this
->
returnValue
(
false
));
->
will
(
$this
->
returnValue
(
false
));
$this
->
filter
->
method
(
'current'
)
$this
->
filter
->
method
(
'current'
)
->
will
(
$this
->
returnValue
(
$iteratorMock
))
->
will
(
$this
->
returnValue
(
$iteratorMock
))
;
;
...
@@ -75,18 +80,22 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
...
@@ -75,18 +80,22 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
* @param bool $fakeExpectedResult
* @param bool $fakeExpectedResult
*/
*/
public
function
testAcceptForDirs
(
$fileName
,
$fakeExpectedResult
){
public
function
testAcceptForDirs
(
$fileName
,
$fakeExpectedResult
){
$iteratorMock
=
$this
->
createMock
(
\
DirectoryIterator
::
class
);
$iteratorMock
=
$this
->
getMockBuilder
(
\
RecursiveDirectoryIterator
::
class
)
->
disableOriginalConstructor
()
->
setMethods
([
'getFilename'
,
'isDir'
])
->
getMock
()
;
$iteratorMock
->
method
(
'getFilename'
)
$iteratorMock
->
method
(
'getFilename'
)
->
will
(
$this
->
returnValue
(
$fileName
))
->
will
(
$this
->
returnValue
(
$fileName
))
;
;
$iteratorMock
->
method
(
'isDir'
)
$this
->
filter
->
method
(
'isDir'
)
->
will
(
$this
->
returnValue
(
true
));
->
will
(
$this
->
returnValue
(
true
));
$this
->
filter
->
method
(
'current'
)
$this
->
filter
->
method
(
'current'
)
->
will
(
$this
->
returnValue
(
$iteratorMock
))
->
will
(
$this
->
returnValue
(
$iteratorMock
))
;
;
$actualResult
=
$this
->
filter
->
accept
();
$actualResult
=
$this
->
filter
->
accept
();
$this
->
assert
Fals
e
(
$actualResult
);
$this
->
assert
Tru
e
(
$actualResult
);
}
}
}
}
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