You are here

public function ComposerHookTest::testScaffoldMessagesDoNotPrintTwice in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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

File

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

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