FullDifferTest.php 966 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Differ;
  13. use PhpCsFixer\Differ\FullDiffer;
  14. /**
  15. * @internal
  16. *
  17. * @covers \PhpCsFixer\Differ\FullDiffer
  18. */
  19. final class FullDifferTest extends AbstractDifferTestCase
  20. {
  21. public function testDiffReturnsDiff(): void
  22. {
  23. $diff = '--- Original
  24. +++ New
  25. @@ -1,10 +1,10 @@
  26. <?php
  27. '.'
  28. function baz($options)
  29. {
  30. - if (!array_key_exists("foo", $options)) {
  31. + if (!\array_key_exists("foo", $options)) {
  32. throw new \InvalidArgumentException();
  33. }
  34. '.'
  35. return json_encode($options);
  36. }
  37. ';
  38. $differ = new FullDiffer();
  39. self::assertSame($diff, $differ->diff($this->oldCode(), $this->newCode()));
  40. }
  41. }