DiffLibTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. App::uses('DiffLib', 'Tools.Lib');
  3. App::uses('MyCakeTestCase', 'Tools.TestSuite');
  4. /**
  5. * 2010-06-30 ms
  6. */
  7. class DiffLibTest extends MyCakeTestCase {
  8. public $Diff = null;
  9. public function setUp() {
  10. parent::setUp();
  11. $this->Diff = new DiffLib();
  12. $style = <<<CSS
  13. <style type="text/css">
  14. del {
  15. color: red;
  16. }
  17. ins {
  18. color: green;
  19. }
  20. </style>
  21. CSS;
  22. $this->out($style, true);
  23. }
  24. public function testCompare() {
  25. }
  26. public function testReverse() {
  27. $this->out('String - autodetect', true);
  28. $text = <<<TEXT
  29. ***************
  30. *** 1 ****
  31. ! 99999999777
  32. --- 1 ----
  33. ! 9999944449977
  34. TEXT;
  35. $res = $this->Diff->reverse($text);
  36. $this->out($res);
  37. $this->out('String - Context - render as Unified', true);
  38. }
  39. public function testParseDiff() {
  40. $t1 = array(
  41. 'errgrshrth',
  42. 'srhrthrt777 ssshsrjtz jrjtjtjt',
  43. '1dfdf'.PHP_EOL.'jtzth6h6h6th6'.PHP_EOL.'xcsdfdf',
  44. '99999999777'
  45. );
  46. $t2 = array(
  47. 'errgrsh3333rth',
  48. 'srhrthrt777 hsrthsrjt888 jrjtjtjt',
  49. '1dfdf'.PHP_EOL.'jtzh6h6th6'.PHP_EOL.'xcsdfdf',
  50. '9999944449977'
  51. );
  52. $this->out('Inline - auto', false);
  53. for ($i = 0; $i < 4; $i++) {
  54. $res = $this->Diff->compare($t1[$i], $t2[$i]);
  55. $this->out($res);
  56. }
  57. }
  58. }