Skip to content

Commit 00b57b7

Browse files
authored
Added tests for empty commit messages (#196)
* added tests for empty commit messages * cosmetic changes for continuous-integration/styleci/pr * added phpspec/prophecy to composer-json, so the tests pass * added phpspec/prophecy compatibility with php 5.6 * sorted composer.json alphabetically and removed "^1.15"
1 parent 33ae0a2 commit 00b57b7

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"require-dev": {
4444
"ext-fileinfo": "*",
45+
"phpspec/prophecy": "^1.10.2",
4546
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.20 || ^9.5.9",
4647
"psr/log": "^1.0"
4748
},

tests/Gitonomy/Git/Tests/AbstractTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ abstract class AbstractTest extends TestCase
2020
{
2121
const REPOSITORY_URL = 'https://github.com/gitonomy/foobar.git';
2222

23+
const NO_MESSAGE_COMMIT = '011cd0c1625190d2959ee9a8f9f822006d94b661';
2324
const LONGFILE_COMMIT = '4f17752acc9b7c54ba679291bf24cb7d354f0f4f';
2425
const BEFORE_LONGFILE_COMMIT = 'e0ec50e2af75fa35485513f60b2e658e245227e9';
2526
const LONGMESSAGE_COMMIT = '3febd664b6886344a9b32d70657687ea4b1b4fab';

tests/Gitonomy/Git/Tests/CommitTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Gitonomy\Git\Diff\Diff;
1717
use Gitonomy\Git\Exception\InvalidArgumentException;
1818
use Gitonomy\Git\Exception\ReferenceNotFoundException;
19+
use Gitonomy\Git\Repository;
1920
use Gitonomy\Git\Tree;
2021

2122
class CommitTest extends AbstractTest
@@ -189,6 +190,31 @@ public function testGetMessage($repository)
189190
$this->assertEquals('add a long file'."\n", $commit->getMessage());
190191
}
191192

193+
/**
194+
* @dataProvider provideFoobar
195+
*
196+
* @param $repository Repository
197+
*/
198+
public function testGetEmptyMessage($repository)
199+
{
200+
$commit = $repository->getCommit(self::NO_MESSAGE_COMMIT);
201+
202+
$this->assertEquals('', $commit->getMessage());
203+
}
204+
205+
/**
206+
* @dataProvider provideFoobar
207+
*
208+
* @param $repository Repository
209+
*/
210+
public function testGetEmptyMessageFromLog($repository)
211+
{
212+
$commit = $repository->getCommit(self::NO_MESSAGE_COMMIT);
213+
$commitMessageFromLog = $commit->getLog()->getCommits()[0]->getMessage();
214+
215+
$this->assertEquals('', $commitMessageFromLog);
216+
}
217+
192218
/**
193219
* This test ensures that GPG signed commits does not break the reading of a commit
194220
* message.

0 commit comments

Comments
 (0)