File tree Expand file tree Collapse file tree 3 files changed +65
-2
lines changed Expand file tree Collapse file tree 3 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -381,4 +381,35 @@ public function getMessage()
381
381
382
382
return $ this ->message ;
383
383
}
384
+
385
+ /**
386
+ * Returns the subject message (the first line)
387
+ *
388
+ * @return string The subject message
389
+ */
390
+ public function getSubjectMessage ()
391
+ {
392
+ $ message = $ this ->getMessage ();
393
+
394
+ $ lines = explode ("\n" , $ message );
395
+
396
+ return reset ($ lines );
397
+ }
398
+
399
+ /**
400
+ * Return the body message
401
+ *
402
+ * @return string The body message
403
+ */
404
+ public function getBodyMessage ()
405
+ {
406
+ $ message = $ this ->getMessage ();
407
+
408
+ $ lines = explode ("\n" , $ message );
409
+
410
+ array_shift ($ lines );
411
+ array_shift ($ lines );
412
+
413
+ return implode ("\n" , $ lines );
414
+ }
384
415
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase
21
21
22
22
const LONGFILE_COMMIT = '4f17752acc9b7c54ba679291bf24cb7d354f0f4f ' ;
23
23
const BEFORE_LONGFILE_COMMIT = 'e0ec50e2af75fa35485513f60b2e658e245227e9 ' ;
24
+ const LONGMESSAGE_COMMIT = '3febd664b6886344a9b32d70657687ea4b1b4fab ' ;
24
25
const INITIAL_COMMIT = '74acd054c8ec873ae6be044041d3a85a4f890ba5 ' ;
25
26
26
27
/**
Original file line number Diff line number Diff line change @@ -170,9 +170,40 @@ public function testGetMessage($repository)
170
170
*/
171
171
public function testGetShortMessage ($ repository )
172
172
{
173
- $ commit = $ repository ->getCommit (self ::LONGFILE_COMMIT );
173
+ $ commit = $ repository ->getCommit (self ::LONGMESSAGE_COMMIT );
174
+
175
+ $ this ->assertEquals ('Fixed perm... ' , $ commit ->getShortMessage (10 ));
176
+ }
177
+
178
+ /**
179
+ * @dataProvider provideFoobar
180
+ */
181
+ public function testGetSubjectMessage ($ repository )
182
+ {
183
+ $ commit = $ repository ->getCommit (self ::LONGMESSAGE_COMMIT );
184
+
185
+ $ this ->assertEquals ('Fixed permissions of test.sh. Basically I just run bash command. ' , $ commit ->getSubjectMessage ());
186
+ }
187
+
188
+ /**
189
+ * @dataProvider provideFoobar
190
+ */
191
+ public function testGetBodyMessage ($ repository )
192
+ {
193
+ $ commit = $ repository ->getCommit (self ::LONGMESSAGE_COMMIT );
194
+ $ message = <<<EOL
195
+ If you want to know everything,
196
+ I ran something like `chmox +x test.sh`
197
+
198
+ Hello and good bye.
199
+
200
+ EOL ;
201
+
202
+ $ this ->assertEquals ($ message , $ commit ->getBodyMessage ());
203
+
204
+ $ commit = $ repository ->getCommit (self ::INITIAL_COMMIT );
174
205
175
- $ this ->assertEquals ('add a long file ' , $ commit ->getShortMessage ());
206
+ $ this ->assertEquals ('' , $ commit ->getBodyMessage ());
176
207
}
177
208
178
209
/**
You can’t perform that action at this time.
0 commit comments