public function FileTest::testMoveToAnUnexistentDirectory

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php, line 129

Class

FileTest

Namespace

Symfony\Component\HttpFoundation\Tests\File

Code

public function testMoveToAnUnexistentDirectory() {
  $sourcePath = __DIR__ . '/Fixtures/test.copy.gif';
  $targetDir = __DIR__ . '/Fixtures/directory/sub';
  $targetPath = $targetDir . '/test.copy.gif';
  @unlink($sourcePath);
  @unlink($targetPath);
  @rmdir($targetDir);
  copy(__DIR__ . '/Fixtures/test.gif', $sourcePath);
  $file = new File($sourcePath);
  $movedFile = $file
    ->move($targetDir);
  $this
    ->assertFileExists($targetPath);
  $this
    ->assertFileNotExists($sourcePath);
  $this
    ->assertEquals(realpath($targetPath), $movedFile
    ->getRealPath());
  @unlink($sourcePath);
  @unlink($targetPath);
  @rmdir($targetDir);
}