@@ -848,7 +848,9 @@ public function validateOnNonExistentGitattributesFilesWithCreationOptionCreates
848848
849849 $ this ->assertStringNotContainsString (GitattributesFileRepository::GENERATED_HEADER , $ commandTester ->getDisplay ());
850850 $ this ->assertStringNotContainsString (GitattributesFileRepository::MODIFIED_HEADER , $ commandTester ->getDisplay ());
851+
851852 $ commandTester ->assertCommandIsSuccessful ();
853+
852854 $ this ->assertFileExists (
853855 WORKING_DIRECTORY . DIRECTORY_SEPARATOR . '.gitattributes '
854856 );
@@ -1566,6 +1568,35 @@ public function createdHeaderIsReplacedByModifiedHeader(): void
15661568 );
15671569 }
15681570
1571+ #[Test]
1572+ public function addsCreatedHeaderAsExpected (): void
1573+ {
1574+ $ artifactFilenames = ['phpspec.yml.dist ' , 'version-increase-command ' ];
1575+
1576+ $ this ->createTemporaryFiles (
1577+ $ artifactFilenames ,
1578+ ['specs ' ]
1579+ );
1580+
1581+ $ command = $ this ->application ->find ('validate ' );
1582+ $ commandTester = new CommandTester ($ command );
1583+ $ commandTester ->execute ([
1584+ 'command ' => $ command ->getName (),
1585+ 'directory ' => WORKING_DIRECTORY ,
1586+ '--create ' => true ,
1587+ '--omit-header ' => false ,
1588+ ]);
1589+
1590+ $ commandTester ->assertCommandIsSuccessful ();
1591+ $ this ->assertFileExists (
1592+ WORKING_DIRECTORY . DIRECTORY_SEPARATOR . '.gitattributes '
1593+ );
1594+ $ this ->assertStringContainsString (
1595+ GitattributesFileRepository::GENERATED_HEADER ,
1596+ \file_get_contents (WORKING_DIRECTORY . DIRECTORY_SEPARATOR . '.gitattributes ' )
1597+ );
1598+ }
1599+
15691600 #[Test]
15701601 #[Ticket('https://github.com/raphaelstolt/lean-package-validator/issues/8 ' )]
15711602 #[DataProvider('optionProvider ' )]
@@ -1588,15 +1619,7 @@ public function incompleteGitattributesFileIsOverwritten(string $option): void
15881619 ['specs ' ]
15891620 );
15901621
1591- $ header = GitattributesFileRepository::GENERATED_HEADER . PHP_EOL . PHP_EOL ;
1592-
1593- if ($ option === '--overwrite ' ) {
1594- $ header = GitattributesFileRepository::MODIFIED_HEADER . PHP_EOL ;
1595- }
1596-
1597- if ($ option === '--create ' ) {
1598- $ header = GitattributesFileRepository::MODIFIED_HEADER . PHP_EOL . PHP_EOL ;
1599- }
1622+ $ header = GitattributesFileRepository::MODIFIED_HEADER . PHP_EOL ;
16001623
16011624 $ command = $ this ->application ->find ('validate ' );
16021625 $ commandTester = new CommandTester ($ command );
0 commit comments