@@ -230,9 +230,10 @@ public function testSetFromTag()
230
230
$ changeLog ->setFromTag ('DoesNotExist ' );
231
231
}
232
232
233
- public function testBuild ()
233
+ public function testBuildAscendingCommitOrder ()
234
234
{
235
235
$ changeLog = new GitChangeLog ();
236
+ $ changeLog ->setOptions ('tagOrderDesc ' , false );
236
237
$ testValues =
237
238
[
238
239
// No tags.
@@ -263,6 +264,40 @@ public function testBuild()
263
264
}
264
265
}
265
266
267
+ public function testBuildDescendingCommitOrder ()
268
+ {
269
+ $ changeLog = new GitChangeLog ();
270
+ $ changeLog ->setOptions ('commitOrder ' , 'DESC ' );
271
+ $ testValues =
272
+ [
273
+ // No tags.
274
+ [],
275
+ // Head Revision included.
276
+ ['HEAD ' => ['date ' => 'B ' , 'subjects ' => ['C ' , 'D ' ], 'hashes ' => [['E ' ], ['F ' ]]]],
277
+ // Dummy tag, no commits.
278
+ ['A ' => ['date ' => 'B ' , 'subjects ' => [], 'hashes ' => []]],
279
+ // Dummy tag and commits.
280
+ ['A ' => ['date ' => 'B ' , 'subjects ' => ['C ' , 'D ' ], 'hashes ' => [['E ' , 'F ' ], ['G ' ]]]],
281
+ ];
282
+ $ expectedValues =
283
+ [
284
+ //No tags
285
+ "# Changelog \n\nNo changes. \n" ,
286
+ // Head Revision included.
287
+ "# Changelog \n\n## Upcoming changes (Undetermined) \n\n* D (F) \n* C (E) \n" ,
288
+ // Dummy tag, no commits.
289
+ "# Changelog \n\n## A (B) \n\n* No changes. \n" ,
290
+ // Dummy tag and commits.
291
+ "# Changelog \n\n## A (B) \n\n* D (G) \n* C (E, F) \n" ,
292
+ ];
293
+
294
+ foreach ($ testValues as $ key => $ value ) {
295
+ $ this ->setPrivateProperty ($ changeLog , 'commitData ' , $ value );
296
+ $ changeLog ->build ();
297
+ $ this ->assertEquals ($ expectedValues [$ key ], $ changeLog ->get ());
298
+ }
299
+ }
300
+
266
301
public function testProcessCommitData ()
267
302
{
268
303
$ changeLog = new ReflectionClass ('DigiLive\GitChangeLog\GitChangeLog ' );
0 commit comments