ConfigurationTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2023 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Psy\Test;
  11. use Psy\CodeCleaner;
  12. use Psy\Configuration;
  13. use Psy\ExecutionLoop\ProcessForker;
  14. use Psy\Output\PassthruPager;
  15. use Psy\Output\ShellOutput;
  16. use Psy\VersionUpdater\GitHubChecker;
  17. use Symfony\Component\Console\Input\InputDefinition;
  18. use Symfony\Component\Console\Input\StringInput;
  19. use Symfony\Component\Console\Output\ConsoleOutput;
  20. use Symfony\Component\Console\Output\OutputInterface;
  21. class ConfigurationTest extends TestCase
  22. {
  23. private function getConfig($configFile = null)
  24. {
  25. return new Configuration([
  26. 'configFile' => $configFile ?: __DIR__.'/fixtures/empty.php',
  27. ]);
  28. }
  29. public function testDefaults()
  30. {
  31. $config = $this->getConfig();
  32. $this->assertSame(\function_exists('readline'), $config->hasReadline());
  33. $this->assertSame(\function_exists('readline'), $config->useReadline());
  34. $this->assertSame(ProcessForker::isSupported(), $config->hasPcntl());
  35. $this->assertSame($config->hasPcntl(), $config->usePcntl());
  36. $this->assertFalse($config->requireSemicolons());
  37. $this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode());
  38. $this->assertNull($config->getStartupMessage());
  39. }
  40. public function testGettersAndSetters()
  41. {
  42. $config = $this->getConfig();
  43. $this->assertNull($config->getDataDir());
  44. $config->setDataDir('wheee');
  45. $this->assertSame('wheee', $config->getDataDir());
  46. $this->assertNull($config->getConfigDir());
  47. $config->setConfigDir('wheee');
  48. $this->assertSame('wheee', $config->getConfigDir());
  49. }
  50. /**
  51. * @group isolation-fail
  52. */
  53. public function testLoadConfig()
  54. {
  55. $config = $this->getConfig();
  56. $cleaner = new CodeCleaner();
  57. $pager = new PassthruPager(new ConsoleOutput());
  58. $config->loadConfig([
  59. 'useReadline' => false,
  60. 'usePcntl' => false,
  61. 'codeCleaner' => $cleaner,
  62. 'pager' => $pager,
  63. 'requireSemicolons' => true,
  64. 'errorLoggingLevel' => \E_ERROR | \E_WARNING,
  65. 'colorMode' => Configuration::COLOR_MODE_FORCED,
  66. 'startupMessage' => 'Psysh is awesome!',
  67. ]);
  68. $this->assertFalse($config->useReadline());
  69. $this->assertFalse($config->usePcntl());
  70. $this->assertSame($cleaner, $config->getCodeCleaner());
  71. $this->assertSame($pager, $config->getPager());
  72. $this->assertTrue($config->requireSemicolons());
  73. $this->assertSame(\E_ERROR | \E_WARNING, $config->errorLoggingLevel());
  74. $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode());
  75. $this->assertSame('Psysh is awesome!', $config->getStartupMessage());
  76. }
  77. public function testLoadConfigFile()
  78. {
  79. $config = $this->getConfig(__DIR__.'/fixtures/config.php');
  80. $runtimeDir = $this->joinPath(\realpath(\sys_get_temp_dir()), 'psysh_test', 'withconfig', 'temp');
  81. $this->assertStringStartsWith($runtimeDir, \realpath($config->getTempFile('foo', 123)));
  82. $this->assertStringStartsWith($runtimeDir, \realpath(\dirname($config->getPipe('pipe', 123))));
  83. $this->assertStringStartsWith($runtimeDir, \realpath($config->getRuntimeDir()));
  84. $this->assertSame(\function_exists('readline'), $config->useReadline());
  85. $this->assertFalse($config->usePcntl());
  86. $this->assertSame(\E_ALL & ~\E_NOTICE, $config->errorLoggingLevel());
  87. }
  88. public function testLoadLocalConfigFile()
  89. {
  90. $oldPwd = \getcwd();
  91. \chdir(\realpath(__DIR__.'/fixtures/project/'));
  92. $config = new Configuration();
  93. // When no configuration file is specified local project config is merged
  94. $this->assertTrue($config->requireSemicolons());
  95. $this->assertFalse($config->useUnicode());
  96. $config = new Configuration(['configFile' => __DIR__.'/fixtures/config.php']);
  97. // Defining a configuration file skips loading local project config
  98. $this->assertFalse($config->requireSemicolons());
  99. $this->assertTrue($config->useUnicode());
  100. \chdir($oldPwd);
  101. }
  102. public function testUnknownConfigFileThrowsException()
  103. {
  104. $this->expectException(\InvalidArgumentException::class);
  105. $this->expectExceptionMessage('Invalid configuration file specified');
  106. $config = new Configuration(['configFile' => __DIR__.'/not/a/real/config.php']);
  107. $this->fail();
  108. }
  109. public function testBaseDirConfigIsDeprecated()
  110. {
  111. $this->expectException(\Psy\Exception\DeprecatedException::class);
  112. $config = new Configuration(['baseDir' => 'fake']);
  113. $this->fail();
  114. }
  115. private function joinPath(...$parts)
  116. {
  117. return \implode(\DIRECTORY_SEPARATOR, $parts);
  118. }
  119. public function testConfigIncludes()
  120. {
  121. $config = new Configuration([
  122. 'defaultIncludes' => ['/file.php'],
  123. 'configFile' => __DIR__.'/fixtures/empty.php',
  124. ]);
  125. $includes = $config->getDefaultIncludes();
  126. $this->assertCount(1, $includes);
  127. $this->assertSame('/file.php', $includes[0]);
  128. }
  129. public function testGetOutput()
  130. {
  131. $config = $this->getConfig();
  132. $output = $config->getOutput();
  133. $this->assertInstanceOf(ShellOutput::class, $output);
  134. }
  135. public function getOutputDecoratedProvider()
  136. {
  137. return [
  138. 'auto' => [
  139. null,
  140. Configuration::COLOR_MODE_AUTO,
  141. ],
  142. 'forced' => [
  143. true,
  144. Configuration::COLOR_MODE_FORCED,
  145. ],
  146. 'disabled' => [
  147. false,
  148. Configuration::COLOR_MODE_DISABLED,
  149. ],
  150. ];
  151. }
  152. /** @dataProvider getOutputDecoratedProvider */
  153. public function testGetOutputDecorated($expectation, $colorMode)
  154. {
  155. if ($colorMode === Configuration::COLOR_MODE_AUTO) {
  156. $this->markTestSkipped('This test won\'t work on CI without overriding pipe detection');
  157. }
  158. $config = $this->getConfig();
  159. $config->setColorMode($colorMode);
  160. $this->assertSame($expectation, $config->getOutputDecorated());
  161. }
  162. public function setColorModeValidProvider()
  163. {
  164. return [
  165. 'auto' => [Configuration::COLOR_MODE_AUTO],
  166. 'forced' => [Configuration::COLOR_MODE_FORCED],
  167. 'disabled' => [Configuration::COLOR_MODE_DISABLED],
  168. ];
  169. }
  170. /** @dataProvider setColorModeValidProvider */
  171. public function testSetColorModeValid($colorMode)
  172. {
  173. $config = $this->getConfig();
  174. $config->setColorMode($colorMode);
  175. $this->assertSame($colorMode, $config->colorMode());
  176. }
  177. public function testSetColorModeInvalid()
  178. {
  179. $this->expectException(\InvalidArgumentException::class);
  180. $this->expectExceptionMessage('Invalid color mode: some invalid mode');
  181. $config = $this->getConfig();
  182. $config->setColorMode('some invalid mode');
  183. $this->fail();
  184. }
  185. public function getOutputVerbosityProvider()
  186. {
  187. return [
  188. 'quiet' => [OutputInterface::VERBOSITY_QUIET, Configuration::VERBOSITY_QUIET],
  189. 'normal' => [OutputInterface::VERBOSITY_NORMAL, Configuration::VERBOSITY_NORMAL],
  190. 'verbose' => [OutputInterface::VERBOSITY_VERBOSE, Configuration::VERBOSITY_VERBOSE],
  191. 'very_verbose' => [OutputInterface::VERBOSITY_VERY_VERBOSE, Configuration::VERBOSITY_VERY_VERBOSE],
  192. 'debug' => [OutputInterface::VERBOSITY_DEBUG, Configuration::VERBOSITY_DEBUG],
  193. ];
  194. }
  195. /**
  196. * @dataProvider getOutputVerbosityProvider
  197. *
  198. * @group isolation-fail
  199. */
  200. public function testGetOutputVerbosity($expectation, $verbosity)
  201. {
  202. $config = $this->getConfig();
  203. $config->setVerbosity($verbosity);
  204. $this->assertSame($expectation, $config->getOutputVerbosity());
  205. }
  206. public function setVerbosityValidProvider()
  207. {
  208. return [
  209. 'quiet' => [Configuration::VERBOSITY_QUIET],
  210. 'normal' => [Configuration::VERBOSITY_NORMAL],
  211. 'verbose' => [Configuration::VERBOSITY_VERBOSE],
  212. 'very_verbose' => [Configuration::VERBOSITY_VERY_VERBOSE],
  213. 'debug' => [Configuration::VERBOSITY_DEBUG],
  214. ];
  215. }
  216. /** @dataProvider setVerbosityValidProvider */
  217. public function testSetVerbosityValid($verbosity)
  218. {
  219. $config = $this->getConfig();
  220. $config->setVerbosity($verbosity);
  221. $this->assertSame($verbosity, $config->verbosity());
  222. }
  223. public function testSetVerbosityInvalid()
  224. {
  225. $this->expectException(\InvalidArgumentException::class);
  226. $this->expectExceptionMessage('Invalid verbosity level: some invalid verbosity');
  227. $config = $this->getConfig();
  228. $config->setVerbosity('some invalid verbosity');
  229. $this->fail();
  230. }
  231. public function getInputInteractiveProvider()
  232. {
  233. return [
  234. 'auto' => [
  235. null,
  236. Configuration::INTERACTIVE_MODE_AUTO,
  237. ],
  238. 'forced' => [
  239. true,
  240. Configuration::INTERACTIVE_MODE_FORCED,
  241. ],
  242. 'disabled' => [
  243. false,
  244. Configuration::INTERACTIVE_MODE_DISABLED,
  245. ],
  246. ];
  247. }
  248. /** @dataProvider getInputInteractiveProvider */
  249. public function testGetInputInteractive($expectation, $interactive)
  250. {
  251. if ($interactive === Configuration::INTERACTIVE_MODE_AUTO) {
  252. $this->markTestSkipped('This test won\'t work on CI without overriding pipe detection');
  253. }
  254. $config = $this->getConfig();
  255. $config->setInteractiveMode($interactive);
  256. $this->assertSame($expectation, $config->getInputInteractive());
  257. }
  258. public function setInteractiveModeValidProvider()
  259. {
  260. return [
  261. 'auto' => [Configuration::INTERACTIVE_MODE_AUTO],
  262. 'forced' => [Configuration::INTERACTIVE_MODE_FORCED],
  263. 'disabled' => [Configuration::INTERACTIVE_MODE_DISABLED],
  264. ];
  265. }
  266. /** @dataProvider setInteractiveModeValidProvider */
  267. public function testsetInteractiveModeValid($interactive)
  268. {
  269. $config = $this->getConfig();
  270. $config->setInteractiveMode($interactive);
  271. $this->assertSame($interactive, $config->interactiveMode());
  272. }
  273. public function testsetInteractiveModeInvalid()
  274. {
  275. $this->expectException(\InvalidArgumentException::class);
  276. $this->expectExceptionMessage('Invalid interactive mode: nope');
  277. $config = $this->getConfig();
  278. $config->setInteractiveMode('nope');
  279. $this->fail();
  280. }
  281. public function testSetCheckerValid()
  282. {
  283. $config = $this->getConfig();
  284. $checker = new GitHubChecker();
  285. $config->setChecker($checker);
  286. $this->assertSame($checker, $config->getChecker());
  287. }
  288. public function testSetFormatterStyles()
  289. {
  290. $config = $this->getConfig();
  291. $config->setFormatterStyles([
  292. 'mario' => ['white', 'red'],
  293. 'luigi' => ['white', 'green'],
  294. ]);
  295. $formatter = $config->getOutput()->getFormatter();
  296. $this->assertTrue($formatter->hasStyle('mario'));
  297. $this->assertTrue($formatter->hasStyle('luigi'));
  298. $mario = $formatter->getStyle('mario');
  299. $this->assertSame("\e[37;41mwheee\e[39;49m", $mario->apply('wheee'));
  300. $luigi = $formatter->getStyle('luigi');
  301. $this->assertSame("\e[37;42mwheee\e[39;49m", $luigi->apply('wheee'));
  302. }
  303. public function testSetFormatterStylesRuntimeUpdates()
  304. {
  305. $config = $this->getConfig();
  306. $formatter = $config->getOutput()->getFormatter();
  307. $this->assertFalse($formatter->hasStyle('mario'));
  308. $this->assertFalse($formatter->hasStyle('luigi'));
  309. $config->setFormatterStyles([
  310. 'mario' => ['white', 'red'],
  311. 'luigi' => ['white', 'green'],
  312. ]);
  313. $this->assertTrue($formatter->hasStyle('mario'));
  314. $this->assertTrue($formatter->hasStyle('luigi'));
  315. $mario = $formatter->getStyle('mario');
  316. $this->assertSame("\e[37;41mwheee\e[39;49m", $mario->apply('wheee'));
  317. $luigi = $formatter->getStyle('luigi');
  318. $this->assertSame("\e[37;42mwheee\e[39;49m", $luigi->apply('wheee'));
  319. $config->setFormatterStyles([
  320. 'mario' => ['red', 'white'],
  321. 'luigi' => ['green', 'white'],
  322. ]);
  323. $mario = $formatter->getStyle('mario');
  324. $this->assertSame("\e[31;47mwheee\e[39;49m", $mario->apply('wheee'));
  325. $luigi = $formatter->getStyle('luigi');
  326. $this->assertSame("\e[32;47mwheee\e[39;49m", $luigi->apply('wheee'));
  327. }
  328. /**
  329. * @dataProvider invalidStyles
  330. */
  331. public function testSetFormatterStylesInvalid($styles, $option)
  332. {
  333. $this->expectException(\InvalidArgumentException::class);
  334. $this->expectExceptionMessage('Invalid');
  335. $this->expectExceptionMessage($option);
  336. $config = $this->getConfig();
  337. $config->setFormatterStyles($styles);
  338. $this->fail();
  339. }
  340. public function invalidStyles()
  341. {
  342. return [
  343. [
  344. ['error' => ['burgundy', null, ['bold']]],
  345. '"burgundy"',
  346. ],
  347. [
  348. ['error' => ['red', 'ink', ['bold']]],
  349. '"ink"',
  350. ],
  351. [
  352. ['error' => ['black', 'red', ['marquee']]],
  353. '"marquee"',
  354. ],
  355. ];
  356. }
  357. /**
  358. * @dataProvider inputStrings
  359. *
  360. * @group isolation-fail
  361. */
  362. public function testConfigurationFromInput($inputString, $verbosity, $colorMode, $interactiveMode, $rawOutput, $yolo)
  363. {
  364. $input = $this->getBoundStringInput($inputString);
  365. $config = Configuration::fromInput($input);
  366. $this->assertSame($verbosity, $config->verbosity());
  367. $this->assertSame($colorMode, $config->colorMode());
  368. $this->assertSame($interactiveMode, $config->interactiveMode());
  369. $this->assertSame($rawOutput, $config->rawOutput());
  370. $this->assertSame($yolo, $config->yolo());
  371. $input = $this->getUnboundStringInput($inputString);
  372. $config = Configuration::fromInput($input);
  373. $this->assertSame($verbosity, $config->verbosity());
  374. $this->assertSame($colorMode, $config->colorMode());
  375. $this->assertSame($interactiveMode, $config->interactiveMode());
  376. $this->assertSame($rawOutput, $config->rawOutput());
  377. $this->assertSame($yolo, $config->yolo());
  378. }
  379. public function inputStrings()
  380. {
  381. return [
  382. ['', Configuration::VERBOSITY_NORMAL, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, false],
  383. ['--raw-output --color --interactive --verbose', Configuration::VERBOSITY_VERBOSE, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false],
  384. ['--raw-output --no-color --no-interactive --quiet', Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_DISABLED, Configuration::INTERACTIVE_MODE_DISABLED, true, false],
  385. ['--quiet --color --interactive', Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false],
  386. ['--quiet --yolo', Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, true],
  387. ];
  388. }
  389. /**
  390. * @group isolation-fail
  391. */
  392. public function testConfigurationFromInputSpecificity()
  393. {
  394. $input = $this->getBoundStringInput('--raw-output --color --interactive --verbose');
  395. $config = Configuration::fromInput($input);
  396. $this->assertSame(Configuration::VERBOSITY_VERBOSE, $config->verbosity());
  397. $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode());
  398. $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode());
  399. $this->assertFalse($config->rawOutput(), '--raw-output is ignored with interactive input');
  400. $input = $this->getBoundStringInput('--verbose --quiet --color --no-color --interactive --no-interactive');
  401. $config = Configuration::fromInput($input);
  402. $this->assertSame(Configuration::VERBOSITY_QUIET, $config->verbosity(), '--quiet trumps --verbose');
  403. $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode(), '--color trumps --no-color');
  404. $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode(), '--interactive trumps --no-interactive');
  405. }
  406. /**
  407. * @dataProvider verbosityInputStrings
  408. *
  409. * @group isolation-fail
  410. */
  411. public function testConfigurationFromInputVerbosityLevels($inputString, $verbosity)
  412. {
  413. $input = $this->getBoundStringInput($inputString);
  414. $config = Configuration::fromInput($input);
  415. $this->assertSame($verbosity, $config->verbosity());
  416. $input = $this->getUnboundStringInput($inputString);
  417. $config = Configuration::fromInput($input);
  418. $this->assertSame($verbosity, $config->verbosity());
  419. }
  420. public function verbosityInputStrings()
  421. {
  422. return [
  423. ['--verbose 0', Configuration::VERBOSITY_NORMAL],
  424. ['--verbose=0', Configuration::VERBOSITY_NORMAL],
  425. ['--verbose 1', Configuration::VERBOSITY_VERBOSE],
  426. ['--verbose=1', Configuration::VERBOSITY_VERBOSE],
  427. ['-v', Configuration::VERBOSITY_VERBOSE],
  428. ['--verbose 2', Configuration::VERBOSITY_VERY_VERBOSE],
  429. ['--verbose=2', Configuration::VERBOSITY_VERY_VERBOSE],
  430. ['-vv', Configuration::VERBOSITY_VERY_VERBOSE],
  431. ['--verbose 3', Configuration::VERBOSITY_DEBUG],
  432. ['--verbose=3', Configuration::VERBOSITY_DEBUG],
  433. ['-vvv', Configuration::VERBOSITY_DEBUG],
  434. // no `--verbose -1` because that's not a valid option value :P
  435. ['--verbose=-1', Configuration::VERBOSITY_QUIET],
  436. ['--quiet', Configuration::VERBOSITY_QUIET],
  437. ];
  438. }
  439. /**
  440. * @dataProvider shortInputStrings
  441. *
  442. * @group isolation-fail
  443. */
  444. public function testConfigurationFromInputShortOptions($inputString, $verbosity, $interactiveMode, $rawOutput, $skipUnbound = false)
  445. {
  446. $input = $this->getBoundStringInput($inputString);
  447. $config = Configuration::fromInput($input);
  448. $this->assertSame($verbosity, $config->verbosity());
  449. $this->assertSame($interactiveMode, $config->interactiveMode());
  450. $this->assertSame($rawOutput, $config->rawOutput());
  451. if ($skipUnbound) {
  452. $this->markTestSkipped($inputString.' fails with unbound input');
  453. }
  454. $input = $this->getUnboundStringInput($inputString);
  455. $config = Configuration::fromInput($input);
  456. $this->assertSame($verbosity, $config->verbosity());
  457. $this->assertSame($interactiveMode, $config->interactiveMode());
  458. $this->assertSame($rawOutput, $config->rawOutput());
  459. }
  460. public function shortInputStrings()
  461. {
  462. return [
  463. // Can't do `-nrq`-style compact short options with unbound input.
  464. ['-nrq', Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true, true],
  465. ['-n -r -q', Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true],
  466. ['-v', Configuration::VERBOSITY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false],
  467. ['-vv', Configuration::VERBOSITY_VERY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false],
  468. ['-vvv', Configuration::VERBOSITY_DEBUG, Configuration::INTERACTIVE_MODE_AUTO, false],
  469. ];
  470. }
  471. /**
  472. * @group isolation-fail
  473. */
  474. public function testConfigurationFromInputAliases()
  475. {
  476. $input = $this->getBoundStringInput('--ansi --interaction');
  477. $config = Configuration::fromInput($input);
  478. $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode());
  479. $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode());
  480. $input = $this->getBoundStringInput('--no-ansi --no-interaction');
  481. $config = Configuration::fromInput($input);
  482. $this->assertSame(Configuration::COLOR_MODE_DISABLED, $config->colorMode());
  483. $this->assertSame(Configuration::INTERACTIVE_MODE_DISABLED, $config->interactiveMode());
  484. }
  485. private function getBoundStringInput($string, $configFile = null)
  486. {
  487. $input = $this->getUnboundStringInput($string, $configFile);
  488. $input->bind(new InputDefinition(Configuration::getInputOptions()));
  489. return $input;
  490. }
  491. private function getUnboundStringInput($string, $configFile = null)
  492. {
  493. if ($configFile === null) {
  494. $configFile = __DIR__.'/fixtures/empty.php';
  495. }
  496. return new StringInput($string.' --config '.\escapeshellarg($configFile));
  497. }
  498. public function testYoloMode()
  499. {
  500. $config = $this->getConfig();
  501. $this->assertFalse($config->yolo());
  502. $config->setYolo(true);
  503. $this->assertTrue($config->yolo());
  504. // The CodeCleaner will not be updated after the first time we access it:
  505. $this->assertTrue($config->getCodeCleaner()->yolo());
  506. }
  507. }