IntegrationTest.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. if ($fixedInputCode === $fixedInputCodeWithReversedFixers) {
  49. if (\in_array($case->getFileName(), [
  50. 'priority'.\DIRECTORY_SEPARATOR.'backtick_to_shell_exec,escape_implicit_backslashes.test',
  51. 'priority'.\DIRECTORY_SEPARATOR.'backtick_to_shell_exec,string_implicit_backslashes.test',
  52. 'priority'.\DIRECTORY_SEPARATOR.'braces,indentation_type,no_break_comment.test',
  53. 'priority'.\DIRECTORY_SEPARATOR.'standardize_not_equals,binary_operator_spaces.test',
  54. ], true)) {
  55. self::markTestIncomplete(\sprintf(
  56. 'Integration test `%s` was defined as explicit priority test, but no priority conflict was detected.'
  57. ."\n".'Either integration test needs to be extended or moved from `priority` to `misc`.'
  58. ."\n".'But don\'t do it blindly - it deserves investigation!',
  59. $case->getFileName()
  60. ));
  61. }
  62. }
  63. self::assertNotSame(
  64. $fixedInputCode,
  65. $fixedInputCodeWithReversedFixers,
  66. \sprintf('Test "%s" in "%s" is expected to be priority check.', $case->getTitle(), $case->getFileName())
  67. );
  68. }
  69. }
  70. }