function ScaffoldTest::assertAutoloadFileCorrect

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ScaffoldTest::assertAutoloadFileCorrect()

Assert that the autoload file was scaffolded and contains correct path.

@internal

Parameters

string $docroot: Location of the doc root, where autoload.php should be written.

bool $relocated_docroot: Whether the document root is relocated or now.

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php, line 420

Class

ScaffoldTest
Tests Composer Scaffold.

Namespace

Drupal\Tests\Composer\Plugin\Scaffold\Functional

Code

protected function assertAutoloadFileCorrect(string $docroot, bool $relocated_docroot = FALSE) : void {
  $autoload_path = $docroot . '/autoload.php';
  // Ensure that the autoload.php file was written.
  $this->assertFileExists($autoload_path);
  $contents = file_get_contents($autoload_path);
  $expected = "return require __DIR__ . '/vendor/autoload.php';";
  if ($relocated_docroot) {
    $expected = "return require __DIR__ . '/../vendor/autoload.php';";
  }
  $this->assertStringContainsString($expected, $contents);
}

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