You are here

public function EntityFileTest::testIsLocationUnchanged in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/file/src/Tests/Migrate/EntityFileTest.php \Drupal\file\Tests\Migrate\EntityFileTest::testIsLocationUnchanged()

Tests various invocations of the isLocationUnchanged() method.

File

core/modules/file/src/Tests/Migrate/EntityFileTest.php, line 177
Contains \Drupal\file\Tests\Migrate\EntityFileTest.

Class

EntityFileTest
Tests the entity file destination plugin.

Namespace

Drupal\file\Tests\Migrate

Code

public function testIsLocationUnchanged() {
  $plugin = $this->destination;
  $method = new \ReflectionMethod($plugin, 'isLocationUnchanged');
  $method
    ->setAccessible(TRUE);
  $public_dir = Settings::get('file_public_path');

  // Due to the limitations of realpath(), the source file must exist.
  touch('public://foo.txt');
  $this
    ->assertTrue($method
    ->invoke($plugin, $public_dir . '/foo.txt', 'public://foo.txt'));
  unlink('public://foo.txt');
  $temporary_file = '/tmp/foo.txt';
  touch($temporary_file);
  $this
    ->assertTrue($method
    ->invoke($plugin, $temporary_file, 'temporary://foo.txt'));
  unlink($temporary_file);
}