diff --git a/.travis.yml b/.travis.yml index b2856901f5..90fb0a771b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,15 +20,11 @@ sudo: false matrix: include: - php: 7.2 - env: 'SCENARIO=isolation DEPENDENCIES=highest' + env: 'DEPENDENCIES=highest' - php: 7.2 - env: 'SCENARIO=isolation' - php: 7.0.11 - env: 'SCENARIO=isolation' - php: 5.6 - env: 'SCENARIO=isolation-phpunit4 DEPENDENCIES=lowest' - - php: 5.6 - env: 'SCENARIO=isolation-phpunit4 DEPENDENCIES=lowest' + env: 'SCENARIO=phpunit4 DEPENDENCIES=lowest' env: global: @@ -62,5 +58,3 @@ after_success: - git config --global user.email $GITHUB_USER_EMAIL - git config --global user.name "Drush Documentation Bot" - cd $TRAVIS_BUILD_DIR && build/scripts/publish-api-docs.sh - # Background: https://github.com/drush-ops/drush/pull/1426 - #- ${PWD}/tests/testChildren.sh diff --git a/composer.json b/composer.json index d192e72623..392c4498d6 100644 --- a/composer.json +++ b/composer.json @@ -71,13 +71,12 @@ "autoload": { "psr-4": { "Drush\\": "src/", - "Drush\\Internal\\": "internal-copy/", - "Unish\\": "tests/" + "Drush\\Internal\\": "src/internal-forks" } }, "autoload-dev": { "psr-4": { - "Drush\\": "isolation/src/" + "Unish\\": "tests/unish" }, "files": ["tests/load.environment.php"] }, @@ -109,11 +108,10 @@ "scenario": "scenarios/install", "sut": "./drush --uri=dev", "sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=${UNISH_DB_URL:-mysql://root:password@mariadb}/unish_dev -v", - "unit": "phpunit --colors=always", - "functional": "phpunit --colors=always --configuration tests", + "unit": "phpunit --colors=always --configuration tests/unit", + "functional": "phpunit --colors=always --configuration tests/functional", "post-update-cmd": [ - "create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'", - "create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'" + "create-scenario phpunit4 --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'" ] }, "extra": { diff --git a/isolation/.gitignore b/isolation/.gitignore deleted file mode 100644 index 181546de83..0000000000 --- a/isolation/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor -build diff --git a/isolation/src/FunctionUtils.php b/isolation/src/FunctionUtils.php deleted file mode 100644 index c0a9c59cc9..0000000000 --- a/isolation/src/FunctionUtils.php +++ /dev/null @@ -1,14 +0,0 @@ -sut, $methodName); - $r->setAccessible(true); - return $r->invokeArgs($this->sut, $args); - } -} diff --git a/scenarios/isolation-phpunit4/isolation b/scenarios/isolation-phpunit4/isolation deleted file mode 120000 index e526690331..0000000000 --- a/scenarios/isolation-phpunit4/isolation +++ /dev/null @@ -1 +0,0 @@ -../../isolation \ No newline at end of file diff --git a/scenarios/isolation/.gitignore b/scenarios/isolation/.gitignore deleted file mode 100644 index 22d0d82f80..0000000000 --- a/scenarios/isolation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/scenarios/isolation/composer.json b/scenarios/isolation/composer.json deleted file mode 100644 index 0e9b9f0d6a..0000000000 --- a/scenarios/isolation/composer.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "name": "drush/drush", - "description": "Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.", - "homepage": "http://www.drush.org", - "license": "GPL-2.0-or-later", - "minimum-stability": "stable", - "prefer-stable": true, - "authors": [ - { "name": "Moshe Weitzman", "email": "weitzman@tejasa.com" }, - { "name": "Owen Barton", "email": "drupal@owenbarton.com" }, - { "name": "Greg Anderson", "email": "greg.1.anderson@greenknowe.org" }, - { "name": "Jonathan AraƱa Cruz", "email": "jonhattan@faita.net" }, - { "name": "Jonathan Hedstrom", "email": "jhedstrom@gmail.com" }, - { "name": "Christopher Gervais", "email": "chris@ergonlogic.com" }, - { "name": "Dave Reid", "email": "dave@davereid.net" }, - { "name": "Damian Lee", "email": "damiankloip@googlemail.com" } - ], - "support": { - "forum": "http://drupal.stackexchange.com/questions/tagged/drush", - "irc": "irc://irc.freenode.org/drush", - "slack": "https://drupal.slack.com/messages/C62H9CWQM" - }, - "bin": [ - "drush" - ], - "repositories": { - "drupal_org": { - "type": "composer", - "url": "https://packages.drupal.org/8" - } - }, - "require": { - "php": ">=5.6.0", - "ext-dom": "*", - "consolidation/config": "^1.1.0", - "consolidation/site-alias": "^1.1.6|^2", - "psr/log": "~1.0", - "symfony/finder": "^3.4", - "symfony/var-dumper": "^3.4 || ^4.0", - "webflo/drupal-finder": "^1.1", - "webmozart/path-util": "^2.1.0" - }, - "require-dev": { - "lox/xhprof": "dev-master", - "phpunit/phpunit": "^5.5.4", - "vlucas/phpdotenv": "^2.4" - }, - "autoload": { - "psr-4": { - "Drush\\": "src/", - "Drush\\Internal\\": "internal-copy/", - "Unish\\": "tests/" - } - }, - "autoload-dev": { - "psr-4": { - "Drush\\": "isolation/src/" - }, - "files": ["tests/load.environment.php"] - }, - "config": { - "optimize-autoloader": true, - "preferred-install": "dist", - "sort-packages": true, - "process-timeout": 9600, - "platform": { - - }, - "vendor-dir": "../../vendor" - }, - "scripts": { - "cs": "phpcs", - "cbf": "phpcbf", - "lint": [ - "find includes -name '*.inc' -print0 | xargs -0 -n1 php -l", - "find src -name '*.php' -print0 | xargs -0 -n1 php -l", - "find tests -name '*.php' -print0 | xargs -0 -n1 php -l" - ], - "test": [ - "@lint", - "@unit", - "@cs", - "@functional" - ], - "api": "PATH=$HOME/bin:$PATH sami.phar --ansi update sami-config.php", - "sami-install": "mkdir -p $HOME/bin && curl --output $HOME/bin/sami.phar http://get.sensiolabs.org/sami.phar && chmod +x $HOME/bin/sami.phar", - "scenario": "scenarios/install", - "sut": "./drush --uri=dev", - "sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=${UNISH_DB_URL:-mysql://root:password@mariadb}/unish_dev -v", - "unit": "phpunit --colors=always", - "functional": "phpunit --colors=always --configuration tests", - "post-update-cmd": [ - "create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'", - "create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'" - ] - }, - "extra": { - "installer-paths": { - "sut/core": ["type:drupal-core"], - "sut/libraries/{$name}": ["type:drupal-library"], - "sut/modules/unish/{$name}": ["drupal/devel"], - "sut/themes/unish/{$name}": ["drupal/empty_theme"], - "sut/modules/contrib/{$name}": ["type:drupal-module"], - "sut/profiles/contrib/{$name}": ["type:drupal-profile"], - "sut/themes/contrib/{$name}": ["type:drupal-theme"], - "sut/drush/contrib/{$name}": ["type:drupal-drush"] - }, - "branch-alias": { - "dev-master": "9.x-dev" - } - } -} diff --git a/scenarios/isolation/internal-copy b/scenarios/isolation/internal-copy deleted file mode 120000 index b9e4cca604..0000000000 --- a/scenarios/isolation/internal-copy +++ /dev/null @@ -1 +0,0 @@ -../../internal-copy \ No newline at end of file diff --git a/scenarios/isolation/isolation b/scenarios/isolation/isolation deleted file mode 120000 index e526690331..0000000000 --- a/scenarios/isolation/isolation +++ /dev/null @@ -1 +0,0 @@ -../../isolation \ No newline at end of file diff --git a/scenarios/isolation/src b/scenarios/isolation/src deleted file mode 120000 index 929cb3dc9b..0000000000 --- a/scenarios/isolation/src +++ /dev/null @@ -1 +0,0 @@ -../../src \ No newline at end of file diff --git a/scenarios/isolation/tests b/scenarios/isolation/tests deleted file mode 120000 index c2ebfe530b..0000000000 --- a/scenarios/isolation/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests \ No newline at end of file diff --git a/scenarios/isolation-phpunit4/.gitignore b/scenarios/phpunit4/.gitignore similarity index 100% rename from scenarios/isolation-phpunit4/.gitignore rename to scenarios/phpunit4/.gitignore diff --git a/scenarios/isolation-phpunit4/composer.json b/scenarios/phpunit4/composer.json similarity index 74% rename from scenarios/isolation-phpunit4/composer.json rename to scenarios/phpunit4/composer.json index 5210a13b07..64180d0de8 100644 --- a/scenarios/isolation-phpunit4/composer.json +++ b/scenarios/phpunit4/composer.json @@ -32,29 +32,51 @@ "require": { "php": ">=5.6.0", "ext-dom": "*", + "chi-teck/drupal-code-generator": "^1.27.0", + "composer/semver": "^1.4", + "consolidation/annotated-command": "^2.9.1", "consolidation/config": "^1.1.0", - "consolidation/site-alias": "^1.1.6|^2", + "consolidation/filter-via-dot-access-data": "^0.4", + "consolidation/output-formatters": "^3.3.1", + "consolidation/robo": "^1.1.5", + "consolidation/site-alias": "^1.1.6", + "consolidation/site-process": "^0.1.13", + "grasmash/yaml-expander": "^1.1.1", + "league/container": "~2", "psr/log": "~1.0", + "psy/psysh": "~0.6", + "symfony/config": "^3.4", + "symfony/console": "^3.4", + "symfony/event-dispatcher": "^3.4", "symfony/finder": "^3.4", + "symfony/process": "^3.4", "symfony/var-dumper": "^3.4 || ^4.0", + "symfony/yaml": "^3.4", "webflo/drupal-finder": "^1.1", "webmozart/path-util": "^2.1.0" }, "require-dev": { + "composer/installers": "^1.2", + "cweagans/composer-patches": "~1.0", + "drupal/alinks": "1.0.0", + "drupal/devel": "^1.0@RC", + "drupal/empty_theme": "1.0", + "g1a/composer-test-scenarios": "^2.2.0", "lox/xhprof": "dev-master", "phpunit/phpunit": "^4.8.36", - "vlucas/phpdotenv": "^2.4" + "squizlabs/php_codesniffer": "^2.7", + "vlucas/phpdotenv": "^2.4", + "webflo/drupal-core-strict": "8.6.x-dev" }, "autoload": { "psr-4": { "Drush\\": "src/", - "Drush\\Internal\\": "internal-copy/", - "Unish\\": "tests/" + "Drush\\Internal\\": "src/internal-forks" } }, "autoload-dev": { "psr-4": { - "Drush\\": "isolation/src/" + "Unish\\": "tests/unish" }, "files": ["tests/load.environment.php"] }, @@ -87,11 +109,10 @@ "scenario": "scenarios/install", "sut": "./drush --uri=dev", "sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=${UNISH_DB_URL:-mysql://root:password@mariadb}/unish_dev -v", - "unit": "phpunit --colors=always", - "functional": "phpunit --colors=always --configuration tests", + "unit": "phpunit --colors=always --configuration tests/unit", + "functional": "phpunit --colors=always --configuration tests/functional", "post-update-cmd": [ - "create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'", - "create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'" + "create-scenario phpunit4 --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'" ] }, "extra": { diff --git a/scenarios/isolation-phpunit4/internal-copy b/scenarios/phpunit4/internal-copy similarity index 100% rename from scenarios/isolation-phpunit4/internal-copy rename to scenarios/phpunit4/internal-copy diff --git a/scenarios/isolation-phpunit4/src b/scenarios/phpunit4/src similarity index 100% rename from scenarios/isolation-phpunit4/src rename to scenarios/phpunit4/src diff --git a/scenarios/isolation-phpunit4/tests b/scenarios/phpunit4/tests similarity index 100% rename from scenarios/isolation-phpunit4/tests rename to scenarios/phpunit4/tests diff --git a/src/Runtime/Runtime.php b/src/Runtime/Runtime.php index 53720800c2..5dce8a0243 100644 --- a/src/Runtime/Runtime.php +++ b/src/Runtime/Runtime.php @@ -85,6 +85,12 @@ protected function doRun($argv) $this->preflight->aliasManager() ); + // Our termination handlers depend on classes we set up via DependencyInjection, + // so we do not want to enable it any earlier than this. + // TODO: Inject a termination handler into this class, so that we don't + // need to add these e.g. when testing. + $this->setTerminationHandlers(); + // Now that the DI container has been set up, the Application object will // have a reference to the bootstrap manager et. al., so we may use it // as needed. Tell the application to coordinate between the Bootstrap @@ -92,12 +98,6 @@ protected function doRun($argv) // one was not explicitly provided earlier in the preflight. $application->refineUriSelection($this->preflight->environment()->cwd()); - // Our termination handlers depend on classes we set up via DependencyInjection, - // so we do not want to enable it any earlier than this. - // TODO: Inject a termination handler into this class, so that we don't - // need to add these e.g. when testing. - $this->setTerminationHandlers(); - // Add global options and copy their values into Config. $application->configureGlobalOptions(); diff --git a/internal-copy/Config/Yaml/Escaper.php b/src/internal-forks/Config/Yaml/Escaper.php similarity index 100% rename from internal-copy/Config/Yaml/Escaper.php rename to src/internal-forks/Config/Yaml/Escaper.php diff --git a/internal-copy/Config/Yaml/Exception/ExceptionInterface.php b/src/internal-forks/Config/Yaml/Exception/ExceptionInterface.php similarity index 100% rename from internal-copy/Config/Yaml/Exception/ExceptionInterface.php rename to src/internal-forks/Config/Yaml/Exception/ExceptionInterface.php diff --git a/internal-copy/Config/Yaml/Exception/ParseException.php b/src/internal-forks/Config/Yaml/Exception/ParseException.php similarity index 100% rename from internal-copy/Config/Yaml/Exception/ParseException.php rename to src/internal-forks/Config/Yaml/Exception/ParseException.php diff --git a/internal-copy/Config/Yaml/Exception/RuntimeException.php b/src/internal-forks/Config/Yaml/Exception/RuntimeException.php similarity index 100% rename from internal-copy/Config/Yaml/Exception/RuntimeException.php rename to src/internal-forks/Config/Yaml/Exception/RuntimeException.php diff --git a/internal-copy/Config/Yaml/Inline.php b/src/internal-forks/Config/Yaml/Inline.php similarity index 96% rename from internal-copy/Config/Yaml/Inline.php rename to src/internal-forks/Config/Yaml/Inline.php index 1e3a498886..eec8743ca3 100644 --- a/internal-copy/Config/Yaml/Inline.php +++ b/src/internal-forks/Config/Yaml/Inline.php @@ -220,9 +220,9 @@ public static function dump($value, $flags = 0) case Escaper::requiresDoubleQuoting($value): return Escaper::escapeWithDoubleQuotes($value); case Escaper::requiresSingleQuoting($value): - case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value): - case Parser::preg_match(self::getHexRegex(), $value): - case Parser::preg_match(self::getTimestampRegex(), $value): + case Parser::pregMatch('{^[0-9]+[_0-9]*$}', $value): + case Parser::pregMatch(self::getHexRegex(), $value): + case Parser::pregMatch(self::getTimestampRegex(), $value): return Escaper::escapeWithSingleQuotes($value); default: return $value; @@ -319,10 +319,10 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i $i += strlen($output); // remove comments - if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) { + if (Parser::pregMatch('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) { $output = substr($output, 0, $match[0][1]); } - } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { + } elseif (Parser::pregMatch('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { $output = $match[1]; $i += strlen($output); } else { @@ -358,7 +358,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i */ private static function parseQuotedScalar($scalar, &$i) { - if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { + if (!Parser::pregMatch('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i))); } @@ -681,7 +681,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) // no break case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]): switch (true) { - case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar): + case Parser::pregMatch('{^[+-]?[0-9][0-9_]*$}', $scalar): $scalar = str_replace('_', '', (string) $scalar); // omitting the break / return as integers are handled in the next case // no break @@ -696,7 +696,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw); case is_numeric($scalar): - case Parser::preg_match(self::getHexRegex(), $scalar): + case Parser::pregMatch(self::getHexRegex(), $scalar): $scalar = str_replace('_', '', $scalar); return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar; @@ -705,14 +705,14 @@ private static function evaluateScalar($scalar, $flags, $references = array()) return -log(0); case '-.inf' === $scalarLower: return log(0); - case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar): - case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar): + case Parser::pregMatch('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar): + case Parser::pregMatch('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar): if (false !== strpos($scalar, ',')) { @trigger_error(sprintf('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0 on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED); } return (float) str_replace(array(',', '_'), '', $scalar); - case Parser::preg_match(self::getTimestampRegex(), $scalar): + case Parser::pregMatch(self::getTimestampRegex(), $scalar): if (Yaml::PARSE_DATETIME & $flags) { // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. return new \DateTime($scalar, new \DateTimeZone('UTC')); @@ -784,7 +784,7 @@ public static function evaluateBinaryScalar($scalar) throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', strlen($parsedBinaryData))); } - if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) { + if (!Parser::pregMatch('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) { throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData)); } diff --git a/internal-copy/Config/Yaml/LICENSE b/src/internal-forks/Config/Yaml/LICENSE similarity index 100% rename from internal-copy/Config/Yaml/LICENSE rename to src/internal-forks/Config/Yaml/LICENSE diff --git a/internal-copy/Config/Yaml/Parser.php b/src/internal-forks/Config/Yaml/Parser.php similarity index 96% rename from internal-copy/Config/Yaml/Parser.php rename to src/internal-forks/Config/Yaml/Parser.php index 92de98dced..a3376decee 100644 --- a/internal-copy/Config/Yaml/Parser.php +++ b/src/internal-forks/Config/Yaml/Parser.php @@ -166,13 +166,13 @@ private function doParse($value, $flags) } $isRef = $mergeNode = false; - if (self::preg_match('#^\-((?P\s+)(?P.+))?$#u', rtrim($this->currentLine), $values)) { + if (self::pregMatch('#^\-((?P\s+)(?P.+))?$#u', rtrim($this->currentLine), $values)) { if ($context && 'mapping' == $context) { throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine); } $context = 'sequence'; - if (isset($values['value']) && self::preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { + if (isset($values['value']) && self::pregMatch('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } @@ -191,7 +191,7 @@ private function doParse($value, $flags) ); } else { if (isset($values['leadspaces']) - && self::preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $this->trimTag($values['value']), $matches) + && self::pregMatch('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $this->trimTag($values['value']), $matches) ) { // this is a compact notation element, add to next block and parse $block = $values['value']; @@ -207,8 +207,7 @@ private function doParse($value, $flags) if ($isRef) { $this->refs[$isRef] = end($data); } - } elseif ( - self::preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) + } elseif (self::pregMatch('#^(?P'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'"))) ) { if ($context && 'sequence' == $context) { @@ -246,7 +245,7 @@ private function doParse($value, $flags) $key = (string) $key; } - if ('<<' === $key && (!isset($values['value']) || !self::preg_match('#^&(?P[^ ]+)#u', $values['value'], $refMatches))) { + if ('<<' === $key && (!isset($values['value']) || !self::pregMatch('#^&(?P[^ ]+)#u', $values['value'], $refMatches))) { $mergeNode = true; $allowOverwrite = true; if (isset($values['value'][0]) && '*' === $values['value'][0]) { @@ -303,7 +302,7 @@ private function doParse($value, $flags) $data += $parsed; // array union } } - } elseif ('<<' !== $key && isset($values['value']) && self::preg_match('#^&(?P[^ ]++) *+(?P.*)#u', $values['value'], $matches)) { + } elseif ('<<' !== $key && isset($values['value']) && self::pregMatch('#^&(?P[^ ]++) *+(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } @@ -676,7 +675,7 @@ private function parseValue($value, $flags, $context) return $this->refs[$value]; } - if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) { + if (self::pregMatch('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers)); @@ -696,7 +695,7 @@ private function parseValue($value, $flags, $context) $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null; // do not take following lines into account when the current line is a quoted single line value - if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) { + if (null !== $quotation && self::pregMatch('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) { return Inline::parse($value, $flags, $this->refs); } @@ -777,7 +776,7 @@ private function parseBlockScalar($style, $chomping = '', $indentation = 0) // determine indentation if not specified if (0 === $indentation) { - if (self::preg_match('/^ +/', $this->currentLine, $matches)) { + if (self::pregMatch('/^ +/', $this->currentLine, $matches)) { $indentation = strlen($matches[0]); } } @@ -785,10 +784,9 @@ private function parseBlockScalar($style, $chomping = '', $indentation = 0) if ($indentation > 0) { $pattern = sprintf('/^ {%d}(.*)$/', $indentation); - while ( - $notEOF && ( + while ($notEOF && ( $isCurrentLineBlank || - self::preg_match($pattern, $this->currentLine, $matches) + self::pregMatch($pattern, $this->currentLine, $matches) ) ) { if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) { @@ -1001,7 +999,7 @@ private function isStringUnIndentedCollectionItem() */ private function isBlockScalarHeader() { - return (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine); + return (bool) self::pregMatch('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine); } /** @@ -1011,13 +1009,17 @@ private function isBlockScalarHeader() * This avoids us needing to check for "false" every time PCRE is used * in the YAML engine * + * DRUSH FORK: Renamed from preg_match to pregMatch. Not what I would have + * preferred, but easier / cleaner than customizing phpcs to not flag this + * one warning. + * * @throws ParseException on a PCRE internal error * * @see preg_last_error() * * @internal */ - public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0) + public static function pregMatch($pattern, $subject, &$matches = null, $flags = 0, $offset = 0) { if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) { switch (preg_last_error()) { @@ -1063,7 +1065,7 @@ private function trimTag($value) private function getLineTag($value, $flags, $nextLineCheck = true) { - if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) { + if ('' === $value || '!' !== $value[0] || 1 !== self::pregMatch('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) { return; } diff --git a/internal-copy/Config/Yaml/README.md b/src/internal-forks/Config/Yaml/README.md similarity index 100% rename from internal-copy/Config/Yaml/README.md rename to src/internal-forks/Config/Yaml/README.md diff --git a/internal-copy/Config/Yaml/Tag/TaggedValue.php b/src/internal-forks/Config/Yaml/Tag/TaggedValue.php similarity index 100% rename from internal-copy/Config/Yaml/Tag/TaggedValue.php rename to src/internal-forks/Config/Yaml/Tag/TaggedValue.php diff --git a/internal-copy/Config/Yaml/Unescaper.php b/src/internal-forks/Config/Yaml/Unescaper.php similarity index 100% rename from internal-copy/Config/Yaml/Unescaper.php rename to src/internal-forks/Config/Yaml/Unescaper.php diff --git a/internal-copy/Config/Yaml/Yaml.php b/src/internal-forks/Config/Yaml/Yaml.php similarity index 100% rename from internal-copy/Config/Yaml/Yaml.php rename to src/internal-forks/Config/Yaml/Yaml.php diff --git a/isolation/fixtures/etc/drush/drush.yml b/tests/fixtures/etc/drush/drush.yml similarity index 100% rename from isolation/fixtures/etc/drush/drush.yml rename to tests/fixtures/etc/drush/drush.yml diff --git a/isolation/fixtures/etc/drush/drushIGNORED.yml b/tests/fixtures/etc/drush/drushIGNORED.yml similarity index 100% rename from isolation/fixtures/etc/drush/drushIGNORED.yml rename to tests/fixtures/etc/drush/drushIGNORED.yml diff --git a/isolation/fixtures/etc/drush/drushVARIANT.yml b/tests/fixtures/etc/drush/drushVARIANT.yml similarity index 100% rename from isolation/fixtures/etc/drush/drushVARIANT.yml rename to tests/fixtures/etc/drush/drushVARIANT.yml diff --git a/isolation/fixtures/home/.drush/drush.yml b/tests/fixtures/home/.drush/drush.yml similarity index 100% rename from isolation/fixtures/home/.drush/drush.yml rename to tests/fixtures/home/.drush/drush.yml diff --git a/isolation/fixtures/sitealiases/legacy/cc.aliases.drushrc.php b/tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php similarity index 100% rename from isolation/fixtures/sitealiases/legacy/cc.aliases.drushrc.php rename to tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php diff --git a/isolation/fixtures/sitealiases/legacy/one.alias.drushrc.php b/tests/fixtures/sitealiases/legacy/one.alias.drushrc.php similarity index 100% rename from isolation/fixtures/sitealiases/legacy/one.alias.drushrc.php rename to tests/fixtures/sitealiases/legacy/one.alias.drushrc.php diff --git a/isolation/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php b/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php similarity index 94% rename from isolation/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php rename to tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php index 38cc9f1c3c..145ec405b0 100644 --- a/isolation/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php +++ b/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php @@ -15,7 +15,7 @@ $aliases['outlandish-josh.test'] = array( 'uri' => 'test-outlandish-josh.pantheonsite.io', 'db-url' => 'mysql://pantheon:pw@dbserver.test.site-id.drush.in:11621/pantheon', - 'db-allows-remote' => TRUE, + 'db-allows-remote' => true, 'remote-host' => 'appserver.test.site-id.drush.in', 'remote-user' => 'test.site-id', 'ssh-options' => '-p 2222 -o "AddressFamily inet"', @@ -27,7 +27,7 @@ $aliases['outlandish-josh.live'] = array( 'uri' => 'www.outlandishjosh.com', 'db-url' => 'mysql://pantheon:pw@dbserver.live.site-id.drush.in:10516/pantheon', - 'db-allows-remote' => TRUE, + 'db-allows-remote' => true, 'remote-host' => 'appserver.live.site-id.drush.in', 'remote-user' => 'live.site-id', 'ssh-options' => '-p 2222 -o "AddressFamily inet"', @@ -39,7 +39,7 @@ $aliases['outlandish-josh.dev'] = array( 'uri' => 'dev-outlandish-josh.pantheonsite.io', 'db-url' => 'mysql://pantheon:pw@dbserver.dev.site-id.drush.in:21086/pantheon', - 'db-allows-remote' => TRUE, + 'db-allows-remote' => true, 'remote-host' => 'appserver.dev.site-id.drush.in', 'remote-user' => 'dev.site-id', 'ssh-options' => '-p 2222 -o "AddressFamily inet"', diff --git a/isolation/fixtures/sitealiases/legacy/server.aliases.drushrc.php b/tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php similarity index 100% rename from isolation/fixtures/sitealiases/legacy/server.aliases.drushrc.php rename to tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php diff --git a/isolation/fixtures/sitealiases/single/simple.site.yml b/tests/fixtures/sitealiases/single/simple.site.yml similarity index 100% rename from isolation/fixtures/sitealiases/single/simple.site.yml rename to tests/fixtures/sitealiases/single/simple.site.yml diff --git a/isolation/fixtures/sitealiases/single/single.site.yml b/tests/fixtures/sitealiases/single/single.site.yml similarity index 100% rename from isolation/fixtures/sitealiases/single/single.site.yml rename to tests/fixtures/sitealiases/single/single.site.yml diff --git a/isolation/fixtures/sites/d8/drush/drush.yml b/tests/fixtures/sites/d8/drush/drush.yml similarity index 100% rename from isolation/fixtures/sites/d8/drush/drush.yml rename to tests/fixtures/sites/d8/drush/drush.yml diff --git a/isolation/fixtures/sites/d8/drush/sites/self.site.yml b/tests/fixtures/sites/d8/drush/sites/self.site.yml similarity index 100% rename from isolation/fixtures/sites/d8/drush/sites/self.site.yml rename to tests/fixtures/sites/d8/drush/sites/self.site.yml diff --git a/isolation/fixtures/sites/d8/sites/mymultisite/settings.php b/tests/fixtures/sites/d8/sites/mymultisite/settings.php similarity index 100% rename from isolation/fixtures/sites/d8/sites/mymultisite/settings.php rename to tests/fixtures/sites/d8/sites/mymultisite/settings.php diff --git a/isolation/fixtures/usr/share/drush/commands/.gitkeep b/tests/fixtures/usr/share/drush/commands/.gitkeep similarity index 100% rename from isolation/fixtures/usr/share/drush/commands/.gitkeep rename to tests/fixtures/usr/share/drush/commands/.gitkeep diff --git a/tests/AnnotatedCommandTest.php b/tests/functional/AnnotatedCommandTest.php similarity index 100% rename from tests/AnnotatedCommandTest.php rename to tests/functional/AnnotatedCommandTest.php diff --git a/tests/ArgsRemapperTest.php b/tests/functional/ArgsRemapperTest.php similarity index 100% rename from tests/ArgsRemapperTest.php rename to tests/functional/ArgsRemapperTest.php diff --git a/tests/BackendTest.php b/tests/functional/BackendTest.php similarity index 100% rename from tests/BackendTest.php rename to tests/functional/BackendTest.php diff --git a/tests/BatchTest.php b/tests/functional/BatchTest.php similarity index 100% rename from tests/BatchTest.php rename to tests/functional/BatchTest.php diff --git a/tests/COVERAGE.txt b/tests/functional/COVERAGE.txt similarity index 100% rename from tests/COVERAGE.txt rename to tests/functional/COVERAGE.txt diff --git a/tests/CacheCommandTest.php b/tests/functional/CacheCommandTest.php similarity index 100% rename from tests/CacheCommandTest.php rename to tests/functional/CacheCommandTest.php diff --git a/tests/CommandInfoAlterTest.php b/tests/functional/CommandInfoAlterTest.php similarity index 100% rename from tests/CommandInfoAlterTest.php rename to tests/functional/CommandInfoAlterTest.php diff --git a/tests/Commands/TestFixtureCommands.php b/tests/functional/Commands/TestFixtureCommands.php similarity index 96% rename from tests/Commands/TestFixtureCommands.php rename to tests/functional/Commands/TestFixtureCommands.php index 3bcf437587..b6fd97d043 100644 --- a/tests/Commands/TestFixtureCommands.php +++ b/tests/functional/Commands/TestFixtureCommands.php @@ -56,11 +56,11 @@ public function drushUnitBatch() // Reduce php memory/time limits to test backend respawn. // TODO. - $operations[] = ['\Unish\resources\UnitBatchOperations::operate', []]; + $operations[] = ['\Unish\Batch\UnitBatchOperations::operate', []]; $batch = [ 'operations' => $operations, - 'finished' => '\Unish\resources\UnitBatchOperations::finish', + 'finished' => '\Unish\Batch\UnitBatchOperations::finish', ]; \batch_set($batch); $result = \drush_backend_batch_process(); diff --git a/tests/ConfigPullTest.php b/tests/functional/ConfigPullTest.php similarity index 100% rename from tests/ConfigPullTest.php rename to tests/functional/ConfigPullTest.php diff --git a/tests/ConfigTest.php b/tests/functional/ConfigTest.php similarity index 100% rename from tests/ConfigTest.php rename to tests/functional/ConfigTest.php diff --git a/tests/ContainerTest.php b/tests/functional/ContainerTest.php similarity index 100% rename from tests/ContainerTest.php rename to tests/functional/ContainerTest.php diff --git a/tests/CoreTest.php b/tests/functional/CoreTest.php similarity index 100% rename from tests/CoreTest.php rename to tests/functional/CoreTest.php diff --git a/tests/ExpandWildcardTablesUnitTest.php b/tests/functional/ExpandWildcardTablesUnitTest.php similarity index 100% rename from tests/ExpandWildcardTablesUnitTest.php rename to tests/functional/ExpandWildcardTablesUnitTest.php diff --git a/tests/ImageTest.php b/tests/functional/ImageTest.php similarity index 100% rename from tests/ImageTest.php rename to tests/functional/ImageTest.php diff --git a/tests/InitCommandTest.php b/tests/functional/InitCommandTest.php similarity index 100% rename from tests/InitCommandTest.php rename to tests/functional/InitCommandTest.php diff --git a/tests/LanguageAddTest.php b/tests/functional/LanguageAddTest.php similarity index 100% rename from tests/LanguageAddTest.php rename to tests/functional/LanguageAddTest.php diff --git a/tests/LocaleTest.php b/tests/functional/LocaleTest.php similarity index 100% rename from tests/LocaleTest.php rename to tests/functional/LocaleTest.php diff --git a/tests/PmEnDisUnListInfoTest.php b/tests/functional/PmEnDisUnListInfoTest.php similarity index 100% rename from tests/PmEnDisUnListInfoTest.php rename to tests/functional/PmEnDisUnListInfoTest.php diff --git a/tests/PmEnLocaleImportTest.php b/tests/functional/PmEnLocaleImportTest.php similarity index 100% rename from tests/PmEnLocaleImportTest.php rename to tests/functional/PmEnLocaleImportTest.php diff --git a/tests/QueueTest.php b/tests/functional/QueueTest.php similarity index 100% rename from tests/QueueTest.php rename to tests/functional/QueueTest.php diff --git a/tests/RoleTest.php b/tests/functional/RoleTest.php similarity index 100% rename from tests/RoleTest.php rename to tests/functional/RoleTest.php diff --git a/tests/RsyncTest.php b/tests/functional/RsyncTest.php similarity index 100% rename from tests/RsyncTest.php rename to tests/functional/RsyncTest.php diff --git a/tests/SecurityUpdatesTest.php b/tests/functional/SecurityUpdatesTest.php similarity index 100% rename from tests/SecurityUpdatesTest.php rename to tests/functional/SecurityUpdatesTest.php diff --git a/tests/SiteAliasConvertTest.php b/tests/functional/SiteAliasConvertTest.php similarity index 100% rename from tests/SiteAliasConvertTest.php rename to tests/functional/SiteAliasConvertTest.php diff --git a/tests/SiteSetTest.php b/tests/functional/SiteSetTest.php similarity index 100% rename from tests/SiteSetTest.php rename to tests/functional/SiteSetTest.php diff --git a/tests/SiteSshTest.php b/tests/functional/SiteSshTest.php similarity index 100% rename from tests/SiteSshTest.php rename to tests/functional/SiteSshTest.php diff --git a/tests/SqlConnectCreateTest.php b/tests/functional/SqlConnectCreateTest.php similarity index 100% rename from tests/SqlConnectCreateTest.php rename to tests/functional/SqlConnectCreateTest.php diff --git a/tests/SqlDumpTest.php b/tests/functional/SqlDumpTest.php similarity index 100% rename from tests/SqlDumpTest.php rename to tests/functional/SqlDumpTest.php diff --git a/tests/SqlSyncTest.php b/tests/functional/SqlSyncTest.php similarity index 100% rename from tests/SqlSyncTest.php rename to tests/functional/SqlSyncTest.php diff --git a/tests/UpdateDBTest.php b/tests/functional/UpdateDBTest.php similarity index 100% rename from tests/UpdateDBTest.php rename to tests/functional/UpdateDBTest.php diff --git a/tests/UserTest.php b/tests/functional/UserTest.php similarity index 100% rename from tests/UserTest.php rename to tests/functional/UserTest.php diff --git a/tests/WatchdogTest.php b/tests/functional/WatchdogTest.php similarity index 100% rename from tests/WatchdogTest.php rename to tests/functional/WatchdogTest.php diff --git a/tests/XhUnitTest.php b/tests/functional/XhUnitTest.php similarity index 100% rename from tests/XhUnitTest.php rename to tests/functional/XhUnitTest.php diff --git a/tests/phpunit.xml.dist b/tests/functional/phpunit.xml.dist similarity index 100% rename from tests/phpunit.xml.dist rename to tests/functional/phpunit.xml.dist diff --git a/tests/resources/alias-fixtures/drupalvm.aliases.drushrc.php b/tests/functional/resources/alias-fixtures/drupalvm.aliases.drushrc.php similarity index 100% rename from tests/resources/alias-fixtures/drupalvm.aliases.drushrc.php rename to tests/functional/resources/alias-fixtures/drupalvm.aliases.drushrc.php diff --git a/tests/resources/alias-fixtures/example.site.yml b/tests/functional/resources/alias-fixtures/example.site.yml similarity index 100% rename from tests/resources/alias-fixtures/example.site.yml rename to tests/functional/resources/alias-fixtures/example.site.yml diff --git a/tests/resources/create_unish_articles.php b/tests/functional/resources/create_unish_articles.php similarity index 100% rename from tests/resources/create_unish_articles.php rename to tests/functional/resources/create_unish_articles.php diff --git a/tests/resources/devel.nl.po b/tests/functional/resources/devel.nl.po similarity index 100% rename from tests/resources/devel.nl.po rename to tests/functional/resources/devel.nl.po diff --git a/tests/resources/devel.post_update.php b/tests/functional/resources/devel.post_update.php similarity index 100% rename from tests/resources/devel.post_update.php rename to tests/functional/resources/devel.post_update.php diff --git a/tests/resources/global-includes/Commands/FoobarCommands.php b/tests/functional/resources/global-includes/Commands/FoobarCommands.php similarity index 100% rename from tests/resources/global-includes/Commands/FoobarCommands.php rename to tests/functional/resources/global-includes/Commands/FoobarCommands.php diff --git a/tests/resources/global-includes/FoobazCommands.php b/tests/functional/resources/global-includes/FoobazCommands.php similarity index 100% rename from tests/resources/global-includes/FoobazCommands.php rename to tests/functional/resources/global-includes/FoobazCommands.php diff --git a/tests/resources/global-includes/Generators/FooGenerator.php b/tests/functional/resources/global-includes/Generators/FooGenerator.php similarity index 100% rename from tests/resources/global-includes/Generators/FooGenerator.php rename to tests/functional/resources/global-includes/Generators/FooGenerator.php diff --git a/tests/resources/global-includes/Generators/foo.twig b/tests/functional/resources/global-includes/Generators/foo.twig similarity index 100% rename from tests/resources/global-includes/Generators/foo.twig rename to tests/functional/resources/global-includes/Generators/foo.twig diff --git a/tests/resources/modules/d8/woot/composer.json b/tests/functional/resources/modules/d8/woot/composer.json similarity index 100% rename from tests/resources/modules/d8/woot/composer.json rename to tests/functional/resources/modules/d8/woot/composer.json diff --git a/tests/resources/modules/d8/woot/drush.services.yml b/tests/functional/resources/modules/d8/woot/drush.services.yml similarity index 100% rename from tests/resources/modules/d8/woot/drush.services.yml rename to tests/functional/resources/modules/d8/woot/drush.services.yml diff --git a/tests/resources/modules/d8/woot/src/Commands/AnnotatedGreetCommand.php b/tests/functional/resources/modules/d8/woot/src/Commands/AnnotatedGreetCommand.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Commands/AnnotatedGreetCommand.php rename to tests/functional/resources/modules/d8/woot/src/Commands/AnnotatedGreetCommand.php diff --git a/tests/resources/modules/d8/woot/src/Commands/GreetCommand.php b/tests/functional/resources/modules/d8/woot/src/Commands/GreetCommand.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Commands/GreetCommand.php rename to tests/functional/resources/modules/d8/woot/src/Commands/GreetCommand.php diff --git a/tests/resources/modules/d8/woot/src/Commands/WootCommands.php b/tests/functional/resources/modules/d8/woot/src/Commands/WootCommands.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Commands/WootCommands.php rename to tests/functional/resources/modules/d8/woot/src/Commands/WootCommands.php diff --git a/tests/resources/modules/d8/woot/src/Controller/WootController.php b/tests/functional/resources/modules/d8/woot/src/Controller/WootController.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Controller/WootController.php rename to tests/functional/resources/modules/d8/woot/src/Controller/WootController.php diff --git a/tests/resources/modules/d8/woot/src/DependingService.php b/tests/functional/resources/modules/d8/woot/src/DependingService.php similarity index 100% rename from tests/resources/modules/d8/woot/src/DependingService.php rename to tests/functional/resources/modules/d8/woot/src/DependingService.php diff --git a/tests/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php b/tests/functional/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php similarity index 100% rename from tests/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php rename to tests/functional/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php diff --git a/tests/resources/modules/d8/woot/src/Generators/ExampleGenerator.php b/tests/functional/resources/modules/d8/woot/src/Generators/ExampleGenerator.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Generators/ExampleGenerator.php rename to tests/functional/resources/modules/d8/woot/src/Generators/ExampleGenerator.php diff --git a/tests/resources/modules/d8/woot/src/Generators/example-generator.twig b/tests/functional/resources/modules/d8/woot/src/Generators/example-generator.twig similarity index 100% rename from tests/resources/modules/d8/woot/src/Generators/example-generator.twig rename to tests/functional/resources/modules/d8/woot/src/Generators/example-generator.twig diff --git a/tests/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php b/tests/functional/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php similarity index 100% rename from tests/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php rename to tests/functional/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php diff --git a/tests/resources/modules/d8/woot/src/WootCommandInfoAlterer.php b/tests/functional/resources/modules/d8/woot/src/WootCommandInfoAlterer.php similarity index 100% rename from tests/resources/modules/d8/woot/src/WootCommandInfoAlterer.php rename to tests/functional/resources/modules/d8/woot/src/WootCommandInfoAlterer.php diff --git a/tests/resources/modules/d8/woot/src/WootManager.php b/tests/functional/resources/modules/d8/woot/src/WootManager.php similarity index 100% rename from tests/resources/modules/d8/woot/src/WootManager.php rename to tests/functional/resources/modules/d8/woot/src/WootManager.php diff --git a/tests/resources/modules/d8/woot/woot.info.yml b/tests/functional/resources/modules/d8/woot/woot.info.yml similarity index 100% rename from tests/resources/modules/d8/woot/woot.info.yml rename to tests/functional/resources/modules/d8/woot/woot.info.yml diff --git a/tests/resources/modules/d8/woot/woot.install b/tests/functional/resources/modules/d8/woot/woot.install similarity index 100% rename from tests/resources/modules/d8/woot/woot.install rename to tests/functional/resources/modules/d8/woot/woot.install diff --git a/tests/resources/modules/d8/woot/woot.module b/tests/functional/resources/modules/d8/woot/woot.module similarity index 100% rename from tests/resources/modules/d8/woot/woot.module rename to tests/functional/resources/modules/d8/woot/woot.module diff --git a/tests/resources/modules/d8/woot/woot.post_update.php b/tests/functional/resources/modules/d8/woot/woot.post_update.php similarity index 100% rename from tests/resources/modules/d8/woot/woot.post_update.php rename to tests/functional/resources/modules/d8/woot/woot.post_update.php diff --git a/tests/resources/modules/d8/woot/woot.routing.yml b/tests/functional/resources/modules/d8/woot/woot.routing.yml similarity index 100% rename from tests/resources/modules/d8/woot/woot.routing.yml rename to tests/functional/resources/modules/d8/woot/woot.routing.yml diff --git a/tests/resources/modules/d8/woot/woot.services.yml b/tests/functional/resources/modules/d8/woot/woot.services.yml similarity index 100% rename from tests/resources/modules/d8/woot/woot.services.yml rename to tests/functional/resources/modules/d8/woot/woot.services.yml diff --git a/tests/resources/queue_script.php b/tests/functional/resources/queue_script.php similarity index 100% rename from tests/resources/queue_script.php rename to tests/functional/resources/queue_script.php diff --git a/tests/resources/requeue_script.php b/tests/functional/resources/requeue_script.php similarity index 100% rename from tests/resources/requeue_script.php rename to tests/functional/resources/requeue_script.php diff --git a/tests/resources/testDispatchUsingAlias_script.php b/tests/functional/resources/testDispatchUsingAlias_script.php similarity index 100% rename from tests/resources/testDispatchUsingAlias_script.php rename to tests/functional/resources/testDispatchUsingAlias_script.php diff --git a/tests/resources/updatedb_script.php b/tests/functional/resources/updatedb_script.php similarity index 100% rename from tests/resources/updatedb_script.php rename to tests/functional/resources/updatedb_script.php diff --git a/tests/resources/user_fields-D8.php b/tests/functional/resources/user_fields-D8.php similarity index 100% rename from tests/resources/user_fields-D8.php rename to tests/functional/resources/user_fields-D8.php diff --git a/tests/testChildren.sh b/tests/testChildren.sh deleted file mode 100755 index 372ce72e37..0000000000 --- a/tests/testChildren.sh +++ /dev/null @@ -1,16 +0,0 @@ -# See https://github.com/drush-ops/drush/pull/1426 for background information. -# -# $AUTH_TOKEN is provided via a secure Travis environment variable. -# Secure environment variables are not set for pull requests that -# originated from another repository, so skip child tests if $AUTH_TOKEN -# is empty. -if [ -n "$AUTH_TOKEN" ] -then - # After a travis build succeeds, run tests from any child repository defined in $TEST_CHILDREN - for CHILD in $TEST_CHILDREN - do - BUILD_NUM=$(curl -s "https://api.travis-ci.org/repos/$CHILD/builds" | grep -o '^\[{"id":[0-9]*,' | grep -o '[0-9]' | tr -d '\n') - echo "Restarting build $BUILD_NUM for $CHILD" - curl -X POST https://api.travis-ci.org/builds/$BUILD_NUM/restart --header "Authorization: token "$AUTH_TOKEN - done -fi diff --git a/tests/resources/UnitBatchOperations.php b/tests/unish/Batch/UnitBatchOperations.php similarity index 93% rename from tests/resources/UnitBatchOperations.php rename to tests/unish/Batch/UnitBatchOperations.php index e80abf3644..c923b598cf 100644 --- a/tests/resources/UnitBatchOperations.php +++ b/tests/unish/Batch/UnitBatchOperations.php @@ -1,6 +1,6 @@ simplifyOutput($this->getOutput()); - } - /** - * Returns a simplified version of the error output to facilitate testing. + * Idle timeouts for commands. * - * @return string - * A simplified version of the error output that has things like full - * paths and superfluous whitespace removed from it. + * Reset to $defaultIdleTimeout after executing a command. + * + * @var int */ - protected function getSimplifiedErrorOutput() - { - return $this->simplifyOutput($this->getErrorOutput()); - } + protected $idleTimeout = 15; /** - * Remove things like full paths and extra whitespace from the given string. - * - * @param string $output - * The output string to simplify. + * Accessor for the last output, non-trimmed. * * @return string - * The simplified output. + * Raw output as text. + * + * @access public */ - protected function simplifyOutput($output) - { - // We do not care if Drush inserts a -t or not in the string. Depends on whether there is a tty. - $output = preg_replace('# -t #', ' ', $output); - // Remove double spaces from output to help protect test from false negatives if spacing changes subtly - $output = preg_replace('# *#', ' ', $output); - // Remove leading and trailing spaces. - $output = preg_replace('#^ *#m', '', $output); - $output = preg_replace('# *$#m', '', $output); - // Remove multiple blank lines - $output = preg_replace("#\n\n\n*#m", "\n\n", $output); - // Remove stderr marker. @see realTimeOutput during siteProcess. - $output = preg_replace('#ERR >#', '', $output); - // Remove verbose info for rsync. - $output = preg_replace('# -akzv --stats --progress #', ' -akz ', $output); - // Debug flags may be added to command strings if we are in debug mode. Take those out so that tests in phpunit --debug mode work - $output = preg_replace('# --debug #', ' ', $output); - $output = preg_replace('# --verbose #', ' ', $output); - // Get rid of any full paths in the output - $output = str_replace(__DIR__, '__DIR__', $output); - $output = str_replace(self::getSandbox(), '__SANDBOX__', $output); - $output = str_replace(self::getSut(), '__SUT__', $output); - - return $output; - } - - /** - * Accessor for the last output, trimmed. - * - * @return string - * Trimmed output as text. - * - * @access public - */ - public function getOutput() - { - return trim($this->getOutputRaw()); - } - - /** - * Accessor for the last output, non-trimmed. - * - * @return string - * Raw output as text. - * - * @access public - */ public function getOutputRaw() { return $this->process ? $this->process->getOutput() : ''; } - /** - * Accessor for the last output, rtrimmed and split on newlines. - * - * @return array - * Output as array of lines. - * - * @access public - */ - public function getOutputAsList() - { - return array_map('rtrim', explode("\n", $this->getOutput())); - } - - /** - * Accessor for the last stderr output, trimmed. - * - * @return string - * Trimmed stderr as text. - * - * @access public - */ - public function getErrorOutput() - { - return trim($this->getErrorOutputRaw()); - } - - /** - * Accessor for the last stderr output, non-trimmed. - * - * @return string - * Raw stderr as text. - * - * @access public - */ + /** + * Accessor for the last stderr output, non-trimmed. + * + * @return string + * Raw stderr as text. + * + * @access public + */ public function getErrorOutputRaw() { return $this->process ? $this->process->getErrorOutput() : ''; } - /** - * Accessor for the last stderr output, rtrimmed and split on newlines. - * - * @return array - * Stderr as array of lines. - * - * @access public - */ - public function getErrorOutputAsList() - { - return array_map('rtrim', explode("\n", $this->getErrorOutput())); - } - - /** - * Accessor for the last output, decoded from json. - * - * @param string $key - * Optionally return only a top level element from the json object. - * - * @return object - * Decoded object. - */ - public function getOutputFromJSON($key = null) - { - $json = json_decode($this->getOutput()); - if (isset($key)) { - $json = $json->{$key}; // http://stackoverflow.com/questions/2925044/hyphens-in-keys-of-object - } - return $json; - } - - /** - * Actually runs the command. - * - * @param string $command - * The actual command line to run. - * @param integer $expected_return - * The return code to expect - * @param sting cd - * The directory to run the command in. - * @param array $env - * Extra environment variables. - * @param string $input - * A string representing the STDIN that is piped to the command. - * @return integer - * Exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS. - */ + /** + * Actually runs the command. + * + * @param string $command + * The actual command line to run. + * @param integer $expected_return + * The return code to expect + * @param sting cd + * The directory to run the command in. + * @param array $env + * Extra environment variables. + * @param string $input + * A string representing the STDIN that is piped to the command. + * @return integer + * Exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS. + */ public function execute($command, $expected_return = self::EXIT_SUCCESS, $cd = null, $env = null, $input = null) { $this->tick(); @@ -289,29 +160,29 @@ public function buildProcessMessage(Process $process) return $message; } - /** - * Invoke drush in via execute(). - * - * @param command - * A defined drush command such as 'cron', 'status' or any of the available ones such as 'drush pm'. - * @param args - * Command arguments. - * @param $options - * An associative array containing options. - * @param $site_specification - * A site alias or site specification. Include the '@' at start of a site alias. - * @param $cd - * A directory to change into before executing. - * @param $expected_return - * The expected exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS. - * @param $suffix - * Any code to append to the command. For example, redirection like 2>&1. - * @param array $env - * Not used. Environment variables to pass along to the subprocess. - * @todo Look into inheritEnvironmentVariables() - available since Process 3.1. See https://github.com/symfony/symfony/pull/19053/files. - * @return integer - * An exit code. - */ + /** + * Invoke drush in via execute(). + * + * @param command + * A defined drush command such as 'cron', 'status' or any of the available ones such as 'drush pm'. + * @param args + * Command arguments. + * @param $options + * An associative array containing options. + * @param $site_specification + * A site alias or site specification. Include the '@' at start of a site alias. + * @param $cd + * A directory to change into before executing. + * @param $expected_return + * The expected exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS. + * @param $suffix + * Any code to append to the command. For example, redirection like 2>&1. + * @param array $env + * Not used. Environment variables to pass along to the subprocess. + * @todo Look into inheritEnvironmentVariables() - available since Process 3.1. See https://github.com/symfony/symfony/pull/19053/files. + * @return integer + * An exit code. + */ public function drush($command, array $args = [], array $options = [], $site_specification = null, $cd = null, $expected_return = self::EXIT_SUCCESS, $suffix = null, $env = []) { // cd is added for the benefit of siteSshTest which tests a strict command. @@ -397,9 +268,9 @@ public function drush($command, array $args = [], array $options = [], $site_spe return $return; } - /** - * A slightly less functional copy of drush_backend_parse_output(). - */ + /** + * A slightly less functional copy of drush_backend_parse_output(). + */ public function parseBackendOutput($string) { $regex = sprintf(self::getBackendOutputDelimiter(), '(.*)'); @@ -420,20 +291,20 @@ public function parseBackendOutput($string) return $string; } - /** - * Ensure that an expected log message appears in the Drush log. - * - * $this->drush('command', array(), array('backend' => NULL)); - * $parsed = $this->parse_backend_output($this->getOutput()); - * $this->assertLogHasMessage($parsed['log'], "Expected message", 'debug') - * - * @param $log Parsed log entries from backend invoke - * @param $message The expected message that must be contained in - * some log entry's 'message' field. Substrings will match. - * @param $logType The type of log message to look for; all other - * types are ignored. If FALSE (the default), then all log types - * will be searched. - */ + /** + * Ensure that an expected log message appears in the Drush log. + * + * $this->drush('command', array(), array('backend' => NULL)); + * $parsed = $this->parse_backend_output($this->getOutput()); + * $this->assertLogHasMessage($parsed['log'], "Expected message", 'debug') + * + * @param $log Parsed log entries from backend invoke + * @param $message The expected message that must be contained in + * some log entry's 'message' field. Substrings will match. + * @param $logType The type of log message to look for; all other + * types are ignored. If FALSE (the default), then all log types + * will be searched. + */ public function assertLogHasMessage($log, $message, $logType = false) { foreach ($log as $entry) { diff --git a/tests/TestModuleHelperTrait.php b/tests/unish/TestModuleHelperTrait.php similarity index 100% rename from tests/TestModuleHelperTrait.php rename to tests/unish/TestModuleHelperTrait.php diff --git a/tests/UnishProcessFailedException.php b/tests/unish/UnishProcessFailedException.php similarity index 100% rename from tests/UnishProcessFailedException.php rename to tests/unish/UnishProcessFailedException.php diff --git a/tests/UnishTestCase.php b/tests/unish/UnishTestCase.php similarity index 98% rename from tests/UnishTestCase.php rename to tests/unish/UnishTestCase.php index d347cc020a..505e91738a 100644 --- a/tests/UnishTestCase.php +++ b/tests/unish/UnishTestCase.php @@ -8,6 +8,10 @@ abstract class UnishTestCase extends TestCase { + // Unix exit codes. + const EXIT_SUCCESS = 0; + const EXIT_ERROR = 1; + const UNISH_EXITCODE_USER_ABORT = 75; // Same as DRUSH_EXITCODE_USER_ABORT /** * A list of Drupal sites that have been recently installed. They key is the @@ -36,7 +40,7 @@ public function __construct($name = null, array $data = [], $dataName = '') // require_once __DIR__ . '/unish.inc'; // list($unish_tmp, $unish_sandbox, $unish_drush_dir) = \unishGetPaths(); - $unish_sandbox = Path::join(dirname(__DIR__), 'sandbox'); + $unish_sandbox = Path::join(dirname(dirname(__DIR__)), 'sandbox'); self::mkdir($unish_sandbox); $unish_cache = Path::join($unish_sandbox, 'cache'); @@ -107,7 +111,7 @@ public static function getSut() public static function getComposerRoot() { - return dirname(__DIR__); + return dirname(dirname(__DIR__)); } /** diff --git a/isolation/src/FSUtils.php b/tests/unish/Utils/FSUtils.php similarity index 87% rename from isolation/src/FSUtils.php rename to tests/unish/Utils/FSUtils.php index 33a244b069..4cef991cdd 100644 --- a/isolation/src/FSUtils.php +++ b/tests/unish/Utils/FSUtils.php @@ -1,10 +1,10 @@ setAccessible(true); + return $r->invokeArgs($object, $args); + } +} diff --git a/tests/unish/Utils/OutputUtilsTrait.php b/tests/unish/Utils/OutputUtilsTrait.php new file mode 100644 index 0000000000..a739992297 --- /dev/null +++ b/tests/unish/Utils/OutputUtilsTrait.php @@ -0,0 +1,157 @@ +simplifyOutput($this->getOutput()); + } + + /** + * Returns a simplified version of the error output to facilitate testing. + * + * @return string + * A simplified version of the error output that has things like full + * paths and superfluous whitespace removed from it. + */ + protected function getSimplifiedErrorOutput() + { + return $this->simplifyOutput($this->getErrorOutput()); + } + + /** + * Remove things like full paths and extra whitespace from the given string. + * + * @param string $output + * The output string to simplify. + * + * @return string + * The simplified output. + */ + protected function simplifyOutput($output) + { + // We do not care if Drush inserts a -t or not in the string. Depends on whether there is a tty. + $output = preg_replace('# -t #', ' ', $output); + // Remove multiple blank lines + $output = preg_replace("#\n\n\n*#m", "\n\n", $output); + // Remove double spaces from output to help protect test from false negatives if spacing changes subtly + $output = preg_replace('# *#', ' ', $output); + // Remove leading and trailing spaces. + $output = preg_replace('#^[ \t]*#m', '', $output); + $output = preg_replace('#[ \t]*$#m', '', $output); + // Remove verbose info for rsync. + $output = preg_replace('# -akzv --stats --progress #', ' -akz ', $output); + // Debug flags may be added to command strings if we are in debug mode. Take those out so that tests in phpunit --debug mode work + $output = preg_replace('# --debug #', ' ', $output); + $output = preg_replace('# --verbose #', ' ', $output); + // Get rid of any full paths in the output + $output = preg_replace('#' . dirname(dirname(__DIR__)) . '/[^/]*#', '__DIR__', $output); + $output = str_replace(self::getSandbox(), '__SANDBOX__', $output); + $output = str_replace(self::getSut(), '__SUT__', $output); + + return $output; + } + + /** + * Accessor for the last output, trimmed. + * + * @return string + * Trimmed output as text. + * + * @access public + */ + public function getOutput() + { + return trim($this->getOutputRaw()); + } + + /** + * Accessor for the last stderr output, trimmed. + * + * @return string + * Trimmed stderr as text. + * + * @access public + */ + public function getErrorOutput() + { + return trim($this->getErrorOutputRaw()); + } + + /** + * Accessor for the last output, rtrimmed and split on newlines. + * + * @return array + * Output as array of lines. + * + * @access public + */ + public function getOutputAsList() + { + return array_map('rtrim', explode("\n", $this->getOutput())); + } + + /** + * Accessor for the last stderr output, rtrimmed and split on newlines. + * + * @return array + * Stderr as array of lines. + * + * @access public + */ + public function getErrorOutputAsList() + { + return array_map('rtrim', explode("\n", $this->getErrorOutput())); + } + + /** + * Accessor for the last output, decoded from json. + * + * @param string $key + * Optionally return only a top level element from the json object. + * + * @return object + * Decoded object. + */ + public function getOutputFromJSON($key = null) + { + $json = json_decode($this->getOutput()); + if (isset($key)) { + $json = $json->{$key}; // http://stackoverflow.com/questions/2925044/hyphens-in-keys-of-object + } + return $json; + } + + /** + * Accessor for the last output, non-trimmed. + * + * @return string + * Raw output as text. + * + * @access public + */ + public abstract function getOutputRaw(); + + /** + * Accessor for the last stderr output, non-trimmed. + * + * @return string + * Raw stderr as text. + * + * @access public + */ + public abstract function getErrorOutputRaw(); +} diff --git a/isolation/tests/ArgsPreprocessorTest.php b/tests/unit/ArgsPreprocessorTest.php similarity index 99% rename from isolation/tests/ArgsPreprocessorTest.php rename to tests/unit/ArgsPreprocessorTest.php index 1b16e49e90..c12e8331bb 100644 --- a/isolation/tests/ArgsPreprocessorTest.php +++ b/tests/unit/ArgsPreprocessorTest.php @@ -5,8 +5,7 @@ class ArgsPreprocessorTest extends TestCase { - - use \Drush\FixtureFactory; + use \Unish\Utils\Fixtures; /** * @dataProvider argTestValues @@ -19,8 +18,9 @@ public function testArgPreprocessor( $aliasPath, $commandPath, $isLocal, - $unprocessedArgs) - { + $unprocessedArgs + ) { + $argProcessor = new ArgsPreprocessor(); $preflightArgs = new PreflightArgs(); diff --git a/isolation/tests/ConfigLocatorTest.php b/tests/unit/ConfigLocatorTest.php similarity index 95% rename from isolation/tests/ConfigLocatorTest.php rename to tests/unit/ConfigLocatorTest.php index ddf092e803..f0e4d79be4 100644 --- a/isolation/tests/ConfigLocatorTest.php +++ b/tests/unit/ConfigLocatorTest.php @@ -8,12 +8,12 @@ */ class ConfigLocatorTest extends TestCase { - use \Drush\FixtureFactory; + use \Unish\Utils\Fixtures; /** * Test a config locator initialized only with data from the fixture's environment */ - function testOnlyEnvironmentData() + public function testOnlyEnvironmentData() { $configLocator = new ConfigLocator('TEST_'); $configLocator->addEnvironment($this->environment()); @@ -24,7 +24,7 @@ function testOnlyEnvironmentData() /** * Test a comprehensive load of all default fixture data. */ - function testLoadAll() + public function testLoadAll() { $configLocator = $this->createConfigLocator(); @@ -51,7 +51,7 @@ function testLoadAll() * context, "global" means anything that is not site-local, including the * configuration file in the user's home directory, etc. */ - function testLocalMode() + public function testLocalMode() { $configLocator = $this->createConfigLocator(true); @@ -70,7 +70,7 @@ function testLocalMode() $this->assertEquals('A site-specific setting', $config->get('test.site')); } - function testAliasPaths() + public function testAliasPaths() { $configLocator = $this->createConfigLocator(); $aliasPaths = $configLocator->getSiteAliasPaths(['/home/user/aliases'], $this->environment()); diff --git a/isolation/tests/EnvironmentTest.php b/tests/unit/EnvironmentTest.php similarity index 84% rename from isolation/tests/EnvironmentTest.php rename to tests/unit/EnvironmentTest.php index 7056927edc..591d435e90 100644 --- a/isolation/tests/EnvironmentTest.php +++ b/tests/unit/EnvironmentTest.php @@ -9,22 +9,22 @@ */ class EnvironmentTest extends TestCase { - use \Drush\FixtureFactory; + use \Unish\Utils\Fixtures; - function testExportConfigData() + public function testExportConfigData() { $data = $this->environment()->exportConfigData(); $this->assertEquals($this->homeDir(), $data['env']['cwd']); } - function testDocsPath() + public function testDocsPath() { $docsPath = $this->environment()->docsPath(); $this->assertInternalType('string', $docsPath, 'A docsPath was found'); $this->assertFileExists("$docsPath/README.md", 'README.md exists at docsPath'); } - function testDrushConfigFileFixturesExist() + public function testDrushConfigFileFixturesExist() { $fixturesDir = $this->fixturesDir(); $this->assertFileExists("$fixturesDir/etc/drush/drush.yml", '/etc/drush/drush.yml exists'); diff --git a/isolation/tests/LegacyAliasConverterTest.php b/tests/unit/LegacyAliasConverterTest.php similarity index 90% rename from isolation/tests/LegacyAliasConverterTest.php rename to tests/unit/LegacyAliasConverterTest.php index 5c35164b7d..e120de84d2 100644 --- a/isolation/tests/LegacyAliasConverterTest.php +++ b/tests/unit/LegacyAliasConverterTest.php @@ -6,12 +6,13 @@ class LegacyAliasConverterTest extends TestCase { - use \Drush\FixtureFactory; - use \Drush\FunctionUtils; - use \Drush\FSUtils; + use \Unish\Utils\Fixtures; + use \Unish\Utils\FunctionUtils; + use \Unish\Utils\FSUtils; protected $discovery; protected $target; + protected $sut; protected function setUp() { @@ -31,7 +32,7 @@ protected function tearDown() protected function tempdir() { - $tempfile = tempnam(sys_get_temp_dir(),''); + $tempfile = tempnam(sys_get_temp_dir(), ''); if (file_exists($tempfile)) { unlink($tempfile); } @@ -48,7 +49,7 @@ public function testWriteOne() $testContents = 'test: This is the initial file contents'; // Write the data once, and confirm it was written. - $this->callProtected('writeOne', [$testPath, $testContents]); + $this->callProtected($this->sut, 'writeOne', [$testPath, $testContents]); $this->assertStringEqualsFile($testPath, $testContents); // Check to see that the checksum file was written, and that @@ -59,7 +60,7 @@ public function testWriteOne() $overwriteContents = 'test: Overwrite the file contents'; // Write the data again, and confirm it was changed. - $this->callProtected('writeOne', [$testPath, $overwriteContents]); + $this->callProtected($this->sut, 'writeOne', [$testPath, $overwriteContents]); $this->assertStringEqualsFile($testPath, $overwriteContents); $simulatedEditedContents = 'test: My simulated edit'; @@ -69,27 +70,27 @@ public function testWriteOne() // Write the yet data again; this time, confirm that // nothing changed, because the checksum does not match. - $this->callProtected('writeOne', [$testPath, $ignoredContents]); + $this->callProtected($this->sut, 'writeOne', [$testPath, $ignoredContents]); $this->assertStringEqualsFile($testPath, $simulatedEditedContents); // Write yet again, this time removing the target so that it will // be writable again. unlink($testPath); - $this->callProtected('writeOne', [$testPath, $overwriteContents]); + $this->callProtected($this->sut, 'writeOne', [$testPath, $overwriteContents]); $this->assertStringEqualsFile($testPath, $overwriteContents); $this->assertFileExists($checksumPath); // Remove the checksum file, and confirm that the target cannot // be overwritten unlink($checksumPath); - $this->callProtected('writeOne', [$testPath, $ignoredContents]); + $this->callProtected($this->sut, 'writeOne', [$testPath, $ignoredContents]); $this->assertStringEqualsFile($testPath, $overwriteContents); } public function testConvertAll() { $legacyFiles = $this->discovery->findAllLegacyAliasFiles(); - $result = $this->callProtected('convertAll', [$legacyFiles]); + $result = $this->callProtected($this->sut, 'convertAll', [$legacyFiles]); ksort($result); $this->assertEquals('cc.site.yml,isp.site.yml,live.site.yml,nitrogen.site.yml,one.site.yml,outlandish-josh.site.yml,pantheon.site.yml,server.site.yml,update.site.yml', implode(',', array_keys($result))); //$this->assertEquals('', var_export($result, true)); @@ -106,8 +107,8 @@ public function testWriteAll() ], ]; - $this->callProtected('cacheConvertedFilePath', ['b.aliases.drushrc.php', 'b.yml']); - $this->callProtected('writeAll', [$convertedFileFixtures]); + $this->callProtected($this->sut, 'cacheConvertedFilePath', ['b.aliases.drushrc.php', 'b.yml']); + $this->callProtected($this->sut, 'writeAll', [$convertedFileFixtures]); $this->assertFileExists($this->target . '/a.yml'); $this->assertFileExists($this->target . '/.checksums/a.md5'); $this->assertFileExists($this->target . '/b.yml'); @@ -127,7 +128,7 @@ public function testWriteAll() public function testConvertLegacyFile($source, $expected) { $legacyFile = $this->fixturesDir() . '/sitealiases/legacy/' . $source; - $result = $this->callProtected('convertLegacyFile', [$legacyFile]); + $result = $this->callProtected($this->sut, 'convertLegacyFile', [$legacyFile]); $this->assertEquals($expected, $result); } diff --git a/isolation/tests/SiteAliasFileDiscoveryTest.php b/tests/unit/SiteAliasFileDiscoveryTest.php similarity index 94% rename from isolation/tests/SiteAliasFileDiscoveryTest.php rename to tests/unit/SiteAliasFileDiscoveryTest.php index 170857aec0..44c9a932a1 100644 --- a/isolation/tests/SiteAliasFileDiscoveryTest.php +++ b/tests/unit/SiteAliasFileDiscoveryTest.php @@ -6,10 +6,10 @@ class SiteAliasFileDiscoveryTest extends TestCase { - use \Drush\FixtureFactory; - use \Drush\FunctionUtils; + use \Unish\Utils\Fixtures; + use \Unish\Utils\FunctionUtils; - function setUp() + public function setUp() { $this->sut = new SiteAliasFileDiscovery(); } @@ -59,8 +59,7 @@ protected function simplifyToBasenamesWithLocation($result) $result = array_map( function ($item) { return basename(dirname($item)) . '/' . basename($item); - } - , + }, $result ); diff --git a/isolation/tests/SiteAliasFileLoaderTest.php b/tests/unit/SiteAliasFileLoaderTest.php similarity index 89% rename from isolation/tests/SiteAliasFileLoaderTest.php rename to tests/unit/SiteAliasFileLoaderTest.php index 6d147d4a2b..f44aa6a877 100644 --- a/isolation/tests/SiteAliasFileLoaderTest.php +++ b/tests/unit/SiteAliasFileLoaderTest.php @@ -8,10 +8,12 @@ class SiteAliasFileLoaderTest extends TestCase { - use \Drush\FixtureFactory; - use \Drush\FunctionUtils; + use \Unish\Utils\Fixtures; + use \Unish\Utils\FunctionUtils; - function setUp() + protected $sut; + + public function setUp() { $this->sut = new SiteAliasFileLoader(); @@ -30,27 +32,27 @@ public function testLoadSingleAliasFile() // Look for a simple alias with no environments defined $name = new SiteAliasName('simple'); - $result = $this->callProtected('loadSingleAliasFile', [$name]); + $result = $this->callProtected($this->sut, 'loadSingleAliasFile', [$name]); $this->assertEquals(AliasRecord::class, get_class($result)); $this->assertEquals('/path/to/simple', $result->get('root')); // Look for a single alias without an environment specified. $name = new SiteAliasName('single'); - $result = $this->callProtected('loadSingleAliasFile', [$name]); + $result = $this->callProtected($this->sut, 'loadSingleAliasFile', [$name]); $this->assertTrue($result instanceof AliasRecord); $this->assertEquals('/path/to/single', $result->get('root')); $this->assertEquals('bar', $result->get('foo')); // Same test, but with environment explicitly requested. $name = new SiteAliasName('single', 'alternate'); - $result = $this->callProtected('loadSingleAliasFile', [$name]); + $result = $this->callProtected($this->sut, 'loadSingleAliasFile', [$name]); $this->assertTrue($result instanceof AliasRecord); $this->assertEquals('/alternate/path/to/single', $result->get('root')); $this->assertEquals('bar', $result->get('foo')); // Try to fetch an alias that does not exist. $name = new SiteAliasName('missing'); - $result = $this->callProtected('loadSingleAliasFile', [$name]); + $result = $this->callProtected($this->sut, 'loadSingleAliasFile', [$name]); $this->assertFalse($result); } diff --git a/isolation/tests/SiteAliasNameTest.php b/tests/unit/SiteAliasNameTest.php similarity index 100% rename from isolation/tests/SiteAliasNameTest.php rename to tests/unit/SiteAliasNameTest.php diff --git a/isolation/tests/SiteSpecParserTest.php b/tests/unit/SiteSpecParserTest.php similarity index 98% rename from isolation/tests/SiteSpecParserTest.php rename to tests/unit/SiteSpecParserTest.php index 794b63e922..16f725b10b 100644 --- a/isolation/tests/SiteSpecParserTest.php +++ b/tests/unit/SiteSpecParserTest.php @@ -5,15 +5,16 @@ class SiteSpecParserTest extends TestCase { - use \Drush\FixtureFactory; + use \Unish\Utils\Fixtures; /** * @dataProvider parserTestValues */ public function testSiteSpecParser( $spec, - $expected) - { + $expected + ) { + $root = $this->siteDir(); $fixtureSite = '/' . basename($root); $parser = new SiteSpecParser(); @@ -84,7 +85,7 @@ public static function invalidSiteSpecs() [ 'user@server/path/to/drupal#uri!' ], [ 'user@server/path/to/drupal##uri' ], [ 'user#server/path/to/drupal#uri' ], - ]; + ]; } public static function parserTestValues() diff --git a/phpunit.xml.dist b/tests/unit/phpunit.xml.dist similarity index 80% rename from phpunit.xml.dist rename to tests/unit/phpunit.xml.dist index 22b0d43591..670ca54dc4 100644 --- a/phpunit.xml.dist +++ b/tests/unit/phpunit.xml.dist @@ -2,19 +2,19 @@ This is the phpunit configuration file for the unit tests. For the functional tests configuration, see: - tests/phpunit.xml.dist + tests/functional/phpunit.xml.dist This configuration usually does not need to be customized. You may copy and rename to phpunit.xml to do so if you wish, though. --> - isolation/tests + .