public function FileTest::testMove

File

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

Class

FileTest

Namespace

Symfony\Component\HttpFoundation\Tests\File

Code

public function testMove() {
  $path = __DIR__ . '/Fixtures/test.copy.gif';
  $targetDir = __DIR__ . '/Fixtures/directory';
  $targetPath = $targetDir . '/test.copy.gif';
  @unlink($path);
  @unlink($targetPath);
  copy(__DIR__ . '/Fixtures/test.gif', $path);
  $file = new File($path);
  $movedFile = $file
    ->move($targetDir);
  $this
    ->assertInstanceOf('Symfony\\Component\\HttpFoundation\\File\\File', $movedFile);
  $this
    ->assertTrue(file_exists($targetPath));
  $this
    ->assertFalse(file_exists($path));
  $this
    ->assertEquals(realpath($targetPath), $movedFile
    ->getRealPath());
  @unlink($targetPath);
}