@@ -174,44 +174,55 @@ public function testIgnoreFile()
174
174
$ this ->assertEquals ('File path was not valid. Please check that the file exists. ' ,$ message );
175
175
}
176
176
177
+ /**
178
+ * @expectedException \VersionControl\GitCommandBundle\GitCommands\Exception\FileStatusException
179
+ */
180
+ public function testUnTrackFileExceptionFromRepoNotCommitted ()
181
+ {
182
+ // make your exception assertions
183
+ //$this->expectException(\VersionControl\GitCommandBundle\GitCommands\Exception\FileStatusException::class);
184
+ //$this->expectExceptionMessage('Please commit all files first');
185
+
186
+ $ filesCommand = $ this ->gitCommands ->command ('files ' );
187
+ $ filesCommand ->unTrackFile ('test ' );
188
+
189
+ }
177
190
178
191
public function testUnTrackFile ()
179
192
{
180
193
$ filesCommand = $ this ->gitCommands ->command ('files ' );
181
194
182
- //$this->assertTrue($filesCommand->isFileTracked('test'),'Test that test file is tracked');
195
+ //Commit all files
196
+ $ this ->gitCommands ->command ('commit ' )->stageAll ();
197
+ $ this ->gitCommands ->command ('commit ' )->commit ('second commit ' , 'Paul Schweppe <paulschweppe@gmail.com> ' );
183
198
184
- //Some files are not commits so an exception will be thrown
185
- $ message = '' ;
186
- try {
187
- $ filesCommand ->unTrackFile ('test ' );
188
- }catch (\VersionControl \GitCommandBundle \GitCommands \Exception \FileStatusException $ e ){
189
- $ message = $ e ->getMessage ();
190
- }
191
- $ this ->assertEquals ('Please commit all files first ' ,$ message );
199
+ //Untrack file should now work
200
+ $ response = $ filesCommand ->unTrackFile ('test ' );
201
+ $ this ->assertContains ('Please commit to complete the removal ' ,$ response );
202
+
203
+ }
204
+
205
+ public function testFileNolongerTrackAfterUntrackFile ()
206
+ {
207
+ $ filesCommand = $ this ->gitCommands ->command ('files ' );
192
208
193
209
//Commit all files
194
210
$ this ->gitCommands ->command ('commit ' )->stageAll ();
195
211
$ this ->gitCommands ->command ('commit ' )->commit ('second commit ' , 'Paul Schweppe <paulschweppe@gmail.com> ' );
196
212
197
213
//Untrack file should now work
198
- $ response2 = $ filesCommand ->unTrackFile ('test ' );
199
- $ this ->assertContains ('Please commit to complete the removal ' ,$ response2 );
214
+ $ filesCommand ->unTrackFile ('test ' );
200
215
201
- //Add test to .gitignore
202
- $ this ->updateFile ('.gitignore ' ,null , 'test ' );
216
+ //Add test to .gitignore. Must happen before commit
217
+ $ this ->updateFile ('.gitignore ' ,'test ' );
203
218
204
219
//Commit change to untracked file
205
- //$this->command->runCommand('git add .');
206
- //$this->gitCommands->command('commit')->stageAll();
207
- //$this->gitCommands->command('commit')->commit('Remove file from git index', 'Paul Schweppe <paulschweppe@gmail.com>');
220
+ $ this ->gitCommands ->command ('commit ' )->stageAll ();
221
+ $ this ->gitCommands ->command ('commit ' )->commit ('Remove file from git index ' , 'Paul Schweppe <paulschweppe@gmail.com> ' );
208
222
209
223
//Test that file is no longer tracked
210
224
$ this ->assertFalse ($ filesCommand ->isFileTracked ('test ' ),'Test that test file is no longer tracked ' );
211
225
212
-
213
-
214
-
215
226
}
216
227
217
228
0 commit comments