You are here

protected function ScaffoldTest::assertAutoloadFileCorrect in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ScaffoldTest::assertAutoloadFileCorrect()
  2. 9 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.

4 calls to ScaffoldTest::assertAutoloadFileCorrect()
ScaffoldTest::testDrupalDrupalFileWasAppended in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
Tests a fixture where the robots.txt file is prepended / appended to.
ScaffoldTest::testDrupalDrupalFileWasReplaced in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
Asserts that the appropriate file was replaced.
ScaffoldTest::testProjectThatScaffoldsEmptyProject in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
Try to scaffold a project that allows a project with no scaffold files.
ScaffoldTest::testScaffoldOverridingSettingsExcludingHtaccess in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
Asserts that the drupal/assets scaffold files correct for sut.

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);
}