Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for empty commit messages #196

Merged
merged 5 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"require-dev": {
"ext-fileinfo": "*",
"phpspec/prophecy": "^1.10.2",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.20 || ^9.5.9",
"psr/log": "^1.0"
},
Expand Down
1 change: 1 addition & 0 deletions tests/Gitonomy/Git/Tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract class AbstractTest extends TestCase
{
const REPOSITORY_URL = 'https://github.com/gitonomy/foobar.git';

const NO_MESSAGE_COMMIT = '011cd0c1625190d2959ee9a8f9f822006d94b661';
const LONGFILE_COMMIT = '4f17752acc9b7c54ba679291bf24cb7d354f0f4f';
const BEFORE_LONGFILE_COMMIT = 'e0ec50e2af75fa35485513f60b2e658e245227e9';
const LONGMESSAGE_COMMIT = '3febd664b6886344a9b32d70657687ea4b1b4fab';
Expand Down
26 changes: 26 additions & 0 deletions tests/Gitonomy/Git/Tests/CommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Gitonomy\Git\Diff\Diff;
use Gitonomy\Git\Exception\InvalidArgumentException;
use Gitonomy\Git\Exception\ReferenceNotFoundException;
use Gitonomy\Git\Repository;
use Gitonomy\Git\Tree;

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

/**
* @dataProvider provideFoobar
*
* @param $repository Repository
*/
public function testGetEmptyMessage($repository)
{
$commit = $repository->getCommit(self::NO_MESSAGE_COMMIT);

$this->assertEquals('', $commit->getMessage());
}

/**
* @dataProvider provideFoobar
*
* @param $repository Repository
*/
public function testGetEmptyMessageFromLog($repository)
{
$commit = $repository->getCommit(self::NO_MESSAGE_COMMIT);
$commitMessageFromLog = $commit->getLog()->getCommits()[0]->getMessage();

$this->assertEquals('', $commitMessageFromLog);
}

/**
* This test ensures that GPG signed commits does not break the reading of a commit
* message.
Expand Down