IntegrationTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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;
  12. use PhpCsFixer\Tests\Test\AbstractIntegrationTestCase;
  13. use PhpCsFixer\Tests\Test\IntegrationCase;
  14. use PhpCsFixer\Tests\Test\InternalIntegrationCaseFactory;
  15. /**
  16. * Test that parses and runs the fixture '*.test' files found in '/Fixtures/Integration'.
  17. *
  18. * @author SpacePossum
  19. *
  20. * @internal
  21. *
  22. * @coversNothing
  23. */
  24. final class IntegrationTest extends AbstractIntegrationTestCase
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected static function getFixturesDir()
  30. {
  31. return __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Integration';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. protected static function getTempFile()
  37. {
  38. return self::getFixturesDir().DIRECTORY_SEPARATOR.'.tmp.php';
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. protected static function createIntegrationCaseFactory()
  44. {
  45. return new InternalIntegrationCaseFactory();
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. protected static function assertRevertedOrderFixing(IntegrationCase $case, $fixedInputCode, $fixedInputCodeWithReversedFixers)
  51. {
  52. parent::assertRevertedOrderFixing($case, $fixedInputCode, $fixedInputCodeWithReversedFixers);
  53. $settings = $case->getSettings();
  54. if (!isset($settings['isExplicitPriorityCheck'])) {
  55. static::markTestIncomplete('Missing `isExplicitPriorityCheck` extension setting.');
  56. }
  57. if ($settings['isExplicitPriorityCheck']) {
  58. if ($fixedInputCode === $fixedInputCodeWithReversedFixers) {
  59. if (in_array($case->getFileName(), [
  60. 'priority/braces,indentation_type,no_break_comment.test',
  61. 'priority/standardize_not_equals,binary_operator_spaces.test',
  62. ], true)) {
  63. static::markTestIncomplete(sprintf(
  64. 'Integration test `%s` was defined as explicit priority test, but no priority conflict was detected.'
  65. ."\n".'Either integration test needs to be extended, or test moved from `priority` to `misc`.'
  66. ."\n".'Bud don\'t do it blindly - it deserves investigation!',
  67. $case->getFileName()
  68. ));
  69. }
  70. }
  71. static::assertTrue(
  72. $fixedInputCode !== $fixedInputCodeWithReversedFixers,
  73. sprintf('Test "%s" in "%s" is expected to be priority check.', $case->getTitle(), $case->getFileName())
  74. );
  75. }
  76. }
  77. }