You are here

protected function ManageGitIgnoreTest::createSutWithGit in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ManageGitIgnoreTest::createSutWithGit()
  2. 10 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ManageGitIgnoreTest::createSutWithGit()

Creates a system-under-test and initialize a git repository for it.

Parameters

string $fixture_name: The name of the fixture to use from core/tests/Drupal/Tests/Component/Scaffold/fixtures.

Return value

string The path to the fixture directory.

4 calls to ManageGitIgnoreTest::createSutWithGit()
ManageGitIgnoreTest::testAppendToEmptySettingsIsUnmanaged in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
Test appending to an unmanaged file, and confirm it is not .gitignored.
ManageGitIgnoreTest::testManageGitIgnore in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
Tests scaffold command correctly manages the .gitignore file.
ManageGitIgnoreTest::testUnmanagedGitIgnoreWhenDisabled in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
Tests scaffold command does not manage the .gitignore file when disabled.
ManageGitIgnoreTest::testUnmanagedGitIgnoreWhenGitNotAvailable in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
Tests scaffold command disables .gitignore management when git not present.

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php, line 85

Class

ManageGitIgnoreTest
Tests to see whether .gitignore files are correctly managed.

Namespace

Drupal\Tests\Composer\Plugin\Scaffold\Functional

Code

protected function createSutWithGit($fixture_name) {
  $this->fixturesDir = $this->fixtures
    ->tmpDir($this
    ->getName());
  $sut = $this->fixturesDir . '/' . $fixture_name;
  $replacements = [
    'SYMLINK' => 'false',
    'PROJECT_ROOT' => $this->projectRoot,
  ];
  $this->fixtures
    ->cloneFixtureProjects($this->fixturesDir, $replacements);

  // .gitignore files will not be managed unless there is a git repository.
  $this
    ->mustExec('git init', $sut);

  // Add some user info so git does not complain.
  $this
    ->mustExec('git config user.email "test@example.com"', $sut);
  $this
    ->mustExec('git config user.name "Test User"', $sut);
  $this
    ->mustExec('git add .', $sut);
  $this
    ->mustExec('git commit -m "Initial commit."', $sut);

  // Run composer install, but suppress scaffolding.
  $this->fixtures
    ->runComposer("install --no-ansi --no-scripts", $sut);
  return $sut;
}