DocumentationLocatorTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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\Documentation;
  13. use PhpCsFixer\Documentation\DocumentationLocator;
  14. use PhpCsFixer\Fixer\Casing\ConstantCaseFixer;
  15. use PhpCsFixer\Tests\TestCase;
  16. /**
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Documentation\DocumentationLocator
  20. */
  21. final class DocumentationLocatorTest extends TestCase
  22. {
  23. public function testFixersDocumentationDirectoryPath(): void
  24. {
  25. self::assertSame(
  26. realpath(__DIR__.'/../..').'/doc/rules',
  27. (new DocumentationLocator())->getFixersDocumentationDirectoryPath()
  28. );
  29. }
  30. public function testFixersDocumentationIndexFilePath(): void
  31. {
  32. self::assertSame(
  33. realpath(__DIR__.'/../..').'/doc/rules/index.rst',
  34. (new DocumentationLocator())->getFixersDocumentationIndexFilePath()
  35. );
  36. }
  37. public function testFixerDocumentationFilePath(): void
  38. {
  39. self::assertSame(
  40. realpath(__DIR__.'/../..').'/doc/rules/casing/constant_case.rst',
  41. (new DocumentationLocator())->getFixerDocumentationFilePath(new ConstantCaseFixer())
  42. );
  43. }
  44. public function testFixerDocumentationFileRelativePath(): void
  45. {
  46. self::assertSame(
  47. 'casing/constant_case.rst',
  48. (new DocumentationLocator())->getFixerDocumentationFileRelativePath(new ConstantCaseFixer())
  49. );
  50. }
  51. public function testRuleSetsDocumentationDirectoryPath(): void
  52. {
  53. self::assertSame(
  54. realpath(__DIR__.'/../..').'/doc/ruleSets',
  55. (new DocumentationLocator())->getRuleSetsDocumentationDirectoryPath()
  56. );
  57. }
  58. public function testRuleSetsDocumentationIndexFilePath(): void
  59. {
  60. self::assertSame(
  61. realpath(__DIR__.'/../..').'/doc/ruleSets/index.rst',
  62. (new DocumentationLocator())->getRuleSetsDocumentationIndexFilePath()
  63. );
  64. }
  65. public function testRuleSetsDocumentationFilePath(): void
  66. {
  67. self::assertSame(
  68. realpath(__DIR__.'/../..').'/doc/ruleSets/PhpCsFixerRisky.rst',
  69. (new DocumentationLocator())->getRuleSetsDocumentationFilePath('@PhpCsFixer:risky')
  70. );
  71. }
  72. public function testUsageFilePath(): void
  73. {
  74. self::assertSame(
  75. realpath(__DIR__.'/../..').'/doc/usage.rst',
  76. (new DocumentationLocator())->getUsageFilePath()
  77. );
  78. }
  79. }