files = [];
$this->fileList = new FileList(self::$config, self::$ruleset);
}//end initializeFileList()
/**
* Test adding a file to the list.
*
* @param string $fileName The name of the file to add.
* @param bool $passFileObject Whether to pass a File object to addFile() or not.
*
* @dataProvider dataAddFile
*
* @return void
*/
public function testAddFile($fileName, $passFileObject=false)
{
$fileObject = null;
if ($passFileObject === true) {
$fileObject = new File($fileName, self::$ruleset, self::$config);
}
$this->assertCount(0, $this->fileList);
$this->fileList->addFile($fileName, $fileObject);
$fileListArray = iterator_to_array($this->fileList);
$this->assertCount(1, $this->fileList, 'File count mismatch');
$this->assertArrayHasKey($fileName, $fileListArray, 'File not found in list');
if ($fileObject instanceof File) {
$this->assertSame($fileObject, $fileListArray[$fileName], 'File object mismatch');
} else {
$this->assertInstanceOf(
'PHP_CodeSniffer\Files\File',
$fileListArray[$fileName],
'File object not found in list'
);
}
}//end testAddFile()
/**
* Data provider for testAddFile.
*
* @return array