@@ -2228,6 +2228,66 @@ public function detectsNonGitattributeContentInStdinInput(): void
22282228 ->assertFaulty ();
22292229 }
22302230
2231+ #[Test]
2232+ #[RunInSeparateProcess]
2233+ public function detectsValidGitattributeContentInStdinInput (): void
2234+ {
2235+ if ((new OsHelper ())->isWindows ()) {
2236+ $ this ->markTestSkipped ('Skipping test on Windows systems ' );
2237+ }
2238+
2239+ $ artifactFilenames = [
2240+ '.buildignore ' ,
2241+ 'phpspec.yml.dist ' ,
2242+ '.php_cs.cache ' ,
2243+ 'composer.lock ' ,
2244+ ];
2245+
2246+ $ this ->createTemporaryFiles (
2247+ $ artifactFilenames ,
2248+ ['specs ' ]
2249+ );
2250+
2251+ $ gitattributesContent = <<<CONTENT
2252+ * text=auto
2253+
2254+ .buildignore export-ignore
2255+ phpspec.yml.dist export-ignore
2256+ specs/ export-ignore
2257+ .php_cs.cache export-ignore
2258+ composer.lock export-ignore
2259+ .gitignore export-ignore
2260+ .gitattributes export-ignore
2261+
2262+ CONTENT ;
2263+
2264+ $ this ->createTemporaryGitattributesFile ($ gitattributesContent );
2265+
2266+ $ application = new Application ();
2267+ $ fakeInputReader = new FakeInputReader ();
2268+ $ fakeInputReader ->set ($ gitattributesContent );
2269+
2270+ $ analyserCommand = new ValidateCommand (
2271+ new Analyser (new Finder (new PhpPreset ())),
2272+ new Validator (new Archive ($ this ->temporaryDirectory )),
2273+ $ fakeInputReader
2274+ );
2275+
2276+ $ application ->add ($ analyserCommand );
2277+ $ command = $ application ->find ('validate ' );
2278+
2279+ $ expectedDisplay = <<<CONTENT
2280+ The provided .gitattributes content is considered valid.
2281+
2282+ CONTENT ;
2283+
2284+ TestCommand::for ($ command )
2285+ ->addOption ('stdin-input ' )
2286+ ->execute ()
2287+ ->assertOutputContains ($ expectedDisplay )
2288+ ->assertSuccessful ();
2289+ }
2290+
22312291 /**
22322292 * @return array
22332293 */
0 commit comments