Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Psy\Test; use Psy\CodeCleaner; use Psy\Configuration; use Psy\ExecutionLo..

Decoded Output download

<?php
 namespace Psy\Test; use Psy\CodeCleaner; use Psy\Configuration; use Psy\ExecutionLoop\ProcessForker; use Psy\Output\PassthruPager; use Psy\Output\ShellOutput; use Psy\VersionUpdater\GitHubChecker; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; class ConfigurationTest extends TestCase { private function getConfig($configFile = null) { return new Configuration(array("configFile" => $configFile ?: __DIR__ . "/fixtures/empty.php")); } public function testDefaults() { $config = $this->getConfig(); $this->assertSame(unction_exists("readline"), $config->hasReadline()); $this->assertSame(unction_exists("readline"), $config->useReadline()); $this->assertSame(ProcessForker::isSupported(), $config->hasPcntl()); $this->assertSame($config->hasPcntl(), $config->usePcntl()); $this->assertFalse($config->requireSemicolons()); $this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode()); $this->assertNull($config->getStartupMessage()); } public function testGettersAndSetters() { $config = $this->getConfig(); $this->assertNull($config->getDataDir()); $config->setDataDir("wheee"); $this->assertSame("wheee", $config->getDataDir()); $this->assertNull($config->getConfigDir()); $config->setConfigDir("wheee"); $this->assertSame("wheee", $config->getConfigDir()); } public function testLoadConfig() { $config = $this->getConfig(); $cleaner = new CodeCleaner(); $pager = new PassthruPager(new ConsoleOutput()); $config->loadConfig(array("useReadline" => false, "usePcntl" => false, "codeCleaner" => $cleaner, "pager" => $pager, "requireSemicolons" => true, "errorLoggingLevel" => \E_ERROR | \E_WARNING, "colorMode" => Configuration::COLOR_MODE_FORCED, "startupMessage" => "Psysh is awesome!")); $this->assertFalse($config->useReadline()); $this->assertFalse($config->usePcntl()); $this->assertSame($cleaner, $config->getCodeCleaner()); $this->assertSame($pager, $config->getPager()); $this->assertTrue($config->requireSemicolons()); $this->assertSame(\E_ERROR | \E_WARNING, $config->errorLoggingLevel()); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame("Psysh is awesome!", $config->getStartupMessage()); } public function testLoadConfigFile() { $config = $this->getConfig(__DIR__ . "/fixtures/config.php"); $runtimeDir = $this->joinPath(
ealpath(\sys_get_temp_dir()), "psysh_test", "withconfig", "temp"); $this->assertStringStartsWith($runtimeDir, 
ealpath($config->getTempFile("foo", 123))); $this->assertStringStartsWith($runtimeDir, 
ealpath(\dirname($config->getPipe("pipe", 123)))); $this->assertStringStartsWith($runtimeDir, 
ealpath($config->getRuntimeDir())); $this->assertSame(unction_exists("readline"), $config->useReadline()); $this->assertFalse($config->usePcntl()); $this->assertSame(\E_ALL & ~\E_NOTICE, $config->errorLoggingLevel()); } public function testLoadLocalConfigFile() { $oldPwd = \getcwd(); \chdir(
ealpath(__DIR__ . "/fixtures/project/")); $config = new Configuration(); $this->assertTrue($config->requireSemicolons()); $this->assertFalse($config->useUnicode()); $config = new Configuration(array("configFile" => __DIR__ . "/fixtures/config.php")); $this->assertFalse($config->requireSemicolons()); $this->assertTrue($config->useUnicode()); \chdir($oldPwd); } public function testUnknownConfigFileThrowsException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Invalid configuration file specified"); $config = new Configuration(array("configFile" => __DIR__ . "/not/a/real/config.php")); $this->fail(); } public function testBaseDirConfigIsDeprecated() { $this->expectException(\Psy\Exception\DeprecatedException::class); $config = new Configuration(array("baseDir" => "fake")); $this->fail(); } private function joinPath(...$parts) { return \implode(\DIRECTORY_SEPARATOR, $parts); } public function testConfigIncludes() { $config = new Configuration(array("defaultIncludes" => array("/file.php"), "configFile" => __DIR__ . "/fixtures/empty.php")); $includes = $config->getDefaultIncludes(); $this->assertCount(1, $includes); $this->assertSame("/file.php", $includes[0]); } public function testGetOutput() { $config = $this->getConfig(); $output = $config->getOutput(); $this->assertInstanceOf(ShellOutput::class, $output); } public function getOutputDecoratedProvider() { return array("auto" => array(null, Configuration::COLOR_MODE_AUTO), "forced" => array(true, Configuration::COLOR_MODE_FORCED), "disabled" => array(false, Configuration::COLOR_MODE_DISABLED)); } public function testGetOutputDecorated($expectation, $colorMode) { if ($colorMode === Configuration::COLOR_MODE_AUTO) { $this->markTestSkipped("This test won't work on CI without overriding pipe detection"); } $config = $this->getConfig(); $config->setColorMode($colorMode); $this->assertSame($expectation, $config->getOutputDecorated()); } public function setColorModeValidProvider() { return array("auto" => array(Configuration::COLOR_MODE_AUTO), "forced" => array(Configuration::COLOR_MODE_FORCED), "disabled" => array(Configuration::COLOR_MODE_DISABLED)); } public function testSetColorModeValid($colorMode) { $config = $this->getConfig(); $config->setColorMode($colorMode); $this->assertSame($colorMode, $config->colorMode()); } public function testSetColorModeInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Invalid color mode: some invalid mode"); $config = $this->getConfig(); $config->setColorMode("some invalid mode"); $this->fail(); } public function getOutputVerbosityProvider() { return array("quiet" => array(OutputInterface::VERBOSITY_QUIET, Configuration::VERBOSITY_QUIET), "normal" => array(OutputInterface::VERBOSITY_NORMAL, Configuration::VERBOSITY_NORMAL), "verbose" => array(OutputInterface::VERBOSITY_VERBOSE, Configuration::VERBOSITY_VERBOSE), "very_verbose" => array(OutputInterface::VERBOSITY_VERY_VERBOSE, Configuration::VERBOSITY_VERY_VERBOSE), "debug" => array(OutputInterface::VERBOSITY_DEBUG, Configuration::VERBOSITY_DEBUG)); } public function testGetOutputVerbosity($expectation, $verbosity) { $config = $this->getConfig(); $config->setVerbosity($verbosity); $this->assertSame($expectation, $config->getOutputVerbosity()); } public function setVerbosityValidProvider() { return array("quiet" => array(Configuration::VERBOSITY_QUIET), "normal" => array(Configuration::VERBOSITY_NORMAL), "verbose" => array(Configuration::VERBOSITY_VERBOSE), "very_verbose" => array(Configuration::VERBOSITY_VERY_VERBOSE), "debug" => array(Configuration::VERBOSITY_DEBUG)); } public function testSetVerbosityValid($verbosity) { $config = $this->getConfig(); $config->setVerbosity($verbosity); $this->assertSame($verbosity, $config->verbosity()); } public function testSetVerbosityInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Invalid verbosity level: some invalid verbosity"); $config = $this->getConfig(); $config->setVerbosity("some invalid verbosity"); $this->fail(); } public function getInputInteractiveProvider() { return array("auto" => array(null, Configuration::INTERACTIVE_MODE_AUTO), "forced" => array(true, Configuration::INTERACTIVE_MODE_FORCED), "disabled" => array(false, Configuration::INTERACTIVE_MODE_DISABLED)); } public function testGetInputInteractive($expectation, $interactive) { if ($interactive === Configuration::INTERACTIVE_MODE_AUTO) { $this->markTestSkipped("This test won't work on CI without overriding pipe detection"); } $config = $this->getConfig(); $config->setInteractiveMode($interactive); $this->assertSame($expectation, $config->getInputInteractive()); } public function setInteractiveModeValidProvider() { return array("auto" => array(Configuration::INTERACTIVE_MODE_AUTO), "forced" => array(Configuration::INTERACTIVE_MODE_FORCED), "disabled" => array(Configuration::INTERACTIVE_MODE_DISABLED)); } public function testsetInteractiveModeValid($interactive) { $config = $this->getConfig(); $config->setInteractiveMode($interactive); $this->assertSame($interactive, $config->interactiveMode()); } public function testsetInteractiveModeInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Invalid interactive mode: nope"); $config = $this->getConfig(); $config->setInteractiveMode("nope"); $this->fail(); } public function testSetCheckerValid() { $config = $this->getConfig(); $checker = new GitHubChecker(); $config->setChecker($checker); $this->assertSame($checker, $config->getChecker()); } public function testSetFormatterStyles() { $config = $this->getConfig(); $config->setFormatterStyles(array("mario" => array("white", "red"), "luigi" => array("white", "green"))); $formatter = $config->getOutput()->getFormatter(); $this->assertTrue($formatter->hasStyle("mario")); $this->assertTrue($formatter->hasStyle("luigi")); $mario = $formatter->getStyle("mario"); $this->assertSame("[37;41mwheee[39;49m", $mario->apply("wheee")); $luigi = $formatter->getStyle("luigi"); $this->assertSame("[37;42mwheee[39;49m", $luigi->apply("wheee")); } public function testSetFormatterStylesRuntimeUpdates() { $config = $this->getConfig(); $formatter = $config->getOutput()->getFormatter(); $this->assertFalse($formatter->hasStyle("mario")); $this->assertFalse($formatter->hasStyle("luigi")); $config->setFormatterStyles(array("mario" => array("white", "red"), "luigi" => array("white", "green"))); $this->assertTrue($formatter->hasStyle("mario")); $this->assertTrue($formatter->hasStyle("luigi")); $mario = $formatter->getStyle("mario"); $this->assertSame("[37;41mwheee[39;49m", $mario->apply("wheee")); $luigi = $formatter->getStyle("luigi"); $this->assertSame("[37;42mwheee[39;49m", $luigi->apply("wheee")); $config->setFormatterStyles(array("mario" => array("red", "white"), "luigi" => array("green", "white"))); $mario = $formatter->getStyle("mario"); $this->assertSame("[31;47mwheee[39;49m", $mario->apply("wheee")); $luigi = $formatter->getStyle("luigi"); $this->assertSame("[32;47mwheee[39;49m", $luigi->apply("wheee")); } public function testSetFormatterStylesInvalid($styles, $option) { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Invalid"); $this->expectExceptionMessage($option); $config = $this->getConfig(); $config->setFormatterStyles($styles); $this->fail(); } public function invalidStyles() { return array(array(array("error" => array("burgundy", null, array("bold"))), ""burgundy""), array(array("error" => array("red", "ink", array("bold"))), ""ink""), array(array("error" => array("black", "red", array("marquee"))), ""marquee"")); } public function testConfigurationFromInput($inputString, $verbosity, $colorMode, $interactiveMode, $rawOutput, $yolo) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($colorMode, $config->colorMode()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); $this->assertSame($yolo, $config->yolo()); $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($colorMode, $config->colorMode()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); $this->assertSame($yolo, $config->yolo()); } public function inputStrings() { return array(array('', Configuration::VERBOSITY_NORMAL, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, false), array("--raw-output --color --interactive --verbose", Configuration::VERBOSITY_VERBOSE, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("--raw-output --no-color --no-interactive --quiet", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_DISABLED, Configuration::INTERACTIVE_MODE_DISABLED, true, false), array("--quiet --color --interactive", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("--quiet --yolo", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, true)); } public function testConfigurationFromInputSpecificity() { $input = $this->getBoundStringInput("--raw-output --color --interactive --verbose"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::VERBOSITY_VERBOSE, $config->verbosity()); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode()); $this->assertFalse($config->rawOutput(), "--raw-output is ignored with interactive input"); $input = $this->getBoundStringInput("--verbose --quiet --color --no-color --interactive --no-interactive"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::VERBOSITY_QUIET, $config->verbosity(), "--quiet trumps --verbose"); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode(), "--color trumps --no-color"); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode(), "--interactive trumps --no-interactive"); } public function testConfigurationFromInputVerbosityLevels($inputString, $verbosity) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); } public function verbosityInputStrings() { return array(array("--verbose 0", Configuration::VERBOSITY_NORMAL), array("--verbose=0", Configuration::VERBOSITY_NORMAL), array("--verbose 1", Configuration::VERBOSITY_VERBOSE), array("--verbose=1", Configuration::VERBOSITY_VERBOSE), array("-v", Configuration::VERBOSITY_VERBOSE), array("--verbose 2", Configuration::VERBOSITY_VERY_VERBOSE), array("--verbose=2", Configuration::VERBOSITY_VERY_VERBOSE), array("-vv", Configuration::VERBOSITY_VERY_VERBOSE), array("--verbose 3", Configuration::VERBOSITY_DEBUG), array("--verbose=3", Configuration::VERBOSITY_DEBUG), array("-vvv", Configuration::VERBOSITY_DEBUG), array("--verbose=-1", Configuration::VERBOSITY_QUIET), array("--quiet", Configuration::VERBOSITY_QUIET)); } public function testConfigurationFromInputShortOptions($inputString, $verbosity, $interactiveMode, $rawOutput, $skipUnbound = false) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); if ($skipUnbound) { $this->markTestSkipped($inputString . " fails with unbound input"); } $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); } public function shortInputStrings() { return array(array("-nrq", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true, true), array("-n -r -q", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true), array("-v", Configuration::VERBOSITY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("-vv", Configuration::VERBOSITY_VERY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("-vvv", Configuration::VERBOSITY_DEBUG, Configuration::INTERACTIVE_MODE_AUTO, false)); } public function testConfigurationFromInputAliases() { $input = $this->getBoundStringInput("--ansi --interaction"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode()); $input = $this->getBoundStringInput("--no-ansi --no-interaction"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::COLOR_MODE_DISABLED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_DISABLED, $config->interactiveMode()); } private function getBoundStringInput($string, $configFile = null) { $input = $this->getUnboundStringInput($string, $configFile); $input->bind(new InputDefinition(Configuration::getInputOptions())); return $input; } private function getUnboundStringInput($string, $configFile = null) { if ($configFile === null) { $configFile = __DIR__ . "/fixtures/empty.php"; } return new StringInput($string . " --config " . \escapeshellarg($configFile)); } public function testYoloMode() { $config = $this->getConfig(); $this->assertFalse($config->yolo()); $config->setYolo(true); $this->assertTrue($config->yolo()); $this->assertTrue($config->getCodeCleaner()->yolo()); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Psy\Test; use Psy\CodeCleaner; use Psy\Configuration; use Psy\ExecutionLoop\ProcessForker; use Psy\Output\PassthruPager; use Psy\Output\ShellOutput; use Psy\VersionUpdater\GitHubChecker; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; class ConfigurationTest extends TestCase { private function getConfig($configFile = null) { return new Configuration(array("\x63\x6f\x6e\146\151\x67\x46\151\x6c\x65" => $configFile ?: __DIR__ . "\57\x66\151\x78\x74\x75\162\145\x73\x2f\x65\155\160\164\171\56\x70\150\x70")); } public function testDefaults() { $config = $this->getConfig(); $this->assertSame(\function_exists("\162\145\x61\x64\x6c\x69\x6e\145"), $config->hasReadline()); $this->assertSame(\function_exists("\162\145\x61\x64\154\151\x6e\x65"), $config->useReadline()); $this->assertSame(ProcessForker::isSupported(), $config->hasPcntl()); $this->assertSame($config->hasPcntl(), $config->usePcntl()); $this->assertFalse($config->requireSemicolons()); $this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode()); $this->assertNull($config->getStartupMessage()); } public function testGettersAndSetters() { $config = $this->getConfig(); $this->assertNull($config->getDataDir()); $config->setDataDir("\x77\x68\145\x65\x65"); $this->assertSame("\167\150\145\145\x65", $config->getDataDir()); $this->assertNull($config->getConfigDir()); $config->setConfigDir("\167\x68\x65\145\145"); $this->assertSame("\167\150\x65\x65\145", $config->getConfigDir()); } public function testLoadConfig() { $config = $this->getConfig(); $cleaner = new CodeCleaner(); $pager = new PassthruPager(new ConsoleOutput()); $config->loadConfig(array("\165\163\x65\x52\145\141\x64\154\x69\x6e\145" => false, "\165\163\145\120\143\156\164\154" => false, "\143\x6f\144\x65\x43\x6c\145\141\x6e\x65\x72" => $cleaner, "\160\141\147\x65\x72" => $pager, "\162\x65\161\x75\x69\x72\145\x53\145\155\151\143\157\154\157\156\163" => true, "\x65\x72\x72\157\162\114\157\x67\147\151\156\x67\x4c\x65\166\x65\x6c" => \E_ERROR | \E_WARNING, "\x63\157\x6c\157\162\115\x6f\144\x65" => Configuration::COLOR_MODE_FORCED, "\x73\164\141\162\x74\x75\160\115\145\163\163\x61\x67\145" => "\x50\x73\171\163\x68\40\x69\x73\x20\x61\x77\145\163\157\x6d\145\41")); $this->assertFalse($config->useReadline()); $this->assertFalse($config->usePcntl()); $this->assertSame($cleaner, $config->getCodeCleaner()); $this->assertSame($pager, $config->getPager()); $this->assertTrue($config->requireSemicolons()); $this->assertSame(\E_ERROR | \E_WARNING, $config->errorLoggingLevel()); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame("\x50\x73\171\x73\150\x20\151\163\x20\x61\167\x65\163\x6f\x6d\145\41", $config->getStartupMessage()); } public function testLoadConfigFile() { $config = $this->getConfig(__DIR__ . "\x2f\x66\x69\170\x74\x75\x72\x65\x73\x2f\143\x6f\156\x66\151\x67\x2e\x70\x68\x70"); $runtimeDir = $this->joinPath(\realpath(\sys_get_temp_dir()), "\x70\x73\171\163\150\137\164\145\x73\164", "\x77\151\x74\150\x63\x6f\x6e\146\151\147", "\x74\x65\155\160"); $this->assertStringStartsWith($runtimeDir, \realpath($config->getTempFile("\x66\157\x6f", 123))); $this->assertStringStartsWith($runtimeDir, \realpath(\dirname($config->getPipe("\x70\x69\160\x65", 123)))); $this->assertStringStartsWith($runtimeDir, \realpath($config->getRuntimeDir())); $this->assertSame(\function_exists("\x72\x65\x61\x64\154\151\x6e\x65"), $config->useReadline()); $this->assertFalse($config->usePcntl()); $this->assertSame(\E_ALL & ~\E_NOTICE, $config->errorLoggingLevel()); } public function testLoadLocalConfigFile() { $oldPwd = \getcwd(); \chdir(\realpath(__DIR__ . "\x2f\x66\x69\x78\164\x75\x72\x65\163\57\160\162\157\152\x65\x63\x74\57")); $config = new Configuration(); $this->assertTrue($config->requireSemicolons()); $this->assertFalse($config->useUnicode()); $config = new Configuration(array("\143\157\156\x66\151\x67\106\x69\154\x65" => __DIR__ . "\57\146\x69\170\x74\x75\162\145\163\x2f\143\x6f\x6e\x66\151\147\56\x70\x68\x70")); $this->assertFalse($config->requireSemicolons()); $this->assertTrue($config->useUnicode()); \chdir($oldPwd); } public function testUnknownConfigFileThrowsException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\111\156\x76\141\x6c\x69\x64\40\143\x6f\156\146\x69\147\x75\x72\x61\x74\151\x6f\x6e\40\146\x69\154\x65\x20\x73\160\x65\143\151\x66\x69\145\144"); $config = new Configuration(array("\x63\x6f\156\146\151\147\x46\151\x6c\145" => __DIR__ . "\57\x6e\x6f\164\x2f\x61\x2f\162\x65\141\x6c\x2f\x63\157\x6e\146\151\147\56\160\x68\160")); $this->fail(); } public function testBaseDirConfigIsDeprecated() { $this->expectException(\Psy\Exception\DeprecatedException::class); $config = new Configuration(array("\x62\x61\163\145\x44\x69\162" => "\146\x61\x6b\145")); $this->fail(); } private function joinPath(...$parts) { return \implode(\DIRECTORY_SEPARATOR, $parts); } public function testConfigIncludes() { $config = new Configuration(array("\144\x65\146\141\165\x6c\164\111\156\x63\x6c\165\x64\x65\163" => array("\57\x66\151\x6c\x65\56\160\150\160"), "\x63\x6f\156\x66\x69\x67\106\151\154\145" => __DIR__ . "\x2f\146\x69\170\164\x75\x72\x65\x73\x2f\x65\155\x70\x74\x79\56\160\150\x70")); $includes = $config->getDefaultIncludes(); $this->assertCount(1, $includes); $this->assertSame("\x2f\x66\151\154\x65\56\160\150\160", $includes[0]); } public function testGetOutput() { $config = $this->getConfig(); $output = $config->getOutput(); $this->assertInstanceOf(ShellOutput::class, $output); } public function getOutputDecoratedProvider() { return array("\x61\165\x74\x6f" => array(null, Configuration::COLOR_MODE_AUTO), "\146\x6f\x72\x63\x65\x64" => array(true, Configuration::COLOR_MODE_FORCED), "\144\151\163\x61\x62\154\145\144" => array(false, Configuration::COLOR_MODE_DISABLED)); } public function testGetOutputDecorated($expectation, $colorMode) { if ($colorMode === Configuration::COLOR_MODE_AUTO) { $this->markTestSkipped("\x54\150\x69\163\x20\x74\x65\163\x74\x20\167\157\x6e\47\164\40\167\x6f\162\x6b\x20\x6f\x6e\40\103\x49\x20\x77\x69\164\x68\x6f\165\x74\x20\x6f\166\145\162\162\151\144\x69\156\147\40\x70\x69\160\x65\x20\x64\x65\164\x65\143\164\x69\157\x6e"); } $config = $this->getConfig(); $config->setColorMode($colorMode); $this->assertSame($expectation, $config->getOutputDecorated()); } public function setColorModeValidProvider() { return array("\141\165\164\x6f" => array(Configuration::COLOR_MODE_AUTO), "\146\157\162\x63\x65\x64" => array(Configuration::COLOR_MODE_FORCED), "\x64\151\x73\141\142\154\x65\x64" => array(Configuration::COLOR_MODE_DISABLED)); } public function testSetColorModeValid($colorMode) { $config = $this->getConfig(); $config->setColorMode($colorMode); $this->assertSame($colorMode, $config->colorMode()); } public function testSetColorModeInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\x6e\166\x61\x6c\x69\144\40\x63\157\154\157\x72\x20\155\157\144\145\72\x20\163\157\155\145\40\151\x6e\x76\x61\x6c\151\144\40\x6d\157\144\x65"); $config = $this->getConfig(); $config->setColorMode("\x73\157\x6d\x65\x20\151\x6e\x76\x61\154\x69\144\40\x6d\157\x64\145"); $this->fail(); } public function getOutputVerbosityProvider() { return array("\x71\x75\151\145\x74" => array(OutputInterface::VERBOSITY_QUIET, Configuration::VERBOSITY_QUIET), "\x6e\x6f\x72\x6d\x61\154" => array(OutputInterface::VERBOSITY_NORMAL, Configuration::VERBOSITY_NORMAL), "\x76\x65\x72\x62\x6f\163\145" => array(OutputInterface::VERBOSITY_VERBOSE, Configuration::VERBOSITY_VERBOSE), "\166\145\x72\171\137\x76\145\x72\x62\157\163\x65" => array(OutputInterface::VERBOSITY_VERY_VERBOSE, Configuration::VERBOSITY_VERY_VERBOSE), "\x64\x65\x62\165\x67" => array(OutputInterface::VERBOSITY_DEBUG, Configuration::VERBOSITY_DEBUG)); } public function testGetOutputVerbosity($expectation, $verbosity) { $config = $this->getConfig(); $config->setVerbosity($verbosity); $this->assertSame($expectation, $config->getOutputVerbosity()); } public function setVerbosityValidProvider() { return array("\x71\x75\x69\x65\x74" => array(Configuration::VERBOSITY_QUIET), "\156\x6f\x72\155\x61\x6c" => array(Configuration::VERBOSITY_NORMAL), "\166\x65\x72\x62\157\x73\145" => array(Configuration::VERBOSITY_VERBOSE), "\166\x65\x72\x79\x5f\166\145\162\x62\x6f\x73\x65" => array(Configuration::VERBOSITY_VERY_VERBOSE), "\x64\145\142\x75\147" => array(Configuration::VERBOSITY_DEBUG)); } public function testSetVerbosityValid($verbosity) { $config = $this->getConfig(); $config->setVerbosity($verbosity); $this->assertSame($verbosity, $config->verbosity()); } public function testSetVerbosityInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\x6e\x76\x61\x6c\151\144\40\166\145\x72\x62\157\x73\x69\164\x79\x20\154\145\166\145\x6c\72\40\163\157\x6d\x65\40\151\x6e\x76\x61\154\x69\x64\40\166\x65\162\x62\x6f\x73\151\x74\171"); $config = $this->getConfig(); $config->setVerbosity("\163\157\155\x65\40\x69\x6e\x76\141\x6c\x69\x64\x20\166\x65\162\142\157\163\x69\x74\171"); $this->fail(); } public function getInputInteractiveProvider() { return array("\141\x75\x74\x6f" => array(null, Configuration::INTERACTIVE_MODE_AUTO), "\146\157\x72\143\145\x64" => array(true, Configuration::INTERACTIVE_MODE_FORCED), "\x64\x69\163\141\x62\x6c\145\144" => array(false, Configuration::INTERACTIVE_MODE_DISABLED)); } public function testGetInputInteractive($expectation, $interactive) { if ($interactive === Configuration::INTERACTIVE_MODE_AUTO) { $this->markTestSkipped("\x54\x68\x69\x73\40\164\x65\163\x74\40\167\157\x6e\x27\x74\40\x77\x6f\x72\x6b\x20\x6f\x6e\x20\x43\111\x20\167\151\x74\150\157\x75\x74\40\157\x76\x65\x72\162\151\144\x69\x6e\x67\40\x70\151\160\x65\x20\144\x65\x74\x65\x63\x74\151\x6f\x6e"); } $config = $this->getConfig(); $config->setInteractiveMode($interactive); $this->assertSame($expectation, $config->getInputInteractive()); } public function setInteractiveModeValidProvider() { return array("\x61\165\x74\157" => array(Configuration::INTERACTIVE_MODE_AUTO), "\x66\157\x72\143\x65\144" => array(Configuration::INTERACTIVE_MODE_FORCED), "\144\x69\163\141\142\x6c\145\x64" => array(Configuration::INTERACTIVE_MODE_DISABLED)); } public function testsetInteractiveModeValid($interactive) { $config = $this->getConfig(); $config->setInteractiveMode($interactive); $this->assertSame($interactive, $config->interactiveMode()); } public function testsetInteractiveModeInvalid() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\x6e\x76\x61\x6c\151\144\x20\151\156\x74\x65\162\141\143\164\x69\x76\x65\x20\x6d\157\x64\145\x3a\x20\156\x6f\x70\145"); $config = $this->getConfig(); $config->setInteractiveMode("\156\157\160\145"); $this->fail(); } public function testSetCheckerValid() { $config = $this->getConfig(); $checker = new GitHubChecker(); $config->setChecker($checker); $this->assertSame($checker, $config->getChecker()); } public function testSetFormatterStyles() { $config = $this->getConfig(); $config->setFormatterStyles(array("\x6d\141\x72\x69\157" => array("\x77\150\151\164\x65", "\162\x65\144"), "\154\x75\x69\147\151" => array("\167\x68\x69\164\x65", "\147\162\x65\x65\x6e"))); $formatter = $config->getOutput()->getFormatter(); $this->assertTrue($formatter->hasStyle("\155\141\162\x69\x6f")); $this->assertTrue($formatter->hasStyle("\x6c\165\x69\147\x69")); $mario = $formatter->getStyle("\155\x61\x72\151\x6f"); $this->assertSame("\33\x5b\x33\67\73\x34\x31\155\167\150\x65\x65\x65\x1b\133\x33\71\x3b\x34\71\x6d", $mario->apply("\x77\150\145\x65\x65")); $luigi = $formatter->getStyle("\x6c\x75\x69\x67\151"); $this->assertSame("\x1b\133\63\x37\x3b\64\x32\x6d\x77\x68\145\x65\145\33\133\x33\x39\x3b\x34\71\155", $luigi->apply("\167\x68\145\x65\x65")); } public function testSetFormatterStylesRuntimeUpdates() { $config = $this->getConfig(); $formatter = $config->getOutput()->getFormatter(); $this->assertFalse($formatter->hasStyle("\x6d\141\x72\x69\x6f")); $this->assertFalse($formatter->hasStyle("\x6c\165\151\147\151")); $config->setFormatterStyles(array("\155\141\162\151\157" => array("\x77\150\x69\x74\145", "\x72\145\144"), "\154\x75\x69\147\x69" => array("\x77\150\151\164\145", "\147\x72\x65\x65\x6e"))); $this->assertTrue($formatter->hasStyle("\x6d\x61\x72\x69\157")); $this->assertTrue($formatter->hasStyle("\154\165\x69\147\151")); $mario = $formatter->getStyle("\155\141\162\151\157"); $this->assertSame("\x1b\133\x33\67\x3b\64\x31\155\x77\x68\x65\145\145\x1b\x5b\63\x39\x3b\x34\71\x6d", $mario->apply("\167\150\145\145\x65")); $luigi = $formatter->getStyle("\x6c\x75\x69\x67\151"); $this->assertSame("\33\x5b\63\67\73\64\62\155\167\150\145\145\x65\x1b\x5b\x33\x39\73\x34\x39\x6d", $luigi->apply("\167\150\x65\145\145")); $config->setFormatterStyles(array("\x6d\141\x72\151\157" => array("\162\x65\144", "\167\150\151\x74\x65"), "\x6c\x75\151\147\151" => array("\147\162\x65\x65\156", "\167\150\x69\x74\x65"))); $mario = $formatter->getStyle("\155\x61\x72\151\x6f"); $this->assertSame("\33\133\x33\x31\x3b\x34\x37\155\167\x68\145\145\145\33\133\63\x39\x3b\64\x39\x6d", $mario->apply("\167\150\x65\145\x65")); $luigi = $formatter->getStyle("\x6c\165\x69\147\151"); $this->assertSame("\x1b\x5b\x33\x32\x3b\64\x37\x6d\x77\150\145\x65\145\x1b\x5b\x33\x39\x3b\64\71\155", $luigi->apply("\x77\150\x65\145\x65")); } public function testSetFormatterStylesInvalid($styles, $option) { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\156\x76\x61\x6c\x69\144"); $this->expectExceptionMessage($option); $config = $this->getConfig(); $config->setFormatterStyles($styles); $this->fail(); } public function invalidStyles() { return array(array(array("\145\x72\162\x6f\162" => array("\x62\x75\x72\x67\165\156\x64\x79", null, array("\142\x6f\154\x64"))), "\42\x62\165\162\147\x75\x6e\144\x79\x22"), array(array("\x65\x72\162\x6f\x72" => array("\162\145\144", "\151\x6e\153", array("\142\157\x6c\144"))), "\42\x69\x6e\153\x22"), array(array("\145\162\162\157\162" => array("\x62\x6c\141\x63\x6b", "\162\x65\x64", array("\x6d\141\x72\x71\x75\145\145"))), "\x22\155\x61\162\x71\165\145\145\x22")); } public function testConfigurationFromInput($inputString, $verbosity, $colorMode, $interactiveMode, $rawOutput, $yolo) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($colorMode, $config->colorMode()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); $this->assertSame($yolo, $config->yolo()); $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($colorMode, $config->colorMode()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); $this->assertSame($yolo, $config->yolo()); } public function inputStrings() { return array(array('', Configuration::VERBOSITY_NORMAL, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, false), array("\x2d\x2d\162\141\167\x2d\157\x75\164\160\165\164\x20\55\55\x63\x6f\154\157\162\40\55\55\151\x6e\x74\145\162\x61\143\164\x69\x76\145\x20\55\55\166\x65\162\142\x6f\x73\145", Configuration::VERBOSITY_VERBOSE, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("\x2d\x2d\x72\x61\x77\55\157\165\164\x70\165\x74\40\55\55\x6e\157\55\x63\157\154\x6f\x72\40\x2d\55\x6e\157\x2d\151\x6e\164\x65\x72\141\x63\x74\151\x76\145\x20\x2d\x2d\161\x75\x69\145\x74", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_DISABLED, Configuration::INTERACTIVE_MODE_DISABLED, true, false), array("\55\x2d\161\165\x69\145\164\x20\x2d\55\143\157\154\157\x72\40\x2d\55\151\156\x74\x65\x72\141\143\164\151\166\145", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("\55\55\161\165\x69\x65\x74\x20\55\55\x79\157\x6c\157", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, true)); } public function testConfigurationFromInputSpecificity() { $input = $this->getBoundStringInput("\x2d\55\162\x61\167\55\x6f\165\x74\160\x75\164\40\x2d\x2d\x63\x6f\154\x6f\x72\40\x2d\55\x69\156\x74\145\162\x61\x63\164\x69\166\x65\x20\x2d\55\166\x65\162\142\x6f\163\x65"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::VERBOSITY_VERBOSE, $config->verbosity()); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode()); $this->assertFalse($config->rawOutput(), "\x2d\x2d\x72\141\x77\55\x6f\165\164\x70\165\x74\40\151\163\x20\151\147\156\157\x72\145\144\40\167\x69\164\x68\40\x69\x6e\164\145\162\141\143\164\151\x76\145\40\151\156\160\165\164"); $input = $this->getBoundStringInput("\55\55\166\145\x72\x62\x6f\x73\145\40\55\x2d\161\165\x69\x65\x74\40\x2d\x2d\143\157\x6c\x6f\x72\40\55\x2d\x6e\x6f\55\x63\157\x6c\x6f\x72\x20\55\55\151\x6e\x74\x65\x72\141\143\x74\x69\166\x65\x20\55\55\156\157\x2d\x69\156\x74\x65\x72\x61\x63\x74\x69\x76\145"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::VERBOSITY_QUIET, $config->verbosity(), "\55\x2d\x71\165\x69\x65\x74\x20\164\x72\165\x6d\160\x73\40\55\55\x76\145\x72\x62\x6f\x73\x65"); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode(), "\55\55\x63\157\x6c\x6f\162\40\164\162\165\155\160\x73\40\55\55\156\157\55\143\x6f\x6c\157\x72"); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode(), "\x2d\x2d\151\x6e\164\145\162\x61\x63\164\151\x76\145\x20\x74\x72\165\x6d\x70\x73\40\x2d\55\x6e\x6f\55\x69\156\x74\145\162\x61\143\x74\x69\166\145"); } public function testConfigurationFromInputVerbosityLevels($inputString, $verbosity) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); } public function verbosityInputStrings() { return array(array("\x2d\x2d\x76\145\162\x62\x6f\163\145\x20\60", Configuration::VERBOSITY_NORMAL), array("\55\55\x76\145\x72\142\157\163\145\x3d\x30", Configuration::VERBOSITY_NORMAL), array("\55\55\166\145\162\x62\157\x73\x65\x20\61", Configuration::VERBOSITY_VERBOSE), array("\55\x2d\x76\145\x72\142\157\163\x65\x3d\x31", Configuration::VERBOSITY_VERBOSE), array("\x2d\x76", Configuration::VERBOSITY_VERBOSE), array("\55\x2d\166\x65\162\142\x6f\163\145\40\x32", Configuration::VERBOSITY_VERY_VERBOSE), array("\x2d\55\166\145\162\x62\x6f\163\x65\x3d\x32", Configuration::VERBOSITY_VERY_VERBOSE), array("\x2d\166\x76", Configuration::VERBOSITY_VERY_VERBOSE), array("\x2d\55\x76\x65\x72\142\x6f\163\x65\40\x33", Configuration::VERBOSITY_DEBUG), array("\55\x2d\x76\x65\x72\142\x6f\163\x65\x3d\x33", Configuration::VERBOSITY_DEBUG), array("\55\x76\x76\x76", Configuration::VERBOSITY_DEBUG), array("\x2d\x2d\166\x65\162\x62\x6f\x73\x65\75\x2d\x31", Configuration::VERBOSITY_QUIET), array("\55\x2d\161\165\151\145\164", Configuration::VERBOSITY_QUIET)); } public function testConfigurationFromInputShortOptions($inputString, $verbosity, $interactiveMode, $rawOutput, $skipUnbound = false) { $input = $this->getBoundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); if ($skipUnbound) { $this->markTestSkipped($inputString . "\40\146\x61\x69\154\x73\x20\x77\151\x74\x68\x20\165\x6e\142\x6f\x75\x6e\144\40\151\156\160\x75\164"); } $input = $this->getUnboundStringInput($inputString); $config = Configuration::fromInput($input); $this->assertSame($verbosity, $config->verbosity()); $this->assertSame($interactiveMode, $config->interactiveMode()); $this->assertSame($rawOutput, $config->rawOutput()); } public function shortInputStrings() { return array(array("\x2d\x6e\x72\x71", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true, true), array("\x2d\x6e\x20\x2d\162\x20\x2d\161", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true), array("\x2d\x76", Configuration::VERBOSITY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("\x2d\x76\166", Configuration::VERBOSITY_VERY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("\x2d\166\x76\166", Configuration::VERBOSITY_DEBUG, Configuration::INTERACTIVE_MODE_AUTO, false)); } public function testConfigurationFromInputAliases() { $input = $this->getBoundStringInput("\x2d\55\x61\156\163\x69\40\x2d\55\x69\156\x74\145\162\x61\143\x74\x69\x6f\156"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode()); $input = $this->getBoundStringInput("\x2d\55\156\x6f\55\141\x6e\x73\x69\40\x2d\55\156\x6f\55\x69\x6e\164\x65\162\141\143\x74\x69\157\x6e"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::COLOR_MODE_DISABLED, $config->colorMode()); $this->assertSame(Configuration::INTERACTIVE_MODE_DISABLED, $config->interactiveMode()); } private function getBoundStringInput($string, $configFile = null) { $input = $this->getUnboundStringInput($string, $configFile); $input->bind(new InputDefinition(Configuration::getInputOptions())); return $input; } private function getUnboundStringInput($string, $configFile = null) { if ($configFile === null) { $configFile = __DIR__ . "\x2f\x66\x69\170\x74\x75\x72\x65\163\57\x65\155\160\x74\x79\x2e\160\150\160"; } return new StringInput($string . "\40\55\55\143\x6f\156\x66\x69\x67\40" . \escapeshellarg($configFile)); } public function testYoloMode() { $config = $this->getConfig(); $this->assertFalse($config->yolo()); $config->setYolo(true); $this->assertTrue($config->yolo()); $this->assertTrue($config->getCodeCleaner()->yolo()); } }

Function Calls

None

Variables

None

Stats

MD5 0d2411f3a1842f835e75cab44438cfbc
Eval Count 0
Decode Time 97 ms