Commit f27e61a6 authored by Vincent Petry's avatar Vincent Petry Committed by GitHub
Browse files

Merge pull request #26888 from owncloud/fix-26870

Fix warnings for ExcludeFileByNameFilterIterator test
parents 5a10d044 99e0a5a5
......@@ -58,11 +58,14 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator {
* @return bool
*/
public function accept() {
if($this->isDir()) {
/** @var \SplFileInfo $current */
$current = $this->current();
if ($current->isDir()) {
return true;
}
$currentFileName = $this->current()->getFilename();
$currentFileName = $current->getFilename();
if (in_array($currentFileName, $this->excludedFilenames, true)){
return false;
}
......
......@@ -25,13 +25,14 @@ use \OC\IntegrityCheck\Iterator\ExcludeFileByNameFilterIterator;
use Test\TestCase;
class ExcludeFileByNameFilterIteratorTest extends TestCase {
/** @var ExcludeFileByNameFilterIterator */
/** @var \PHPUnit_Framework_MockObject_MockBuilder */
protected $filter;
public function setUp() {
parent::setUp();
$this->filter = $this->getMockBuilder(ExcludeFileByNameFilterIterator::class)
->disableOriginalConstructor()
->setMethods(['current'])
->getMock()
;
......@@ -54,13 +55,17 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
* @param bool $expectedResult
*/
public function testAcceptForFiles($fileName, $expectedResult){
$iteratorMock = $this->createMock(\DirectoryIterator::class);
$iteratorMock = $this->getMockBuilder(\RecursiveDirectoryIterator::class)
->disableOriginalConstructor()
->setMethods(['getFilename', 'isDir'])
->getMock()
;
$iteratorMock->method('getFilename')
->will($this->returnValue($fileName))
;
$this->filter->method('isDir')
$iteratorMock->method('isDir')
->will($this->returnValue(false));
$this->filter->method('current')
->will($this->returnValue($iteratorMock))
;
......@@ -75,18 +80,22 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
* @param bool $fakeExpectedResult
*/
public function testAcceptForDirs($fileName, $fakeExpectedResult){
$iteratorMock = $this->createMock(\DirectoryIterator::class);
$iteratorMock = $this->getMockBuilder(\RecursiveDirectoryIterator::class)
->disableOriginalConstructor()
->setMethods(['getFilename', 'isDir'])
->getMock()
;
$iteratorMock->method('getFilename')
->will($this->returnValue($fileName))
;
$this->filter->method('isDir')
$iteratorMock->method('isDir')
->will($this->returnValue(true));
$this->filter->method('current')
->will($this->returnValue($iteratorMock))
;
$actualResult = $this->filter->accept();
$this->assertFalse($actualResult);
$this->assertTrue($actualResult);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment