IntegrationTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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;
  13. use PhpCsFixer\Tests\Test\AbstractIntegrationTestCase;
  14. use PhpCsFixer\Tests\Test\IntegrationCase;
  15. use PhpCsFixer\Tests\Test\IntegrationCaseFactoryInterface;
  16. use PhpCsFixer\Tests\Test\InternalIntegrationCaseFactory;
  17. /**
  18. * Test that parses and runs the fixture '*.test' files found in '/Fixtures/Integration'.
  19. *
  20. * @internal
  21. *
  22. * @coversNothing
  23. *
  24. * @group covers-nothing
  25. */
  26. final class IntegrationTest extends AbstractIntegrationTestCase
  27. {
  28. protected static function getFixturesDir(): string
  29. {
  30. return __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Integration';
  31. }
  32. protected static function getTempFile(): string
  33. {
  34. return sys_get_temp_dir().\DIRECTORY_SEPARATOR.'MyClass.php';
  35. }
  36. protected static function createIntegrationCaseFactory(): IntegrationCaseFactoryInterface
  37. {
  38. return new InternalIntegrationCaseFactory();
  39. }
  40. protected static function assertRevertedOrderFixing(IntegrationCase $case, string $fixedInputCode, string $fixedInputCodeWithReversedFixers): void
  41. {
  42. parent::assertRevertedOrderFixing($case, $fixedInputCode, $fixedInputCodeWithReversedFixers);
  43. $settings = $case->getSettings();
  44. if (!isset($settings['isExplicitPriorityCheck'])) {
  45. self::markTestIncomplete('Missing `isExplicitPriorityCheck` extension setting.');
  46. }
  47. if ($settings['isExplicitPriorityCheck']) {
  48. self::assertNotSame(
  49. $fixedInputCode,
  50. $fixedInputCodeWithReversedFixers,
  51. \sprintf(
  52. 'Test "%s" in "%s" is expected to be priority check, but fixers applied in reversed order made the same changes.',
  53. $case->getTitle(),
  54. $case->getFileName(),
  55. )
  56. );
  57. }
  58. }
  59. }