function SymlinkValidatorTest::testSymlinksNotAllowedOnWindows

Tests that symlinks are not supported on Windows, even if they're safe.

File

core/modules/package_manager/tests/src/Kernel/SymlinkValidatorTest.php, line 161

Class

SymlinkValidatorTest
@covers \Drupal\package_manager\Validator\SymlinkValidator[[api-linebreak]] @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testSymlinksNotAllowedOnWindows() : void {
  $environment = $this->prophesize(EnvironmentInterface::class);
  $environment->isWindows()
    ->willReturn(TRUE);
  $environment->setTimeLimit(Argument::type('int'))
    ->willReturn(TRUE);
  $this->container
    ->set(EnvironmentInterface::class, $environment->reveal());
  $project_root = $this->container
    ->get(PathLocator::class)
    ->getProjectRoot();
  // Relative symlinks must be made from their actual directory to be
  // correctly evaluated.
  chdir($project_root);
  symlink('composer.json', 'composer.link');
  $result = ValidationResult::createError([
    $this->t('The %which directory at %dir contains links, which is not supported on Windows. The first one is %file.', [
      '%which' => 'active',
      '%dir' => $project_root,
      '%file' => $project_root . '/composer.link',
    ]),
  ]);
  $this->assertStatusCheckResults([
    $result,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.