You are here

public function EntityFileTest::testGetDirectory in Zircon Profile 8

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

Tests various invocations of the getDirectory() method.

File

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

Class

EntityFileTest
Tests the entity file destination plugin.

Namespace

Drupal\file\Tests\Migrate

Code

public function testGetDirectory() {
  $plugin = $this->destination;
  $method = new \ReflectionMethod($plugin, 'getDirectory');
  $method
    ->setAccessible(TRUE);
  $this
    ->assertEqual('public://foo', $method
    ->invoke($plugin, 'public://foo/baz.txt'));
  $this
    ->assertEqual('/path/to', $method
    ->invoke($plugin, '/path/to/foo.txt'));

  // A directory like public:// (no path) needs to resolve to a physical path.
  $fs = \Drupal::getContainer()
    ->get('file_system');
  $this
    ->assertEqual($fs
    ->realpath(Settings::get('file_public_path')), $method
    ->invoke($plugin, 'public://foo.txt'));
}