assertScaffoldedFile example

/** * Asserts that the appropriate file was replaced. * * Check the drupal/drupal-based project to confirm that the expected file was * replaced, and that files that were not supposed to be replaced remain * unchanged. */
  public function testDrupalDrupalFileWasReplaced() {
    $fixture_name = 'drupal-drupal-test-overwrite';
    $result = $this->scaffoldSut($fixture_name, FALSE, FALSE);

    $this->assertScaffoldedFile($result->docroot() . '/replace-me.txt', FALSE, 'from assets that replaces file');
    $this->assertScaffoldedFile($result->docroot() . '/keep-me.txt', FALSE, 'File in drupal-drupal-test-overwrite that is not replaced');
    $this->assertScaffoldedFile($result->docroot() . '/make-me.txt', FALSE, 'from assets that replaces file');
    $this->assertCommonDrupalAssetsWereScaffolded($result->docroot(), FALSE);
    $this->assertAutoloadFileCorrect($result->docroot());
    $this->assertScaffoldedFile($result->docroot() . '/robots.txt', FALSE, $fixture_name);
  }

  /** * Provides test values for testDrupalDrupalFileWasAppended. */
  public function scaffoldAppendTestValues() {
    
$this->markTestSkipped('We cannot run the scaffold upgrade test with Composer 2 until we have a stable version of drupal/core-composer-scaffold to start from that we can install with Composer 2.x.');
    }
    $this->fixturesDir = $this->fixtures->tmpDir($this->getName());
    $replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->fixtures->projectRoot()];
    $this->fixtures->cloneFixtureProjects($this->fixturesDir, $replacements);
    $topLevelProjectDir = 'drupal-drupal';
    $sut = $this->fixturesDir . '/' . $topLevelProjectDir;

    // First step: set up the Scaffold plug in. Ensure that scaffold operation     // ran. This is more of a control than a test.     $this->mustExec("composer install --no-ansi", $sut);
    $this->assertScaffoldedFile($sut . '/sites/default/default.settings.php', FALSE, 'A settings.php fixture file scaffolded from the scaffold-override-fixture');

    // Next, bring back packagist.org and install core-composer-scaffold:8.8.0.     // Packagist is disabled in the fixture; we bring it back by removing the     // line that disables it.     $this->mustExec("composer config --unset repositories.packagist.org", $sut);
    $stdout = $this->mustExec("composer require --no-ansi drupal/core-composer-scaffold:8.8.0 --no-plugins 2>&1", $sut);
    $this->assertStringContainsString(" - Installing drupal/core-composer-scaffold (8.8.0):", $stdout);

    // We can't force the path repo to re-install over the stable version     // without removing it, and removing it masks the bugs we are testing for.     // We will therefore make a git repo so that we can tag an explicit version
EOT;
    // At this point we should have a .gitignore file, because although we did     // not explicitly ask for .gitignore tracking, the vendor directory is not     // tracked, so the default in that instance is to manage .gitignore files.     $this->assertScaffoldedFile($sut . '/docroot/.gitignore', FALSE, $expected);
    $this->assertScaffoldedFile($sut . '/docroot/sites/.gitignore', FALSE, 'example.settings.local.php');
    $this->assertScaffoldedFile($sut . '/docroot/sites/default/.gitignore', FALSE, 'default.services.yml');
    $expected = <<<EOT M docroot/.gitignore ?? docroot/sites/.gitignore ?? docroot/sites/default/.gitignore EOT;
    // Check to see whether there are any untracked files. We expect that     // only the .gitignore files themselves should be untracked.     $stdout = $this->mustExec('git status --porcelain', $sut);
    $this->assertEquals(trim($expected)trim($stdout));
  }


  /** * Tests to see if scaffold operation runs at the correct times. */
  public function testComposerHooks() {
    $topLevelProjectDir = 'composer-hooks-fixture';
    $sut = $this->fixturesDir . '/' . $topLevelProjectDir;
    // First test: run composer install. This is the same as composer update     // since there is no lock file. Ensure that scaffold operation ran.     $this->mustExec("composer install --no-ansi", $sut);
    $this->assertScaffoldedFile($sut . '/sites/default/default.settings.php', FALSE, 'Test version of default.settings.php from drupal/core');
    // Run composer required to add in the scaffold-override-fixture. This     // project is "allowed" in our main fixture project, but not required.     // We expect that requiring this library should re-scaffold, resulting     // in a changed default.settings.php file.     $stdout = $this->mustExec("composer require --no-ansi --no-interaction fixtures/drupal-assets-fixture:dev-main fixtures/scaffold-override-fixture:dev-main", $sut);
    $this->assertScaffoldedFile($sut . '/sites/default/default.settings.php', FALSE, 'scaffolded from the scaffold-override-fixture');
    // Make sure that the appropriate notice informing us that scaffolding     // is allowed was printed.     $this->assertStringContainsString('Package fixtures/scaffold-override-fixture has scaffold operations, and is already allowed in the root-level composer.json file.', $stdout);
    // Delete one scaffold file, just for test purposes, then run     // 'composer update' and see if the scaffold file is replaced.
Home | Imprint | This part of the site doesn't use cookies.