public function ManageGitIgnoreTest::testManageGitIgnore in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ManageGitIgnoreTest::testManageGitIgnore()
Tests scaffold command correctly manages the .gitignore file.
File
- core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ManageGitIgnoreTest.php, line 105
Class
- ManageGitIgnoreTest
- Tests to see whether .gitignore files are correctly managed.
Namespace
Drupal\Tests\Composer\Plugin\Scaffold\FunctionalCode
public function testManageGitIgnore() {
// Note that the drupal-composer-drupal-project fixture does not
// have any configuration settings related to .gitignore management.
$sut = $this
->createSutWithGit('drupal-composer-drupal-project');
$this
->assertFileNotExists($sut . '/docroot/autoload.php');
$this
->assertFileNotExists($sut . '/docroot/index.php');
$this
->assertFileNotExists($sut . '/docroot/sites/.gitignore');
// Run the scaffold command.
$this->fixtures
->runScaffold($sut);
$this
->assertFileExists($sut . '/docroot/autoload.php');
$this
->assertFileExists($sut . '/docroot/index.php');
$expected = <<<EOT
/build
/.csslintrc
/.editorconfig
/.eslintignore
/.eslintrc.json
/.gitattributes
/.ht.router.php
/autoload.php
/index.php
/robots.txt
/update.php
/web.config
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));
}