Symfony\Component\Filesystem\Tests\FilesystemTest::testCopyOverridesExistingFileIfForced PHP Method

testCopyOverridesExistingFileIfForced() public method

    public function testCopyOverridesExistingFileIfForced()
    {
        $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);
        $this->filesystem->copy($sourceFilePath, $targetFilePath, true);
        $this->assertFileExists($targetFilePath);
        $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
    }
FilesystemTest