public function testCopyWithOverrideWithReadOnlyTargetFails()
{
// skip test on Windows; PHP can't easily set file as unwritable on Windows
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.');
}
$sourceFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_source_file';
$targetFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_target_file';
file_put_contents($sourceFilePath, 'SOURCE FILE');
file_put_contents($targetFilePath, 'TARGET FILE');
// make sure both files have the same modification time
$modificationTime = time() - 1000;
touch($sourceFilePath, $modificationTime);
touch($targetFilePath, $modificationTime);
// make sure target is read-only
$this->filesystem->chmod($targetFilePath, 0444);
$this->filesystem->copy($sourceFilePath, $targetFilePath, true);
}