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("\143\157\156\x66\151\x67\x46\151\154\145" => $configFile ?: __DIR__ . "\x2f\x66\151\170\x74\x75\x72\x65\163\x2f\x65\x6d\160\x74\x79\56\160\x68\x70")); } public function testDefaults() { $config = $this->getConfig(); $this->assertSame(\function_exists("\x72\x65\x61\144\x6c\151\x6e\145"), $config->hasReadline()); $this->assertSame(\function_exists("\x72\x65\x61\144\x6c\x69\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("\167\150\145\145\x65"); $this->assertSame("\x77\150\x65\145\x65", $config->getDataDir()); $this->assertNull($config->getConfigDir()); $config->setConfigDir("\167\150\x65\x65\x65"); $this->assertSame("\x77\150\x65\x65\145", $config->getConfigDir()); } public function testLoadConfig() { $config = $this->getConfig(); $cleaner = new CodeCleaner(); $pager = new PassthruPager(new ConsoleOutput()); $config->loadConfig(array("\x75\163\145\x52\145\141\x64\154\151\x6e\145" => false, "\165\x73\145\120\x63\x6e\x74\154" => false, "\143\x6f\x64\145\x43\x6c\x65\141\156\145\162" => $cleaner, "\160\141\x67\x65\162" => $pager, "\162\145\161\x75\151\x72\x65\x53\x65\155\151\x63\157\x6c\x6f\156\x73" => true, "\x65\162\x72\x6f\162\x4c\x6f\x67\147\151\156\147\114\x65\x76\145\154" => \E_ERROR | \E_WARNING, "\x63\157\x6c\x6f\x72\x4d\157\144\x65" => Configuration::COLOR_MODE_FORCED, "\x73\x74\141\162\164\165\x70\x4d\145\x73\x73\x61\x67\145" => "\x50\163\171\x73\150\x20\x69\163\40\x61\167\145\x73\157\155\145\x21")); $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\x68\40\x69\163\40\141\x77\145\x73\157\x6d\145\41", $config->getStartupMessage()); } public function testLoadConfigFile() { $config = $this->getConfig(__DIR__ . "\57\146\151\170\x74\x75\162\x65\x73\x2f\x63\157\156\x66\x69\147\56\160\150\160"); $runtimeDir = $this->joinPath(\realpath(\sys_get_temp_dir()), "\160\163\171\163\x68\x5f\164\x65\x73\x74", "\167\151\164\150\143\x6f\x6e\x66\x69\147", "\164\x65\155\160"); $this->assertStringStartsWith($runtimeDir, \realpath($config->getTempFile("\x66\x6f\x6f", 123))); $this->assertStringStartsWith($runtimeDir, \realpath(\dirname($config->getPipe("\160\x69\x70\x65", 123)))); $this->assertStringStartsWith($runtimeDir, \realpath($config->getRuntimeDir())); $this->assertSame(\function_exists("\162\145\141\x64\154\x69\x6e\145"), $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\170\164\165\162\145\x73\57\160\162\x6f\x6a\x65\143\164\57")); $config = new Configuration(); $this->assertTrue($config->requireSemicolons()); $this->assertFalse($config->useUnicode()); $config = new Configuration(array("\143\x6f\156\x66\x69\x67\x46\151\x6c\x65" => __DIR__ . "\x2f\x66\x69\170\x74\x75\162\145\163\57\x63\x6f\x6e\x66\x69\147\x2e\160\x68\x70")); $this->assertFalse($config->requireSemicolons()); $this->assertTrue($config->useUnicode()); \chdir($oldPwd); } public function testUnknownConfigFileThrowsException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\x6e\x76\141\x6c\x69\144\x20\143\157\156\x66\151\147\165\162\x61\164\x69\x6f\x6e\x20\146\x69\154\145\40\163\160\x65\x63\x69\x66\x69\x65\144"); $config = new Configuration(array("\x63\x6f\x6e\x66\x69\147\x46\151\x6c\x65" => __DIR__ . "\57\156\157\164\x2f\x61\x2f\x72\x65\141\x6c\57\x63\157\156\146\x69\x67\x2e\x70\150\160")); $this->fail(); } public function testBaseDirConfigIsDeprecated() { $this->expectException(\Psy\Exception\DeprecatedException::class); $config = new Configuration(array("\x62\141\x73\145\104\151\162" => "\x66\141\153\145")); $this->fail(); } private function joinPath(...$parts) { return \implode(\DIRECTORY_SEPARATOR, $parts); } public function testConfigIncludes() { $config = new Configuration(array("\x64\145\x66\141\x75\x6c\x74\111\x6e\143\154\165\x64\145\163" => array("\x2f\146\x69\154\145\56\x70\x68\x70"), "\x63\157\156\x66\151\147\106\151\x6c\145" => __DIR__ . "\57\x66\x69\x78\164\x75\x72\x65\x73\57\145\155\160\164\x79\56\160\150\x70")); $includes = $config->getDefaultIncludes(); $this->assertCount(1, $includes); $this->assertSame("\57\146\x69\x6c\x65\56\160\x68\x70", $includes[0]); } public function testGetOutput() { $config = $this->getConfig(); $output = $config->getOutput(); $this->assertInstanceOf(ShellOutput::class, $output); } public function getOutputDecoratedProvider() { return array("\141\x75\x74\x6f" => array(null, Configuration::COLOR_MODE_AUTO), "\146\x6f\162\x63\145\x64" => array(true, Configuration::COLOR_MODE_FORCED), "\x64\151\x73\141\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\151\163\x20\x74\145\163\164\x20\x77\157\156\x27\x74\x20\x77\x6f\162\x6b\40\x6f\x6e\x20\103\111\40\167\x69\164\x68\157\165\x74\x20\157\x76\x65\162\162\151\x64\x69\x6e\x67\x20\160\x69\160\x65\40\x64\145\x74\145\x63\164\x69\157\156"); } $config = $this->getConfig(); $config->setColorMode($colorMode); $this->assertSame($expectation, $config->getOutputDecorated()); } public function setColorModeValidProvider() { return array("\x61\x75\164\157" => array(Configuration::COLOR_MODE_AUTO), "\x66\157\162\x63\x65\144" => array(Configuration::COLOR_MODE_FORCED), "\x64\x69\163\x61\142\154\145\144" => 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("\111\x6e\166\141\154\151\x64\40\x63\157\x6c\157\x72\40\155\x6f\x64\x65\72\x20\x73\x6f\155\145\40\x69\x6e\x76\141\x6c\151\x64\x20\155\x6f\x64\145"); $config = $this->getConfig(); $config->setColorMode("\x73\157\155\x65\40\151\156\166\x61\x6c\151\x64\x20\155\157\x64\145"); $this->fail(); } public function getOutputVerbosityProvider() { return array("\x71\165\x69\x65\x74" => array(OutputInterface::VERBOSITY_QUIET, Configuration::VERBOSITY_QUIET), "\156\x6f\x72\x6d\141\x6c" => array(OutputInterface::VERBOSITY_NORMAL, Configuration::VERBOSITY_NORMAL), "\166\x65\x72\142\157\163\x65" => array(OutputInterface::VERBOSITY_VERBOSE, Configuration::VERBOSITY_VERBOSE), "\x76\145\x72\x79\x5f\x76\145\x72\x62\x6f\x73\x65" => array(OutputInterface::VERBOSITY_VERY_VERBOSE, Configuration::VERBOSITY_VERY_VERBOSE), "\x64\145\x62\165\147" => 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("\161\165\151\x65\164" => array(Configuration::VERBOSITY_QUIET), "\x6e\x6f\x72\x6d\x61\154" => array(Configuration::VERBOSITY_NORMAL), "\166\145\162\x62\x6f\163\x65" => array(Configuration::VERBOSITY_VERBOSE), "\166\x65\162\x79\137\166\145\x72\x62\157\x73\x65" => array(Configuration::VERBOSITY_VERY_VERBOSE), "\x64\x65\142\x75\x67" => 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("\111\156\166\x61\154\x69\144\x20\166\145\162\x62\157\x73\151\164\x79\40\154\145\x76\x65\x6c\x3a\x20\x73\157\155\145\x20\x69\x6e\x76\141\154\151\144\x20\166\x65\162\142\157\163\151\x74\171"); $config = $this->getConfig(); $config->setVerbosity("\x73\157\x6d\x65\40\x69\x6e\166\x61\x6c\x69\144\x20\166\x65\162\142\157\163\x69\164\x79"); $this->fail(); } public function getInputInteractiveProvider() { return array("\141\x75\x74\157" => array(null, Configuration::INTERACTIVE_MODE_AUTO), "\x66\x6f\x72\143\x65\144" => array(true, Configuration::INTERACTIVE_MODE_FORCED), "\144\151\x73\141\x62\154\145\x64" => array(false, Configuration::INTERACTIVE_MODE_DISABLED)); } public function testGetInputInteractive($expectation, $interactive) { if ($interactive === Configuration::INTERACTIVE_MODE_AUTO) { $this->markTestSkipped("\124\x68\151\x73\40\x74\145\x73\164\x20\167\157\156\47\164\x20\167\x6f\x72\153\x20\x6f\156\40\x43\x49\x20\x77\x69\164\150\157\165\164\x20\157\x76\145\x72\x72\151\144\x69\x6e\x67\40\x70\151\x70\145\40\x64\145\164\x65\143\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\x63\x65\x64" => array(Configuration::INTERACTIVE_MODE_FORCED), "\x64\151\x73\x61\x62\154\145\144" => 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\156\166\x61\154\151\x64\40\151\x6e\x74\x65\162\x61\143\164\x69\x76\145\x20\155\x6f\144\x65\72\x20\x6e\157\x70\x65"); $config = $this->getConfig(); $config->setInteractiveMode("\x6e\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("\155\141\x72\151\x6f" => array("\x77\x68\151\164\x65", "\x72\x65\x64"), "\x6c\x75\151\x67\x69" => array("\x77\x68\x69\164\145", "\147\x72\145\145\156"))); $formatter = $config->getOutput()->getFormatter(); $this->assertTrue($formatter->hasStyle("\x6d\x61\162\151\157")); $this->assertTrue($formatter->hasStyle("\x6c\x75\151\x67\151")); $mario = $formatter->getStyle("\155\x61\x72\151\157"); $this->assertSame("\33\133\x33\67\x3b\x34\x31\x6d\x77\150\x65\x65\145\33\133\x33\71\73\x34\71\x6d", $mario->apply("\x77\x68\145\x65\145")); $luigi = $formatter->getStyle("\x6c\165\x69\147\151"); $this->assertSame("\x1b\133\x33\x37\x3b\x34\62\x6d\167\150\x65\x65\145\33\x5b\63\x39\x3b\64\x39\155", $luigi->apply("\x77\150\x65\145\145")); } public function testSetFormatterStylesRuntimeUpdates() { $config = $this->getConfig(); $formatter = $config->getOutput()->getFormatter(); $this->assertFalse($formatter->hasStyle("\x6d\141\x72\151\x6f")); $this->assertFalse($formatter->hasStyle("\154\165\x69\x67\151")); $config->setFormatterStyles(array("\155\x61\162\x69\x6f" => array("\167\x68\151\x74\x65", "\x72\x65\x64"), "\x6c\x75\151\x67\151" => array("\x77\150\151\164\145", "\x67\162\x65\x65\156"))); $this->assertTrue($formatter->hasStyle("\x6d\x61\162\151\157")); $this->assertTrue($formatter->hasStyle("\154\165\x69\147\x69")); $mario = $formatter->getStyle("\155\141\162\x69\x6f"); $this->assertSame("\33\133\x33\67\x3b\x34\x31\x6d\x77\x68\145\145\x65\33\133\x33\71\x3b\64\71\x6d", $mario->apply("\167\x68\145\145\145")); $luigi = $formatter->getStyle("\154\165\x69\x67\x69"); $this->assertSame("\33\x5b\x33\67\x3b\x34\x32\x6d\x77\150\x65\145\x65\33\x5b\x33\x39\73\x34\71\x6d", $luigi->apply("\167\x68\145\x65\145")); $config->setFormatterStyles(array("\155\x61\162\151\157" => array("\162\145\144", "\167\150\151\x74\145"), "\154\165\151\x67\x69" => array("\x67\x72\145\x65\x6e", "\x77\150\x69\x74\x65"))); $mario = $formatter->getStyle("\x6d\x61\x72\151\x6f"); $this->assertSame("\x1b\133\x33\x31\73\x34\67\155\167\150\x65\x65\x65\x1b\x5b\63\71\73\64\x39\x6d", $mario->apply("\x77\150\x65\145\x65")); $luigi = $formatter->getStyle("\154\165\151\147\151"); $this->assertSame("\33\133\x33\62\73\x34\67\155\x77\150\x65\145\x65\33\x5b\x33\71\73\64\71\x6d", $luigi->apply("\x77\150\x65\x65\145")); } public function testSetFormatterStylesInvalid($styles, $option) { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("\x49\x6e\166\141\x6c\151\x64"); $this->expectExceptionMessage($option); $config = $this->getConfig(); $config->setFormatterStyles($styles); $this->fail(); } public function invalidStyles() { return array(array(array("\x65\162\x72\x6f\162" => array("\x62\165\x72\x67\165\156\144\171", null, array("\x62\157\154\144"))), "\x22\142\165\162\x67\x75\x6e\144\171\x22"), array(array("\145\x72\162\x6f\162" => array("\x72\145\144", "\x69\156\153", array("\142\157\x6c\x64"))), "\x22\x69\x6e\x6b\x22"), array(array("\145\x72\162\157\162" => array("\x62\154\x61\x63\x6b", "\162\145\144", array("\x6d\141\x72\x71\165\145\x65"))), "\42\155\x61\162\161\165\x65\x65\42")); } 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\x61\167\x2d\x6f\x75\x74\x70\165\x74\40\55\55\x63\x6f\154\157\162\x20\55\55\151\x6e\164\x65\162\x61\x63\164\x69\x76\145\x20\55\x2d\166\145\x72\x62\x6f\x73\x65", Configuration::VERBOSITY_VERBOSE, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("\x2d\x2d\162\x61\x77\x2d\157\165\x74\160\x75\x74\40\x2d\55\x6e\157\x2d\x63\157\154\157\162\x20\55\x2d\x6e\157\55\x69\x6e\x74\x65\162\141\143\164\x69\x76\145\x20\55\x2d\x71\x75\151\x65\x74", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_DISABLED, Configuration::INTERACTIVE_MODE_DISABLED, true, false), array("\x2d\x2d\x71\x75\151\x65\x74\x20\x2d\55\x63\157\x6c\157\162\40\55\x2d\151\156\164\145\x72\141\x63\x74\x69\x76\145", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_FORCED, Configuration::INTERACTIVE_MODE_FORCED, false, false), array("\55\55\x71\165\x69\145\164\x20\x2d\55\171\157\154\x6f", Configuration::VERBOSITY_QUIET, Configuration::COLOR_MODE_AUTO, Configuration::INTERACTIVE_MODE_AUTO, false, true)); } public function testConfigurationFromInputSpecificity() { $input = $this->getBoundStringInput("\55\55\x72\141\167\x2d\157\165\164\x70\x75\164\x20\x2d\55\x63\x6f\x6c\157\162\x20\x2d\x2d\151\156\x74\x65\x72\x61\143\x74\x69\x76\145\40\x2d\55\166\145\x72\x62\157\163\145"); $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\162\x61\167\x2d\x6f\x75\164\160\165\x74\x20\151\163\x20\x69\x67\156\157\x72\x65\144\x20\x77\x69\164\150\40\151\x6e\164\x65\162\141\x63\164\151\166\x65\40\x69\156\160\165\x74"); $input = $this->getBoundStringInput("\x2d\55\166\x65\162\142\157\163\145\x20\x2d\x2d\x71\165\151\x65\x74\40\55\x2d\x63\x6f\154\157\162\40\55\x2d\156\157\x2d\143\157\154\157\162\40\55\x2d\x69\156\164\145\162\x61\143\164\x69\x76\145\x20\55\x2d\156\157\55\151\156\x74\x65\x72\x61\x63\x74\x69\166\x65"); $config = Configuration::fromInput($input); $this->assertSame(Configuration::VERBOSITY_QUIET, $config->verbosity(), "\55\x2d\161\165\x69\145\x74\x20\x74\162\x75\155\160\163\40\55\55\x76\145\x72\142\157\163\x65"); $this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode(), "\x2d\55\143\x6f\x6c\157\x72\x20\x74\x72\x75\155\160\x73\40\55\x2d\156\157\55\x63\x6f\x6c\x6f\162"); $this->assertSame(Configuration::INTERACTIVE_MODE_FORCED, $config->interactiveMode(), "\x2d\55\x69\156\x74\x65\162\141\143\164\151\166\145\40\164\162\165\155\x70\x73\x20\x2d\55\x6e\157\x2d\x69\x6e\x74\x65\x72\x61\x63\164\151\x76\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("\55\55\166\145\x72\x62\157\163\x65\x20\x30", Configuration::VERBOSITY_NORMAL), array("\55\55\x76\145\x72\x62\x6f\163\145\x3d\60", Configuration::VERBOSITY_NORMAL), array("\55\55\166\145\x72\x62\157\x73\145\40\61", Configuration::VERBOSITY_VERBOSE), array("\55\x2d\x76\145\162\142\157\163\145\75\x31", Configuration::VERBOSITY_VERBOSE), array("\x2d\x76", Configuration::VERBOSITY_VERBOSE), array("\55\x2d\x76\x65\x72\x62\157\x73\x65\40\x32", Configuration::VERBOSITY_VERY_VERBOSE), array("\x2d\55\166\145\162\142\x6f\x73\x65\75\62", Configuration::VERBOSITY_VERY_VERBOSE), array("\55\166\x76", Configuration::VERBOSITY_VERY_VERBOSE), array("\x2d\x2d\x76\145\x72\x62\x6f\163\x65\x20\63", Configuration::VERBOSITY_DEBUG), array("\55\55\166\145\162\x62\x6f\x73\145\75\63", Configuration::VERBOSITY_DEBUG), array("\x2d\x76\x76\166", Configuration::VERBOSITY_DEBUG), array("\x2d\55\x76\x65\162\142\x6f\x73\x65\x3d\55\x31", Configuration::VERBOSITY_QUIET), array("\55\x2d\x71\x75\x69\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\x66\141\151\154\x73\40\x77\x69\164\150\x20\165\156\142\157\x75\x6e\x64\40\x69\156\160\165\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\156\x72\161", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true, true), array("\55\156\x20\x2d\162\x20\x2d\x71", Configuration::VERBOSITY_QUIET, Configuration::INTERACTIVE_MODE_DISABLED, true), array("\x2d\166", Configuration::VERBOSITY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("\55\x76\x76", Configuration::VERBOSITY_VERY_VERBOSE, Configuration::INTERACTIVE_MODE_AUTO, false), array("\x2d\166\166\166", Configuration::VERBOSITY_DEBUG, Configuration::INTERACTIVE_MODE_AUTO, false)); } public function testConfigurationFromInputAliases() { $input = $this->getBoundStringInput("\x2d\55\x61\x6e\163\151\x20\55\55\151\156\164\x65\x72\x61\143\x74\151\157\x6e"); $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\x2d\141\156\x73\151\x20\55\55\x6e\157\55\x69\156\x74\x65\162\x61\x63\164\x69\x6f\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\164\x75\x72\x65\x73\x2f\145\155\160\x74\171\56\x70\x68\160"; } return new StringInput($string . "\x20\x2d\55\x63\x6f\x6e\146\x69\147\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 |
Stats
MD5 | bf34f85b5ebe6ef619adbd6e478ac49d |
Eval Count | 0 |
Decode Time | 94 ms |