function ComposerHookTest::testScaffoldMessagesDoNotPrintTwice

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest::testScaffoldMessagesDoNotPrintTwice()
  2. 10 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest::testScaffoldMessagesDoNotPrintTwice()
  3. 11.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest::testScaffoldMessagesDoNotPrintTwice()

Tests to see if scaffold messages are omitted when running scaffold twice.

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php, line 123

Class

ComposerHookTest
Tests Composer Hooks that run scaffold operations.

Namespace

Drupal\Tests\Composer\Plugin\Scaffold\Functional

Code

public function testScaffoldMessagesDoNotPrintTwice() {
    $topLevelProjectDir = 'drupal-drupal';
    $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.
    $stdout = $this->mustExec("composer install --no-ansi", $sut);
    $this->assertStringContainsString('- Copy [web-root]/index.php from assets/index.php', $stdout);
    $this->assertStringContainsString('- Copy [web-root]/update.php from assets/update.php', $stdout);
    // Run scaffold operation again. It should not print anything.
    $stdout = $this->mustExec("composer scaffold --no-ansi", $sut);
    $this->assertEquals('', $stdout);
    // Delete a file and run it again. It should re-scaffold the removed file.
    unlink("{$sut}/index.php");
    $stdout = $this->mustExec("composer scaffold --no-ansi", $sut);
    $this->assertStringContainsString('- Copy [web-root]/index.php from assets/index.php', $stdout);
    $this->assertStringNotContainsString('- Copy [web-root]/update.php from assets/update.php', $stdout);
}

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