Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Tests\Test;
use PhpCsFixer\RuleSet;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class IntegrationCase
{
private $config;
/**
* @var string
*/
private $expectedCode;
/**
* @var string
*/
private $fileName;
/**
* @var null|string
*/
private $inputCode;
/**
* Env requirements (possible keys: php).
*
* @var array
*/
private $requirements;
/**
* @var RuleSet
*/
private $ruleset;
/**
* Settings how to perform the test (possible keys: none in base class, use as extension point for custom IntegrationTestCase).
*
* @var array
*/
private $settings;
/**
* @var string
*/
private $title;
/**
* @param string $fileName
* @param string $title
* @param array $settings
* @param array $requirements
* @param array $config
* @param RuleSet $ruleset
* @param string $expectedCode
* @param null|string $inputCode
*/
public function __construct(
$fileName,
$title,
array $settings,
array $requirements,
array $config,
RuleSet $ruleset,
$expectedCode,
$inputCode
) {
$this->fileName = $fileName;
$this->title = $title;
$this->settings = $settings;
$this->requirements = $requirements;
$this->config = $config;
$this->ruleset = $ruleset;
$this->expectedCode = $expectedCode;
$this->inputCode = $inputCode;
}
public function hasInputCode()
{
return null !== $this->inputCode;
}
public function getConfig()
{
return $this->config;
}
public function getExpectedCode()
{
return $this->expectedCode;
}
public function getFileName()
{
return $this->fileName;
}
public function getInputCode()
{
return $this->inputCode;
}
/**
* @param string $name
*
* @return mixed
*/
public function getRequirement($name)
{
if (!\is_string($name)) {
throw new \InvalidArgumentException(sprintf(
'Requirement key must be a string, got "%s".',
\is_object($name) ? \get_class($name) : \gettype($name).'#'.$name
));
}
if (!array_key_exists($name, $this->requirements)) {
throw new \InvalidArgumentException(sprintf(
'Unknown requirement key "%s", expected any of "%s".',
$name,
implode('","', array_keys($this->requirements))
));
}
return $this->requirements[$name];
}
public function getRequirements()
{
return $this->requirements;
}
public function getRuleset()
{
return $this->ruleset;
}
public function getSettings()
{
return $this->settings;
}
public function getTitle()
{
return $this->title;
}
}