Ingen beskrivning

DiffOnlyOutputBuilderTest.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of sebastian/diff.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\Diff\Output;
  11. use PHPUnit\Framework\TestCase;
  12. use SebastianBergmann\Diff\Differ;
  13. /**
  14. * @covers SebastianBergmann\Diff\Output\DiffOnlyOutputBuilder
  15. *
  16. * @uses SebastianBergmann\Diff\Differ
  17. * @uses SebastianBergmann\Diff\TimeEfficientLongestCommonSubsequenceCalculator
  18. */
  19. final class DiffOnlyOutputBuilderTest extends TestCase
  20. {
  21. /**
  22. * @param string $expected
  23. * @param string $from
  24. * @param string $to
  25. * @param string $header
  26. *
  27. * @dataProvider textForNoNonDiffLinesProvider
  28. */
  29. public function testDiffDoNotShowNonDiffLines(string $expected, string $from, string $to, string $header = ''): void
  30. {
  31. $differ = new Differ(new DiffOnlyOutputBuilder($header));
  32. $this->assertSame($expected, $differ->diff($from, $to));
  33. }
  34. public function textForNoNonDiffLinesProvider(): array
  35. {
  36. return [
  37. [
  38. " #Warning: Strings contain different line endings!\n-A\r\n+B\n",
  39. "A\r\n",
  40. "B\n",
  41. ],
  42. [
  43. "-A\n+B\n",
  44. "\nA",
  45. "\nB",
  46. ],
  47. [
  48. '',
  49. 'a',
  50. 'a',
  51. ],
  52. [
  53. "-A\n+C\n",
  54. "A\n\n\nB",
  55. "C\n\n\nB",
  56. ],
  57. [
  58. "header\n",
  59. 'a',
  60. 'a',
  61. 'header',
  62. ],
  63. [
  64. "header\n",
  65. 'a',
  66. 'a',
  67. "header\n",
  68. ],
  69. ];
  70. }
  71. }