IntegrationCase.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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\Test;
  12. use PhpCsFixer\RuleSet;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. */
  18. final class IntegrationCase
  19. {
  20. private $config;
  21. /**
  22. * @var string
  23. */
  24. private $expectedCode;
  25. /**
  26. * @var string
  27. */
  28. private $fileName;
  29. /**
  30. * @var null|string
  31. */
  32. private $inputCode;
  33. /**
  34. * Env requirements (possible keys: php).
  35. *
  36. * @var array
  37. */
  38. private $requirements;
  39. /**
  40. * @var RuleSet
  41. */
  42. private $ruleset;
  43. /**
  44. * Settings how to perform the test (possible keys: none in base class, use as extension point for custom IntegrationTestCase).
  45. *
  46. * @var array
  47. */
  48. private $settings;
  49. /**
  50. * @var string
  51. */
  52. private $title;
  53. /**
  54. * @param string $fileName
  55. * @param string $title
  56. * @param string $expectedCode
  57. * @param null|string $inputCode
  58. */
  59. public function __construct(
  60. $fileName,
  61. $title,
  62. array $settings,
  63. array $requirements,
  64. array $config,
  65. RuleSet $ruleset,
  66. $expectedCode,
  67. $inputCode
  68. ) {
  69. $this->fileName = $fileName;
  70. $this->title = $title;
  71. $this->settings = $settings;
  72. $this->requirements = $requirements;
  73. $this->config = $config;
  74. $this->ruleset = $ruleset;
  75. $this->expectedCode = $expectedCode;
  76. $this->inputCode = $inputCode;
  77. }
  78. public function hasInputCode()
  79. {
  80. return null !== $this->inputCode;
  81. }
  82. public function getConfig()
  83. {
  84. return $this->config;
  85. }
  86. public function getExpectedCode()
  87. {
  88. return $this->expectedCode;
  89. }
  90. public function getFileName()
  91. {
  92. return $this->fileName;
  93. }
  94. public function getInputCode()
  95. {
  96. return $this->inputCode;
  97. }
  98. /**
  99. * @param string $name
  100. *
  101. * @return mixed
  102. */
  103. public function getRequirement($name)
  104. {
  105. if (!\array_key_exists($name, $this->requirements)) {
  106. throw new \InvalidArgumentException(sprintf(
  107. 'Unknown requirement key "%s", expected any of "%s".',
  108. $name,
  109. implode('","', array_keys($this->requirements))
  110. ));
  111. }
  112. return $this->requirements[$name];
  113. }
  114. public function getRequirements()
  115. {
  116. return $this->requirements;
  117. }
  118. public function getRuleset()
  119. {
  120. return $this->ruleset;
  121. }
  122. public function getSettings()
  123. {
  124. return $this->settings;
  125. }
  126. public function getTitle()
  127. {
  128. return $this->title;
  129. }
  130. }