@@ -98,6 +98,94 @@ public function createsAGitattributesFileWithNegatedExportIgnoreDirectives(): vo
9898 );
9999 }
100100
101+ #[Test]
102+ public function createsAGitattributesFileWithNegatedAndAlignedExportIgnoreDirectives (): void
103+ {
104+ $ artifactFilenames = ['LICENSE.md ' , '.gitignore ' , 'composer.json ' ];
105+
106+ $ this ->createTemporaryFiles (
107+ $ artifactFilenames ,
108+ ['tests ' , 'src ' , 'bin ' , 'vendor ' ]
109+ );
110+
111+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'bin ' , ['lpv ' ]);
112+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'src ' , ['Fake.php ' , 'AnotherFake.php ' ]);
113+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'vendor ' , ['FakeFileA ' , 'FakeFileB ' ]);
114+
115+ TestCommand::for ($ this ->getCommandInstance ())
116+ ->addArgument ($ this ->temporaryDirectory )
117+ ->addOption ('flavour ' , NegatedExportIgnoreAnalyser::EXPORT_IGNORE_NEGATED )
118+ ->addOption ('align-export-ignores ' )
119+ ->execute ()
120+ ->assertSuccessful ();
121+
122+ $ expectedGitattributesContent = <<<CONTENT
123+ # This file was generated by the lean package validator (http://git.io/lean-package-validator).
124+
125+ * text=auto eol=lf
126+
127+ * export-ignore
128+
129+ bin/ -export-ignore
130+ bin/lpv -export-ignore
131+ composer.json -export-ignore
132+ src/ -export-ignore
133+ src/** -export-ignore
134+ CONTENT ;
135+
136+ $ this ->assertFileExists ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . '.gitattributes ' );
137+ $ this ->assertStringContainsStringIgnoringLineEndings (
138+ $ expectedGitattributesContent ,
139+ \file_get_contents ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . '.gitattributes ' )
140+ );
141+ }
142+
143+ #[Test]
144+ public function createsAGitattributesFileWithNegatedExportIgnoreDirectivesAndTwoKeptArtefacts (): void
145+ {
146+ $ artifactFilenames = ['LICENSE.md ' , 'README.md ' , '.gitignore ' , 'composer.json ' ];
147+
148+ $ this ->createTemporaryFiles (
149+ $ artifactFilenames ,
150+ ['tests ' , 'src ' , 'bin ' , 'vendor ' ]
151+ );
152+
153+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'bin ' , ['lpv ' ]);
154+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'src ' , ['Fake.php ' , 'AnotherFake.php ' ]);
155+ $ this ->createTemporaryFilesInDirectory ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . 'vendor ' , ['FakeFileA ' , 'FakeFileB ' ]);
156+
157+ TestCommand::for ($ this ->getCommandInstance ())
158+ ->addArgument ($ this ->temporaryDirectory )
159+ ->addOption ('flavour ' , NegatedExportIgnoreAnalyser::EXPORT_IGNORE_NEGATED )
160+ ->addOption ('align-export-ignores ' )
161+ ->addOption ('keep-readme ' )
162+ ->addOption ('keep-license ' )
163+ ->execute ()
164+ ->assertSuccessful ();
165+
166+ $ expectedGitattributesContent = <<<CONTENT
167+ # This file was generated by the lean package validator (http://git.io/lean-package-validator).
168+
169+ * text=auto eol=lf
170+
171+ * export-ignore
172+
173+ bin/ -export-ignore
174+ bin/lpv -export-ignore
175+ composer.json -export-ignore
176+ LICENSE.md -export-ignore
177+ README.md -export-ignore
178+ src/ -export-ignore
179+ src/** -export-ignore
180+ CONTENT ;
181+
182+ $ this ->assertFileExists ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . '.gitattributes ' );
183+ $ this ->assertStringContainsStringIgnoringLineEndings (
184+ $ expectedGitattributesContent ,
185+ \file_get_contents ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . '.gitattributes ' )
186+ );
187+ }
188+
101189 #[Test]
102190 public function createsNewGitattributesFileWithHeaderAndExpectedContent (): void
103191 {
0 commit comments