66
77use PHPUnit \Framework \Attributes \Test ;
88use Stolt \LeanPackage \Analyser ;
9+ use Stolt \LeanPackage \Commands \CreateCommand ;
910use Stolt \LeanPackage \Commands \UpdateCommand ;
1011use Stolt \LeanPackage \GitattributesFileRepository ;
1112use Stolt \LeanPackage \Helpers \Str as OsHelper ;
@@ -79,7 +80,6 @@ public function updatesExistingGitattributesAndReplacesHeader(): void
7980 $ this ->assertStringContainsString ('tests/ ' , $ content );
8081 $ this ->assertStringContainsString ('export-ignore ' , $ content );
8182 }
82-
8383 #[Test]
8484 public function failsWhenNoGitattributesFileIsPresent (): void
8585 {
@@ -100,4 +100,33 @@ public function failsWhenNoGitattributesFileIsPresent(): void
100100 ->assertFaulty ()
101101 ->assertOutputContains ('No .gitattributes file found. Use the create command to create one first. ' );
102102 }
103+
104+ #[Test]
105+ public function printsExpectedContentWithoutWritingAFile (): void
106+ {
107+ $ analyser = (new Analyser (new Finder (new PhpPreset ())))->setDirectory ($ this ->temporaryDirectory );
108+ $ repository = new GitattributesFileRepository ($ analyser );
109+ $ command = new UpdateCommand ($ analyser , $ repository );
110+
111+ $ artifactFilenames = ['README.md ' , '.gitignore ' , 'phpunit.xml.dist ' ];
112+
113+ $ this ->createTemporaryFiles (
114+ $ artifactFilenames ,
115+ ['tests ' ]
116+ );
117+
118+ $ result = TestCommand::for ($ command )
119+ ->addArgument ($ this ->temporaryDirectory )
120+ ->addOption ('dry-run ' )
121+ ->addOption ('align-export-ignores ' )
122+ ->execute ()
123+ ->assertSuccessful ();
124+
125+ $ output = $ result ->output ();
126+
127+ $ this ->assertStringContainsString ('export-ignore ' , $ output );
128+ $ this ->assertStringNotContainsString ('has been updated ' , $ output );
129+
130+ $ this ->assertFileDoesNotExist ($ this ->temporaryDirectory . DIRECTORY_SEPARATOR . '.gitattributes ' );
131+ }
103132}
0 commit comments