Skip to content

Commit a0e1e02

Browse files
driesvintsStyleCIBotmattstauffer
authored
Test Valet commands (#1256)
* First attempt at testing CLI commands * Apply fixes from StyleCI * Protect from running locally * Fix test * wip * wip * wip * wip * wip * Update app.php * Create config folder and files for CLI tests * Apply fixes from StyleCI * Fix some formatting * Fix imports * Update all output() calls to use the writer passed in by the command Ugly capture of all $outputs from commands, by passing them into `writer()` to be bound into the container, where they can then be pulled out from calls to `output()` and its buddies `info()`, `table()`, and `warning()`. * Apply fixes from StyleCI * Flesh out park command test * Apply fixes from StyleCI * Drop php 7.0 and 7.1 Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Matt Stauffer <[email protected]>
1 parent 9216b9a commit a0e1e02

18 files changed

+975
-736
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: true
1818
matrix:
19-
php: ['7.0', 7.1, 7.2, 7.3, 7.4, '8.0', 8.1, 8.2]
19+
php: [7.2, 7.3, 7.4, '8.0', 8.1, 8.2]
2020

2121
name: PHP ${{ matrix.php }}
2222

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ error.log
55
.idea
66
.phpunit.result.cache
77
tests/conf.d
8+
tests/config/

cli/Valet/Filesystem.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Valet;
44

55
use CommandLine as CommandLineFacade;
6+
use RecursiveDirectoryIterator;
7+
use RecursiveIteratorIterator;
68

79
class Filesystem
810
{
@@ -243,6 +245,24 @@ public function unlink($path)
243245
}
244246
}
245247

248+
/**
249+
* Recursively delete a directory and its contents.
250+
*
251+
* @param string $path
252+
* @return void
253+
*/
254+
public function rmDirAndContents($path)
255+
{
256+
$dir = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
257+
$files = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST);
258+
259+
foreach ($files as $file) {
260+
$file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
261+
}
262+
263+
rmdir($path);
264+
}
265+
246266
/**
247267
* Change the owner of the given path.
248268
*

0 commit comments

Comments
 (0)