PSR12
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
@@ -14,7 +15,7 @@ class xdiffTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Declaration of $string1 and $string2
|
||||
// {{{
|
||||
private $string1 = "This part of the
|
||||
private $string1 = "This part of the
|
||||
document has stayed the
|
||||
same from version to
|
||||
version. It shouldn't
|
||||
@@ -39,7 +40,7 @@ this paragraph needs to
|
||||
be changed. Things can
|
||||
be added after it.
|
||||
";
|
||||
private $string2 = "This is an important
|
||||
private $string2 = "This is an important
|
||||
notice! It should
|
||||
therefore be located at
|
||||
the beginning of this
|
||||
@@ -71,12 +72,12 @@ to this document.
|
||||
";
|
||||
// }}}
|
||||
|
||||
public function test_diff_normal_1 ()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ($this->string1, $this->string2);
|
||||
$this->assertSame ($res, "0a1,6
|
||||
public function test_diff_normal_1()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff($this->string1, $this->string2);
|
||||
$this->assertSame($res, "0a1,6
|
||||
> This is an important
|
||||
> notice! It should
|
||||
> therefore be located at
|
||||
@@ -99,14 +100,14 @@ to this document.
|
||||
> important new additions
|
||||
> to this document.
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_normal_2 ()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
||||
$this->assertSame ($res, "1c1,6
|
||||
public function test_diff_normal_2()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("NEWLINE\n" . $this->string1, $this->string2);
|
||||
$this->assertSame($res, "1c1,6
|
||||
< NEWLINE
|
||||
---
|
||||
> This is an important
|
||||
@@ -131,64 +132,64 @@ to this document.
|
||||
> important new additions
|
||||
> to this document.
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_normal_3 ()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
||||
$this->assertSame ($res, "1c1
|
||||
public function test_diff_normal_3()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("NEWLINE\n", "\n");
|
||||
$this->assertSame($res, "1c1
|
||||
< NEWLINE
|
||||
---
|
||||
>
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_normal_4 ()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
||||
$this->assertSame ($res, "1c1
|
||||
public function test_diff_normal_4()
|
||||
{
|
||||
// Mode normal
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("\n", "NEWLINE\n");
|
||||
$this->assertSame($res, "1c1
|
||||
<
|
||||
---
|
||||
> NEWLINE
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_normal_5 ()
|
||||
{
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("\n", "\n");
|
||||
$this->assertSame ($res, "");
|
||||
}
|
||||
public function test_diff_normal_5()
|
||||
{
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("\n", "\n");
|
||||
$this->assertSame($res, "");
|
||||
}
|
||||
|
||||
public function test_diff_normal_6 ()
|
||||
{
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("\n", "");
|
||||
$this->assertSame ($res, "1d0
|
||||
public function test_diff_normal_6()
|
||||
{
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("\n", "");
|
||||
$this->assertSame($res, "1d0
|
||||
< \n");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_normal_7 ()
|
||||
{
|
||||
$xdiff = new Xdiff ();
|
||||
$res = $xdiff->diff ("", "\n");
|
||||
$this->assertSame ($res, "0a1
|
||||
public function test_diff_normal_7()
|
||||
{
|
||||
$xdiff = new Xdiff();
|
||||
$res = $xdiff->diff("", "\n");
|
||||
$this->assertSame($res, "0a1
|
||||
> \n");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_1 ()
|
||||
{
|
||||
// Mode unified
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ($this->string1, $this->string2);
|
||||
$date = date ("Y-m-d H:i:s.u00");
|
||||
// DST must answer +0200 in winter and +0100 in summer
|
||||
$dst = date ("O");
|
||||
$this->assertSame ($res, "--- Original ${date}0 $dst
|
||||
public function test_diff_unified_1()
|
||||
{
|
||||
// Mode unified
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff($this->string1, $this->string2);
|
||||
$date = date("Y-m-d H:i:s.u00");
|
||||
// DST must answer +0200 in winter and +0100 in summer
|
||||
$dst = date("O");
|
||||
$this->assertSame($res, "--- Original ${date}0 $dst
|
||||
+++ New ${date}1 $dst
|
||||
@@ -0,0 +1,6 @@
|
||||
+This is an important
|
||||
@@ -212,15 +213,15 @@ to this document.
|
||||
+important new additions
|
||||
+to this document.
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_2 ()
|
||||
{
|
||||
// Mode unified
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diff_unified_2()
|
||||
{
|
||||
// Mode unified
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("NEWLINE\n" . $this->string1, $this->string2);
|
||||
$this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ New " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -1 +1,6 @@
|
||||
-NEWLINE
|
||||
+This is an important
|
||||
@@ -244,67 +245,67 @@ to this document.
|
||||
+important new additions
|
||||
+to this document.
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_3 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diff_unified_3()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("NEWLINE\n", "\n");
|
||||
$this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ New " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -1 +1 @@
|
||||
-NEWLINE
|
||||
+
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_4 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diff_unified_4()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("\n", "NEWLINE\n");
|
||||
$this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ New " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -1 +1 @@
|
||||
-
|
||||
+NEWLINE
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_5 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("\n", "\n");
|
||||
$this->assertSame ($res, "");
|
||||
}
|
||||
public function test_diff_unified_5()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("\n", "\n");
|
||||
$this->assertSame($res, "");
|
||||
}
|
||||
|
||||
public function test_diff_unified_6 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("\n", "");
|
||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diff_unified_6()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("\n", "");
|
||||
$this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ New " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -1 +0,0 @@
|
||||
-\n");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diff_unified_7 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diff ("", "\n");
|
||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diff_unified_7()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diff("", "\n");
|
||||
$this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ New " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -0,0 +1 @@
|
||||
+\n");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_diffFile_unified_1 ()
|
||||
{
|
||||
file_put_contents ("/tmp/test_xdiff1", $this->string1);
|
||||
file_put_contents ("/tmp/test_xdiff2", $this->string2);
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||
$this->assertSame ($res, "--- /tmp/test_xdiff1 ".date ("Y-m-d H:i:s.u000 O")."
|
||||
+++ /tmp/test_xdiff2 ".date ("Y-m-d H:i:s.u001 O")."
|
||||
public function test_diffFile_unified_1()
|
||||
{
|
||||
file_put_contents("/tmp/test_xdiff1", $this->string1);
|
||||
file_put_contents("/tmp/test_xdiff2", $this->string2);
|
||||
$xdiff = new Xdiff("unified");
|
||||
$res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||
$this->assertSame($res, "--- /tmp/test_xdiff1 " . date("Y-m-d H:i:s.u000 O") . "
|
||||
+++ /tmp/test_xdiff2 " . date("Y-m-d H:i:s.u001 O") . "
|
||||
@@ -0,0 +1,6 @@
|
||||
+This is an important
|
||||
+notice! It should
|
||||
@@ -327,31 +328,31 @@ to this document.
|
||||
+important new additions
|
||||
+to this document.
|
||||
");
|
||||
}
|
||||
|
||||
}
|
||||
public function test_diffFile_unified_2()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$this->setExpectedException();
|
||||
$res = $xdiff->diffFile("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
|
||||
}
|
||||
|
||||
public function test_diffFile_unified_2 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$this->setExpectedException ();
|
||||
$res = $xdiff->diffFile ("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
|
||||
}
|
||||
public function test_diffFile_unified_3()
|
||||
{
|
||||
$xdiff = new Xdiff("unified");
|
||||
$this->setExpectedException();
|
||||
$res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
|
||||
}
|
||||
|
||||
public function test_diffFile_unified_3 ()
|
||||
{
|
||||
$xdiff = new Xdiff ("unified");
|
||||
$this->setExpectedException ();
|
||||
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
|
||||
}
|
||||
|
||||
public function test_diffFile_sideBySide_1 ()
|
||||
{
|
||||
file_put_contents ("/tmp/test_xdiff1", $this->string1);
|
||||
file_put_contents ("/tmp/test_xdiff2", $this->string2);
|
||||
$xdiff = new Xdiff ("sideBySide");
|
||||
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||
$this->assertSame ($res,
|
||||
" > This is an important
|
||||
public function test_diffFile_sideBySide_1()
|
||||
{
|
||||
file_put_contents("/tmp/test_xdiff1", $this->string1);
|
||||
file_put_contents("/tmp/test_xdiff2", $this->string2);
|
||||
$xdiff = new Xdiff("sideBySide");
|
||||
$res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
" > This is an important
|
||||
> notice! It should
|
||||
> therefore be located at
|
||||
> the beginning of this
|
||||
@@ -385,6 +386,7 @@ be added after it. be added after it.
|
||||
> This paragraph contains
|
||||
> important new additions
|
||||
> to this document.
|
||||
");
|
||||
}
|
||||
"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user