diff --git a/composer.lock b/composer.lock index ff5eb4325..3e3c58e87 100644 --- a/composer.lock +++ b/composer.lock @@ -4,6 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], + "hash": "2cc79ef8656892057aab618f27ff73bc", "content-hash": "d6cf16c66af4f7d019c9c0551cc66c8b", "packages": [ { @@ -66,7 +67,7 @@ "validation", "versioning" ], - "time": "2016-08-30T16:08:34+00:00" + "time": "2016-08-30 16:08:34" }, { "name": "consolidation/annotated-command", @@ -118,7 +119,7 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2017-01-27T01:59:21+00:00" + "time": "2017-01-27 01:59:21" }, { "name": "consolidation/log", @@ -165,7 +166,7 @@ } ], "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", - "time": "2016-03-23T23:46:42+00:00" + "time": "2016-03-23 23:46:42" }, { "name": "consolidation/output-formatters", @@ -214,7 +215,7 @@ } ], "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2017-01-21T06:26:40+00:00" + "time": "2017-01-21 06:26:40" }, { "name": "consolidation/robo", @@ -291,7 +292,7 @@ } ], "description": "Modern task runner", - "time": "2016-11-24T02:07:48+00:00" + "time": "2016-11-24 02:07:48" }, { "name": "container-interop/container-interop", @@ -318,7 +319,7 @@ "MIT" ], "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", - "time": "2014-12-30T15:22:37+00:00" + "time": "2014-12-30 15:22:37" }, { "name": "dnoegel/php-xdg-base-dir", @@ -351,7 +352,7 @@ "MIT" ], "description": "implementation of xdg base directory specification for php", - "time": "2014-10-24T07:27:01+00:00" + "time": "2014-10-24 07:27:01" }, { "name": "guzzlehttp/guzzle", @@ -413,7 +414,7 @@ "rest", "web service" ], - "time": "2016-10-08T15:01:37+00:00" + "time": "2016-10-08 15:01:37" }, { "name": "guzzlehttp/promises", @@ -464,7 +465,7 @@ "keywords": [ "promise" ], - "time": "2016-12-20T10:07:11+00:00" + "time": "2016-12-20 10:07:11" }, { "name": "guzzlehttp/psr7", @@ -522,7 +523,7 @@ "stream", "uri" ], - "time": "2016-06-24T23:00:38+00:00" + "time": "2016-06-24 23:00:38" }, { "name": "jakub-onderka/php-console-color", @@ -565,7 +566,7 @@ "homepage": "http://www.acci.cz" } ], - "time": "2014-04-08T15:00:19+00:00" + "time": "2014-04-08 15:00:19" }, { "name": "jakub-onderka/php-console-highlighter", @@ -609,7 +610,7 @@ "homepage": "http://www.acci.cz/" } ], - "time": "2015-04-20T18:58:01+00:00" + "time": "2015-04-20 18:58:01" }, { "name": "league/container", @@ -673,7 +674,7 @@ "provider", "service" ], - "time": "2016-03-17T11:07:59+00:00" + "time": "2016-03-17 11:07:59" }, { "name": "nikic/php-parser", @@ -724,7 +725,7 @@ "parser", "php" ], - "time": "2016-12-06T11:30:35+00:00" + "time": "2016-12-06 11:30:35" }, { "name": "phpdocumentor/reflection-common", @@ -778,7 +779,7 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2015-12-27 11:43:31" }, { "name": "phpdocumentor/reflection-docblock", @@ -823,7 +824,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30T07:12:33+00:00" + "time": "2016-09-30 07:12:33" }, { "name": "phpdocumentor/type-resolver", @@ -870,7 +871,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-11-25T06:54:22+00:00" + "time": "2016-11-25 06:54:22" }, { "name": "psr/http-message", @@ -920,7 +921,7 @@ "request", "response" ], - "time": "2016-08-06T14:39:51+00:00" + "time": "2016-08-06 14:39:51" }, { "name": "psr/log", @@ -967,7 +968,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2016-10-10 12:19:37" }, { "name": "psy/psysh", @@ -1040,7 +1041,7 @@ "interactive", "shell" ], - "time": "2017-01-15T17:54:13+00:00" + "time": "2017-01-15 17:54:13" }, { "name": "symfony/console", @@ -1101,7 +1102,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-01-08T20:43:03+00:00" + "time": "2017-01-08 20:43:03" }, { "name": "symfony/debug", @@ -1158,7 +1159,7 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-07-30T07:22:48+00:00" + "time": "2016-07-30 07:22:48" }, { "name": "symfony/event-dispatcher", @@ -1218,7 +1219,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "symfony/filesystem", @@ -1267,7 +1268,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-01-08T20:47:33+00:00" + "time": "2017-01-08 20:47:33" }, { "name": "symfony/finder", @@ -1316,7 +1317,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "symfony/polyfill-mbstring", @@ -1375,7 +1376,7 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2016-11-14 01:06:16" }, { "name": "symfony/process", @@ -1424,7 +1425,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "symfony/var-dumper", @@ -1487,7 +1488,7 @@ "debug", "dump" ], - "time": "2017-01-03T08:53:57+00:00" + "time": "2017-01-03 08:53:57" }, { "name": "symfony/yaml", @@ -1542,7 +1543,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-01-03T13:51:32+00:00" + "time": "2017-01-03 13:51:32" }, { "name": "webmozart/assert", @@ -1592,7 +1593,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2016-11-23 20:04:58" } ], "packages-dev": [ @@ -1649,7 +1650,7 @@ "assertion", "validation" ], - "time": "2017-01-24T15:14:39+00:00" + "time": "2017-01-24 15:14:39" }, { "name": "behat/behat", @@ -1731,7 +1732,7 @@ "symfony", "testing" ], - "time": "2016-12-25T13:43:52+00:00" + "time": "2016-12-25 13:43:52" }, { "name": "behat/gherkin", @@ -1790,7 +1791,7 @@ "gherkin", "parser" ], - "time": "2016-10-30T11:50:56+00:00" + "time": "2016-10-30 11:50:56" }, { "name": "behat/transliterator", @@ -1830,7 +1831,7 @@ "slug", "transliterator" ], - "time": "2015-09-28T16:26:35+00:00" + "time": "2015-09-28 16:26:35" }, { "name": "doctrine/instantiator", @@ -1884,7 +1885,7 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2015-06-14 21:17:01" }, { "name": "guzzle/guzzle", @@ -1977,7 +1978,7 @@ "web service" ], "abandoned": "guzzlehttp/guzzle", - "time": "2014-01-28T22:29:15+00:00" + "time": "2014-01-28 22:29:15" }, { "name": "php-vcr/php-vcr", @@ -2027,7 +2028,7 @@ } ], "description": "Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.", - "time": "2016-10-26T19:12:48+00:00" + "time": "2016-10-26 19:12:48" }, { "name": "phpspec/prophecy", @@ -2090,7 +2091,7 @@ "spy", "stub" ], - "time": "2016-11-21T14:58:47+00:00" + "time": "2016-11-21 14:58:47" }, { "name": "phpunit/php-code-coverage", @@ -2152,7 +2153,7 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "time": "2015-10-06 15:47:00" }, { "name": "phpunit/php-file-iterator", @@ -2199,7 +2200,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-text-template", @@ -2240,7 +2241,7 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", @@ -2284,7 +2285,7 @@ "keywords": [ "timer" ], - "time": "2016-05-12T18:03:57+00:00" + "time": "2016-05-12 18:03:57" }, { "name": "phpunit/php-token-stream", @@ -2333,7 +2334,7 @@ "keywords": [ "tokenizer" ], - "time": "2016-11-15T14:06:22+00:00" + "time": "2016-11-15 14:06:22" }, { "name": "phpunit/phpcov", @@ -2385,7 +2386,7 @@ ], "description": "CLI frontend for PHP_CodeCoverage", "homepage": "https://github.com/sebastianbergmann/phpcov", - "time": "2015-10-05T09:24:23+00:00" + "time": "2015-10-05 09:24:23" }, { "name": "phpunit/phpunit", @@ -2457,7 +2458,7 @@ "testing", "xunit" ], - "time": "2017-01-26T16:15:36+00:00" + "time": "2017-01-26 16:15:36" }, { "name": "phpunit/phpunit-mock-objects", @@ -2513,7 +2514,7 @@ "mock", "xunit" ], - "time": "2015-10-02T06:51:40+00:00" + "time": "2015-10-02 06:51:40" }, { "name": "rmccue/requests", @@ -2562,7 +2563,7 @@ "iri", "sockets" ], - "time": "2016-10-13T00:11:37+00:00" + "time": "2016-10-13 00:11:37" }, { "name": "satooshi/php-coveralls", @@ -2620,20 +2621,20 @@ "github", "test" ], - "time": "2016-01-20T17:35:46+00:00" + "time": "2016-01-20 17:35:46" }, { "name": "sebastian/comparator", - "version": "1.2.2", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { @@ -2684,7 +2685,7 @@ "compare", "equality" ], - "time": "2016-11-19T09:18:40+00:00" + "time": "2017-01-29 09:50:25" }, { "name": "sebastian/diff", @@ -2736,7 +2737,7 @@ "keywords": [ "diff" ], - "time": "2015-12-08T07:14:41+00:00" + "time": "2015-12-08 07:14:41" }, { "name": "sebastian/environment", @@ -2786,7 +2787,7 @@ "environment", "hhvm" ], - "time": "2016-08-18T05:49:44+00:00" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", @@ -2853,7 +2854,7 @@ "export", "exporter" ], - "time": "2016-06-17T09:04:28+00:00" + "time": "2016-06-17 09:04:28" }, { "name": "sebastian/finder-facade", @@ -2892,7 +2893,7 @@ ], "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", "homepage": "https://github.com/sebastianbergmann/finder-facade", - "time": "2016-02-17T07:02:23+00:00" + "time": "2016-02-17 07:02:23" }, { "name": "sebastian/global-state", @@ -2943,7 +2944,7 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2015-10-12 03:26:01" }, { "name": "sebastian/phpcpd", @@ -2994,7 +2995,7 @@ ], "description": "Copy/Paste Detector (CPD) for PHP code.", "homepage": "https://github.com/sebastianbergmann/phpcpd", - "time": "2016-04-17T19:32:49+00:00" + "time": "2016-04-17 19:32:49" }, { "name": "sebastian/recursion-context", @@ -3047,7 +3048,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11T19:50:13+00:00" + "time": "2015-11-11 19:50:13" }, { "name": "sebastian/version", @@ -3082,7 +3083,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" + "time": "2015-06-21 13:59:46" }, { "name": "squizlabs/php_codesniffer", @@ -3160,7 +3161,7 @@ "phpcs", "standards" ], - "time": "2016-11-30T04:02:31+00:00" + "time": "2016-11-30 04:02:31" }, { "name": "symfony/class-loader", @@ -3216,7 +3217,7 @@ ], "description": "Symfony ClassLoader Component", "homepage": "https://symfony.com", - "time": "2017-01-10T14:14:38+00:00" + "time": "2017-01-10 14:14:38" }, { "name": "symfony/config", @@ -3272,7 +3273,7 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "symfony/dependency-injection", @@ -3335,7 +3336,7 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2017-01-10T14:21:25+00:00" + "time": "2017-01-10 14:21:25" }, { "name": "symfony/stopwatch", @@ -3384,7 +3385,7 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "symfony/translation", @@ -3448,7 +3449,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-01-02 20:32:22" }, { "name": "theseer/fdomdocument", @@ -3488,7 +3489,7 @@ ], "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", "homepage": "https://github.com/theseer/fDOMDocument", - "time": "2015-05-27T22:58:02+00:00" + "time": "2015-05-27 22:58:02" } ], "aliases": [], diff --git a/config/constants.yml b/config/constants.yml index 40b05510c..95a4d25fd 100644 --- a/config/constants.yml +++ b/config/constants.yml @@ -7,39 +7,39 @@ --- # App -TERMINUS_VERSION: '1.0.0' +TERMINUS_VERSION: '1.0.0' # Connectivity -TERMINUS_HOST: 'terminus.pantheon.io' -TERMINUS_PORT: 443 -TERMINUS_PROTOCOL: 'https' -TERMINUS_SSH_HOST: null +TERMINUS_HOST: 'terminus.pantheon.io' +TERMINUS_PORT: 443 +TERMINUS_PROTOCOL: 'https' +TERMINUS_SSH_HOST: null # User Prompts TERMINUS_DASHBOARD_HOST: 'dashboard.pantheon.io' TERMINUS_DASHBOARD_PROTOCOL: 'https' # Localization -TERMINUS_DATE_FORMAT: 'Y-m-d H:i:s' -TERMINUS_TIME_ZONE: 'UTC' +TERMINUS_DATE_FORMAT: 'Y-m-d H:i:s' +TERMINUS_TIME_ZONE: 'UTC' # File Storage -TERMINUS_CACHE_DIR: '[[ TERMINUS_USER_HOME ]]/.terminus/cache' -TERMINUS_PLUGINS_DIR: '[[ TERMINUS_USER_HOME ]]/.terminus/plugins' -TERMINUS_TOKENS_DIR: '[[ TERMINUS_CACHE_DIR ]]/tokens' -TERMINUS_ASSETS_DIR: '[[ TERMINUS_ROOT ]]/assets' -TERMINUS_TEMPLATES_DIR: '[[ TERMINUS_ROOT ]]/templates' +TERMINUS_CACHE_DIR: '[[ TERMINUS_USER_HOME ]]/.terminus/cache' +TERMINUS_PLUGINS_DIR: '[[ TERMINUS_USER_HOME ]]/.terminus/plugins' +TERMINUS_COMMAND_CACHE_DIR: '[[ TERMINUS_CACHE_DIR ]]/commands' +TERMINUS_TOKENS_DIR: '[[ TERMINUS_CACHE_DIR ]]/tokens' +TERMINUS_ASSETS_DIR: '[[ TERMINUS_ROOT ]]/assets' # Helpers -TERMINUS_USER: null -TERMINUS_SITE: null -TERMINUS_ENV: null -TERMINUS_ORG: null +TERMINUS_USER: null +TERMINUS_SITE: null +TERMINUS_ENV: null +TERMINUS_ORG: null # Testing -TERMINUS_TEST_MODE: false -TERMINUS_VCR_CASSETTE: null -TERMINUS_VCR_MODE: null +TERMINUS_TEST_MODE: false +TERMINUS_VCR_CASSETTE: null +TERMINUS_VCR_MODE: null # Set by Terminus - DO NOT USE # Terminus diff --git a/src/Collections/Sites.php b/src/Collections/Sites.php index a3ac3ce43..a9f2656db 100644 --- a/src/Collections/Sites.php +++ b/src/Collections/Sites.php @@ -72,6 +72,9 @@ public function fetch(array $arg_options = []) if (!$options['team_only']) { $memberships = $this->getUser()->getOrgMemberships()->fetch()->all(); + if (is_null($memberships)) { + $memberships = []; + } if (!is_null($org_id = $options['org_id']) && ($org_id != 'all')) { $memberships = array_filter($memberships, function ($membership) use ($org_id) { return $membership->id == $org_id; diff --git a/src/Commands/Self/ClearCacheCommand.php b/src/Commands/Self/ClearCacheCommand.php index e2c6ff8a7..696195faa 100644 --- a/src/Commands/Self/ClearCacheCommand.php +++ b/src/Commands/Self/ClearCacheCommand.php @@ -5,13 +5,17 @@ use League\Container\ContainerAwareInterface; use League\Container\ContainerAwareTrait; use Pantheon\Terminus\Commands\TerminusCommand; +use Pantheon\Terminus\Helpers\LocalMachineHelper; +use Robo\Common\ConfigAwareTrait; +use Robo\Contract\ConfigAwareInterface; /** * Class ClearCacheCommand * @package Pantheon\Terminus\Commands\Self */ -class ClearCacheCommand extends TerminusCommand implements ContainerAwareInterface +class ClearCacheCommand extends TerminusCommand implements ConfigAwareInterface, ContainerAwareInterface { + use ConfigAwareTrait; use ContainerAwareTrait; /** @@ -24,6 +28,14 @@ class ClearCacheCommand extends TerminusCommand implements ContainerAwareInterfa */ public function clearCache() { + $local_machine = $this->getContainer()->get(LocalMachineHelper::class); + $fs = $local_machine->getFilesystem(); + $finder = $local_machine->getFinder(); + + $finder->files()->in($this->getConfig()->get('command_cache_dir')); + foreach ($finder as $file) { + $fs->remove($file); + } $this->log()->notice('The local Terminus cache has been cleared.'); } } diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index 4d4ac067f..f8063251d 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -6,6 +6,7 @@ use Robo\Common\ConfigAwareTrait; use Robo\Contract\ConfigAwareInterface; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; /** @@ -66,6 +67,17 @@ public function getFilesystem() return new Filesystem(); } + /** + * Returns a finder object + * + * @return Finder + */ + public function getFinder() + { + return new Finder(); + } + + /** /** * Opens the given URL in a browser on the local machine. * diff --git a/src/Terminus.php b/src/Terminus.php index d605a1249..94aeafcfb 100644 --- a/src/Terminus.php +++ b/src/Terminus.php @@ -294,7 +294,7 @@ private function configureContainer() ->invokeMethod('setSites', ['sites']); // Install our command cache into the command factory - $commandCacheDir = $this->getConfig()->get('cache_dir') . '/commands'; + $commandCacheDir = $this->getConfig()->get('command_cache_dir'); $commandCacheDataStore = new FileStore($commandCacheDir); $factory = $container->get('commandFactory'); diff --git a/tests/features/multidev-list.feature b/tests/features/multidev-list.feature index 9f98909cf..499d9f5f0 100644 --- a/tests/features/multidev-list.feature +++ b/tests/features/multidev-list.feature @@ -16,8 +16,8 @@ Feature: Listing a site's environments @vcr site-info.yml Scenario: Listing all multidev environments belonging to a site When I run "terminus multidev:list [[test_site_name]]" - Then I should get: "---------- --------------------- -------------------------------------- --------------- --------- --------------" - And I should get: "Name Created Domain OnServer Dev? Locked? Initialized?" - And I should get: "---------- --------------------- -------------------------------------- --------------- --------- --------------" - And I should get: "multidev 2016-08-16 22:09:01 multidev-behat-tests.pantheonsite.io true false true" - And I should get: "---------- --------------------- -------------------------------------- --------------- --------- --------------" + Then I should get: "---------- ------------------ -------------------------------------- --------------- --------- --------------" + And I should get: "Name Created Domain OnServer Dev? Locked? Initialized?" + And I should get: "---------- ------------------ -------------------------------------- --------------- --------- --------------" + And I should get: "multidev 2016-08-16 15:09 multidev-behat-tests.pantheonsite.io true false true" + And I should get: "---------- ------------------ -------------------------------------- --------------- --------- --------------" diff --git a/tests/features/site-list.feature b/tests/features/site-list.feature index e5d6cc810..908eb07ea 100644 --- a/tests/features/site-list.feature +++ b/tests/features/site-list.feature @@ -10,35 +10,35 @@ Feature: Listing sites Scenario: Listing a user's sites when they haven't any When I run "terminus site:list" Then I should get: "You have no sites." - And I should get: "------ ---- --------------- ----------- ------- --------- -------------" - And I should get: "Name ID Service Level Framework Owner Created Memberships" - And I should get: "------ ---- --------------- ----------- ------- --------- -------------" + And I should get: "------ ---- --------------- ----------- ------- --------- ------------- ------------" + And I should get: "Name ID Service Level Framework Owner Created Memberships Is Frozen?" + And I should get: "------ ---- --------------- ----------- ------- --------- ------------- ------------" @vcr site-list.yml Scenario: Listing a user's sites Given a site named "[[test_site_name]]" When I run "terminus site:list --owner=me" - Then I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" - And I should get: "Name ID Service Level Framework Owner Created Memberships" - And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" - And I should get: "[[test_site_name]] 11111111-1111-1111-1111-111111111111 free wordpress 11111111-1111-1111-1111-111111111111 2016-08-16 22:09:01 11111111-1111-1111-1111-111111111111: Team" - And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" + Then I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" + And I should get: "Name ID Service Level Framework Owner Created Memberships Is Frozen?" + And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" + And I should get: "behat-tests 11111111-1111-1111-1111-111111111111 free wordpress 11111111-1111-1111-1111-111111111111 2016-08-16 15:09 11111111-1111-1111-1111-111111111111: Team false" + And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" @vcr site-list.yml Scenario: Filter sites list by name Given a site named "[[test_site_name]]" When I run "terminus site:list --name=[[test_site_name]]" - Then I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" - And I should get: "Name ID Service Level Framework Owner Created Memberships" - And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" - And I should get: "[[test_site_name]] 11111111-1111-1111-1111-111111111111 free wordpress 11111111-1111-1111-1111-111111111111 2016-08-16 22:09:01 11111111-1111-1111-1111-111111111111: Team" - And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- --------------------- --------------------------------------------" + Then I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" + And I should get: "Name ID Service Level Framework Owner Created Memberships Is Frozen?" + And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" + And I should get: "behat-tests 11111111-1111-1111-1111-111111111111 free wordpress 11111111-1111-1111-1111-111111111111 2016-08-16 15:09 11111111-1111-1111-1111-111111111111: Team false" + And I should get: "------------- -------------------------------------- --------------- ----------- -------------------------------------- ------------------ -------------------------------------------- ------------" @vcr site-list.yml Scenario: Filter sites list by name, excluding the test site Given a site named "[[test_site_name]]" When I run "terminus site:list --name=missing" Then I should get: "You have no sites." - And I should get: "------ ---- --------------- ----------- ------- --------- -------------" - And I should get: "Name ID Service Level Framework Owner Created Memberships" - And I should get: "------ ---- --------------- ----------- ------- --------- -------------" + And I should get: "------ ---- --------------- ----------- ------- --------- ------------- ------------" + And I should get: "Name ID Service Level Framework Owner Created Memberships Is Frozen?" + And I should get: "------ ---- --------------- ----------- ------- --------- ------------- ------------" diff --git a/tests/unit_tests/Commands/Self/ClearCacheCommandTest.php b/tests/unit_tests/Commands/Self/ClearCacheCommandTest.php index 58f075963..062506f49 100644 --- a/tests/unit_tests/Commands/Self/ClearCacheCommandTest.php +++ b/tests/unit_tests/Commands/Self/ClearCacheCommandTest.php @@ -2,8 +2,15 @@ namespace Pantheon\Terminus\UnitTests\Commands\Self; +use League\Container\Container; use Pantheon\Terminus\Commands\Self\ClearCacheCommand; +use Pantheon\Terminus\Config\TerminusConfig; +use Pantheon\Terminus\Helpers\LocalMachineHelper; use Pantheon\Terminus\UnitTests\Commands\CommandTestCase; +use phpDocumentor\Reflection\File; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; +use Symfony\Component\Finder\Tests\Iterator\Iterator; /** * Class ClearCacheCommandTest @@ -12,11 +19,93 @@ */ class ClearCacheCommandTest extends CommandTestCase { + /** + * @var TerminusConfig + */ + protected $config; + /** + * @var Filesystem + */ + protected $filesystem; + /** + * @var Finder + */ + protected $finder; + + /** + * @inheritdoc + */ + public function setUp() + { + parent::setUp(); + + $container = $this->getMockBuilder(Container::class) + ->disableOriginalConstructor() + ->getMock(); + $local_machine = $this->getMockBuilder(LocalMachineHelper::class) + ->disableOriginalConstructor() + ->getMock(); + $this->config = $this->getMockBuilder(TerminusConfig::class) + ->disableOriginalConstructor() + ->getMock(); + $this->filesystem = $this->getMockBuilder(Filesystem::class) + ->disableOriginalConstructor() + ->getMock(); + $this->finder = $this->getMockBuilder(Finder::class) + ->disableOriginalConstructor() + ->getMock(); + + $container->expects($this->once()) + ->method('get') + ->with($this->equalTo(LocalMachineHelper::class)) + ->willReturn($local_machine); + $local_machine->expects($this->once()) + ->method('getFilesystem') + ->with() + ->willReturn($this->filesystem); + $local_machine->expects($this->once()) + ->method('getFinder') + ->with() + ->willReturn($this->finder); + $this->finder->expects($this->once()) + ->method('files') + ->with() + ->willReturn($this->finder); + + $this->command = new ClearCacheCommand(); + $this->command->setLogger($this->logger); + $this->command->setContainer($container); + $this->command->setConfig($this->config); + } + /** * Tests the self:clear-cache command */ public function testClearCache() { + $dir_name = 'some dir'; + $dirs = ['dir1', 'dir2', 'dir3', 'dir4',]; + $iterator = new Iterator($dirs); + + $this->config->expects(($this->once())) + ->method('get') + ->with($this->equalTo('command_cache_dir')) + ->willReturn($dir_name); + $this->finder->expects($this->once()) + ->method('in') + ->with($this->equalTo($dir_name)) + ->willReturn($this->finder); + $this->finder->expects($this->once()) + ->method('getIterator') + ->with() + ->willReturn($iterator); + + for ($i = 0; $i < count($dirs); $i++) { + $this->filesystem->expects($this->at($i)) + ->method('remove') + ->with($this->equalTo($dirs[$i])); + } + $this->logger->expects($this->once()) ->method('log') ->with( @@ -24,9 +113,7 @@ public function testClearCache() $this->equalTo('The local Terminus cache has been cleared.') ); - $command = new ClearCacheCommand(); - $command->setLogger($this->logger); - - $command->clearCache(); + $out = $this->command->clearCache(); + $this->assertNull($out); } }