Skip to content

Commit

Permalink
Update phpunit to 5.x and change some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bircher committed Mar 18, 2017
1 parent c991a02 commit c321b28
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"sebastian/diff": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "~3.0",
"phpunit/phpunit": "~5.0",
"cpliakas/git-wrapper": "dev-master"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/PhpMerge/GitMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ public function merge($base, $remote, $local)
$merged = $this->mergeFile($file, $base, $remote, $local);
return self::postMergeAlter($merged);
} catch (GitException $e) {
// @TODO: clean up working directory.
// Get conflicts by reading from the file.
$conflicts = [];
$merged = [];
self::getConflicts($file, $base, $remote, $local, $conflicts, $merged);
$merged = implode("\n", $merged);
$merged = self::postMergeAlter($merged);
// Set the file to the merged one with the first text for conflicts.
file_put_contents($file, $merged);
$this->git->add($file);
$this->git->commit('Resolve merge conflict.');
Expand Down Expand Up @@ -330,7 +331,6 @@ public function __construct(GitWrapper $wrapper = null)
*/
protected function setup()
{
// @TODO: Allow setting up in an existing dierectory.
if (!$this->dir) {
// Greate a temporary directory.
$tempfile = tempnam(sys_get_temp_dir(), '');
Expand Down
6 changes: 0 additions & 6 deletions src/PhpMerge/XdiffMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ public function merge($base, $remote, $local)
// First try the built in xdiff_string_merge3.
$merged = xdiff_string_merge3($base, $remote, $local, $error);

// if ($error) {
// // Try it the other way around.
// $error = null;
// $merged = xdiff_string_merge3($base, $local, $remote, $error);
// }

if ($error) {
// So there might be a merge conflict.
$baseLines = $this->base = Line::createArray(
Expand Down
15 changes: 11 additions & 4 deletions test/PhpMerge/Test/AbstractPhpMergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ abstract class AbstractPhpMergeTest extends \PHPUnit_Framework_TestCase
protected $merger;

/**
* @param \PhpMerge\PhpMergeInterface $merger
* Set up the merger to use.
*
* @return \PhpMerge\PhpMergeInterface
* The merger used in the subsequent tests.
*/
abstract protected function createMerger();

/**
* {@inheritdoc}
*/
public function setUp(PhpMergeInterface $merger)
public function setUp()
{
parent::setUp();
$this->merger = $merger;
$this->merger = $this->createMerger();
}

/**
Expand Down
10 changes: 8 additions & 2 deletions test/PhpMerge/Test/GitMergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
class GitMergeTest extends AbstractPhpMergeTest
{

public function setUp()
/**
* {@inheritdoc}
*/
protected function createMerger()
{
parent::setUp(new GitMerge());
return new GitMerge();
}

/**
* Test that the git directory is properly cleaned up.
*/
public function testCleanup()
{
$merger = new GitMerge();
Expand Down
7 changes: 4 additions & 3 deletions test/PhpMerge/Test/PhpMergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
*/
class PhpMergeTest extends AbstractPhpMergeTest
{

/**
*
* {@inheritdoc}
*/
public function setUp()
protected function createMerger()
{
parent::setUp(new PhpMerge());
return new PhpMerge();
}

}
7 changes: 4 additions & 3 deletions test/PhpMerge/Test/XdiffMergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
class XdiffMergeTest extends AbstractPhpMergeTest
{
/**
* Set up the xdiff merge if the xdiff extension is installed.
* {@inheritdoc}
*/
public function setUp()
protected function createMerger()
{
if (function_exists('xdiff_string_merge3')) {
parent::setUp(new XdiffMerge());
return new XdiffMerge();
} else {
$this->markTestSkipped('The xdiff php extension is not installed.');
return NULL;
}
}

Expand Down

0 comments on commit c321b28

Please sign in to comment.