mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 22:18:40 +00:00
fix #180
This commit is contained in:
parent
0e8876ce4d
commit
1ae4bba960
|
|
@ -338,10 +338,10 @@ class Commit
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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])) {
|
if (!isset($this->files[$path])) {
|
||||||
throw new \Exception();
|
$this->files[$path] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->files[$path][$line])) {
|
if (!isset($this->files[$path][$line])) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,27 @@ class CommitTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'/some/file/path2' => []
|
'/some/file/path2' => []
|
||||||
], $commit->getFiles());
|
], $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()
|
public function testMessage()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user