|
10 | 10 |
|
11 | 11 | namespace PHPCSUtils\TestUtils;
|
12 | 12 |
|
13 |
| -use PHP_CodeSniffer\Config; |
14 | 13 | use PHP_CodeSniffer\Exceptions\TokenizerException;
|
15 | 14 | use PHP_CodeSniffer\Files\DummyFile;
|
16 | 15 | use PHP_CodeSniffer\Files\File;
|
|
19 | 18 | use PHPCSUtils\Exceptions\TestFileNotFound;
|
20 | 19 | use PHPCSUtils\Exceptions\TestMarkerNotFound;
|
21 | 20 | use PHPCSUtils\Exceptions\TestTargetNotFound;
|
| 21 | +use PHPCSUtils\TestUtils\ConfigDouble; |
22 | 22 | use PHPUnit\Framework\TestCase;
|
23 | 23 | use ReflectionClass;
|
24 | 24 | use ReflectionProperty;
|
@@ -212,31 +212,10 @@ public static function setUpTestFile()
|
212 | 212 |
|
213 | 213 | $contents = \file_get_contents($caseFile);
|
214 | 214 |
|
215 |
| - /* |
216 |
| - * Set the static properties in the Config class to specific values for performance |
217 |
| - * and to clear out values from other tests. |
218 |
| - */ |
219 |
| - self::setStaticConfigProperty('executablePaths', []); |
220 |
| - |
221 |
| - // Set to values which prevent the test-runner user's `CodeSniffer.conf` file |
222 |
| - // from being read and influencing the tests. Also prevent an `exec()` call to stty. |
223 |
| - self::setStaticConfigProperty('configData', ['report_width' => 80]); |
224 |
| - self::setStaticConfigProperty('configDataFile', ''); |
225 |
| - |
226 |
| - $config = new Config(); |
| 215 | + $config = new ConfigDouble(); |
227 | 216 |
|
228 | 217 | /*
|
229 |
| - * Set to a usable value to circumvent Config trying to find a phpcs.xml config file. |
230 |
| - * |
231 |
| - * We just need to provide a standard so PHPCS will tokenize the file. |
232 |
| - * The standard itself doesn't actually matter for testing utility methods, |
233 |
| - * so use the smallest one to get the fastest results. |
234 |
| - */ |
235 |
| - $config->standards = ['PSR1']; |
236 |
| - |
237 |
| - /* |
238 |
| - * Limiting the run to just one sniff will make it, yet again, slightly faster. |
239 |
| - * Picked the simplest/fastest sniff available which is registered in PSR1. |
| 218 | + * Limiting the run to just one (dummy) sniff will make it, yet again, slightly faster. |
240 | 219 | */
|
241 | 220 | $config->sniffs = static::$selectedSniff;
|
242 | 221 |
|
@@ -315,17 +294,15 @@ public static function resetTestFile()
|
315 | 294 | self::$tabWidth = 4;
|
316 | 295 | self::$phpcsFile = null;
|
317 | 296 | self::$selectedSniff = ['Dummy.Dummy.Dummy'];
|
318 |
| - |
319 |
| - // Reset the static properties in the Config class to their defaults to prevent tests influencing each other. |
320 |
| - self::setStaticConfigProperty('executablePaths', []); |
321 |
| - self::setStaticConfigProperty('configData', null); |
322 |
| - self::setStaticConfigProperty('configDataFile', null); |
323 | 297 | }
|
324 | 298 |
|
325 | 299 | /**
|
326 | 300 | * Helper function to set the value of a private static property on the PHPCS Config class.
|
327 | 301 | *
|
328 |
| - * @since 1.0.9 |
| 302 | + * @since 1.0.9 |
| 303 | + * @deprecated 1.1.0 Use the `PHPCSUtils\TestUtils\ConfigDouble::setStaticConfigProperty()` method instead. |
| 304 | + * |
| 305 | + * @codeCoverageIgnore |
329 | 306 | *
|
330 | 307 | * @param string $name The name of the property to set.
|
331 | 308 | * @param mixed $value The value to set the property to.
|
|
0 commit comments