This commit is contained in:
Dennis Eichhorn 2018-09-04 21:22:33 +02:00
parent 0e8876ce4d
commit 1ae4bba960
2 changed files with 23 additions and 2 deletions

View File

@ -338,10 +338,10 @@ class Commit
*
* @since 1.0.0
*/
private function addChange(string $path, int $line, string $old, string $new) : void
public function addChanges(string $path, int $line, string $old, string $new) : void
{
if (!isset($this->files[$path])) {
throw new \Exception();
$this->files[$path] = [];
}
if (!isset($this->files[$path][$line])) {

View File

@ -51,6 +51,27 @@ class CommitTest extends \PHPUnit\Framework\TestCase
self::assertEquals([
'/some/file/path2' => []
], $commit->getFiles());
$commit->addChanges(__DIR__ . '/CommitTest.php', 1, '<?php', 'test');
self::assertTrue(
[
__DIR__ . '/CommitTest.php' => [
1 => [
'old' => '<?php',
'new' => 'test'
]
]
], $commit->getFiles());
}
/**
* @expectedException \Exception
*/
public function testDuplicateLineChange()
{
$commit = new Commit();
$commit->addChanges(__DIR__ . '/CommitTest.php', 1, '<?php', 'test');
$commit->addChanges(__DIR__ . '/CommitTest.php', 1, '<?php', 'test');
}
public function testMessage()