Skip to content

Commit d5f4dec

Browse files
author
alexandresalome
committed
add failing tests (because of encoding)
1 parent 6346e31 commit d5f4dec

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/Gitonomy/Git/Parser/ParserBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function consume($expected)
109109
$length = StringHelper::strlen($expected);
110110
$actual = StringHelper::substr($this->content, $this->cursor, $length);
111111
if ($actual !== $expected) {
112-
throw new \RuntimeException(sprintf('Expected "%s", but got "%s"', $expected, $actual));
112+
throw new \RuntimeException(sprintf('Expected "%s", but got "%s" (%s)', $expected, $actual, substr($this->content, $this->cursor, 10)));
113113
}
114114
$this->cursor += $length;
115115

tests/Gitonomy/Git/Tests/AbstractTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase
2323
const BEFORE_LONGFILE_COMMIT = 'e0ec50e2af75fa35485513f60b2e658e245227e9';
2424
const LONGMESSAGE_COMMIT = '3febd664b6886344a9b32d70657687ea4b1b4fab';
2525
const INITIAL_COMMIT = '74acd054c8ec873ae6be044041d3a85a4f890ba5';
26+
const MERGE_COMMIT = '2f5b9d0a4e6e7173d7816e417805709c708674f8';
27+
const ENCODING_COMMIT = '779420b9b936f18a0b6579e1499a85b14270802e';
2628

2729
/**
2830
* Local clone of remote URL. Avoids network call on each test.
@@ -62,11 +64,7 @@ public static function provideFoobar()
6264
public static function createFoobarRepository($bare = true)
6365
{
6466
if (null === self::$localRepository) {
65-
if (is_dir('/tmp/foobar_test')) {
66-
self::$localRepository = new Repository('/tmp/foobar_test');
67-
} else {
68-
self::$localRepository = Admin::cloneTo('/tmp/foobar_test', self::REPOSITORY_URL);
69-
}
67+
self::$localRepository = Admin::cloneTo(self::createTempDir(), self::REPOSITORY_URL);
7068
}
7169

7270
$repository = self::$localRepository->cloneTo(self::createTempDir(), $bare);

tests/Gitonomy/Git/Tests/CommitTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,24 @@ public function testGetLastModification($repository)
247247
$this->assertTrue($lastModification instanceof Commit, "Last modification is a Commit object");
248248
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $lastModification->getHash(), "Last modification is current commit");
249249
}
250+
251+
/**
252+
* @dataProvider provideFoobar
253+
*/
254+
public function testMergeCommit($repository)
255+
{
256+
$commit = $repository->getCommit(self::MERGE_COMMIT);
257+
258+
$this->assertEquals("Merge branch 'authors'", $commit->getSubjectMessage());
259+
}
260+
261+
/**
262+
* @dataProvider provideFoobar
263+
*/
264+
public function testEncoding($repository)
265+
{
266+
$commit = $repository->getCommit(self::ENCODING_COMMIT);
267+
268+
$this->assertEquals("contribute to AUTHORS file", $commit->getSubjectMessage());
269+
}
250270
}

0 commit comments

Comments
 (0)