DiffTest.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers SebastianBergmann\Diff\Diff
  14. *
  15. * @uses SebastianBergmann\Diff\Chunk
  16. */
  17. final class DiffTest extends TestCase
  18. {
  19. public function testGettersAfterConstructionWithDefault()
  20. {
  21. $from = 'line1a';
  22. $to = 'line2a';
  23. $diff = new Diff($from, $to);
  24. $this->assertSame($from, $diff->getFrom());
  25. $this->assertSame($to, $diff->getTo());
  26. $this->assertSame([], $diff->getChunks(), 'Expect chunks to be default value "array()".');
  27. }
  28. public function testGettersAfterConstructionWithChunks()
  29. {
  30. $from = 'line1b';
  31. $to = 'line2b';
  32. $chunks = [new Chunk(), new Chunk(2, 3)];
  33. $diff = new Diff($from, $to, $chunks);
  34. $this->assertSame($from, $diff->getFrom());
  35. $this->assertSame($to, $diff->getTo());
  36. $this->assertSame($chunks, $diff->getChunks(), 'Expect chunks to be passed value.');
  37. }
  38. public function testSetChunksAfterConstruction()
  39. {
  40. $diff = new Diff('line1c', 'line2c');
  41. $this->assertSame([], $diff->getChunks(), 'Expect chunks to be default value "array()".');
  42. $chunks = [new Chunk(), new Chunk(2, 3)];
  43. $diff->setChunks($chunks);
  44. $this->assertSame($chunks, $diff->getChunks(), 'Expect chunks to be passed value.');
  45. }
  46. }