AbstractDifferTestCase.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\Tests\Differ;
  12. use PhpCsFixer\Tests\TestCase;
  13. /**
  14. * @author Andreas Möller <am@localheinz.com>
  15. *
  16. * @internal
  17. */
  18. abstract class AbstractDifferTestCase extends TestCase
  19. {
  20. final public function testIsDiffer()
  21. {
  22. $className = preg_replace(
  23. '/Test$/',
  24. '',
  25. str_replace(
  26. 'PhpCsFixer\\Tests\\Differ\\',
  27. 'PhpCsFixer\\Differ\\',
  28. static::class
  29. )
  30. );
  31. $differ = new $className();
  32. $this->assertInstanceOf(\PhpCsFixer\Differ\DifferInterface::class, $differ);
  33. }
  34. final protected function oldCode()
  35. {
  36. return <<<'PHP'
  37. <?php
  38. class Foo extends Bar {
  39. function __construct($foo, $bar) {
  40. $this->foo = $foo;
  41. $this->bar = $bar;
  42. }
  43. }
  44. PHP;
  45. }
  46. final protected function newCode()
  47. {
  48. return <<<'PHP'
  49. <?php
  50. class Foo extends Bar {
  51. public function __construct($foo, $bar)
  52. {
  53. $this->foo = $foo;
  54. $this->bar = $bar;
  55. }
  56. }
  57. PHP;
  58. }
  59. }