Skip to content

Commit 2d4eb7c

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 3718f6d + 554be61 commit 2d4eb7c

File tree

22 files changed

+202
-130
lines changed

22 files changed

+202
-130
lines changed

.github/workflows/test-phpunit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- 'tests/**.php'
1212
- 'spark'
1313
- composer.json
14-
- phpunit.xml.dist
14+
- phpunit.dist.xml
1515
- .github/workflows/test-phpunit.yml
1616
- .github/workflows/reusable-phpunit-test.yml
1717

@@ -25,7 +25,7 @@ on:
2525
- 'tests/**.php'
2626
- 'spark'
2727
- composer.json
28-
- phpunit.xml.dist
28+
- phpunit.dist.xml
2929
- .github/workflows/test-phpunit.yml
3030
- .github/workflows/reusable-phpunit-test.yml
3131

.github/workflows/test-random-execution.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- '.github/scripts/run-random-tests.sh'
1010
- '.github/scripts/random-tests-config.txt'
1111
- '.github/workflows/test-random-execution.yml'
12-
- 'phpunit.xml.dist'
12+
- 'phpunit.dist.xml'
1313
- 'system/**.php'
1414
- 'tests/**.php'
1515

@@ -21,7 +21,7 @@ on:
2121
- '.github/scripts/run-random-tests.sh'
2222
- '.github/scripts/random-tests-config.txt'
2323
- '.github/workflows/test-random-execution.yml'
24-
- 'phpunit.xml.dist'
24+
- 'phpunit.dist.xml'
2525
- 'system/**.php'
2626
- 'tests/**.php'
2727

admin/starter/builds

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if (is_file($file)) {
9494

9595
$files = [
9696
__DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php',
97-
__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist',
97+
__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.dist.xml',
9898
__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml',
9999
];
100100

admin/starter/tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ The HTML files can be viewed by opening **tests/coverage/index.html** in your fa
8080

8181
## PHPUnit XML Configuration
8282

83-
The repository has a ``phpunit.xml.dist`` file in the project root that's used for
83+
The repository has a ``phpunit.dist.xml`` file in the project root that's used for
8484
PHPUnit configuration. This is used to provide a default configuration if you
8585
do not have your own configuration file in the project root.
8686

87-
The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
87+
The normal practice would be to copy ``phpunit.dist.xml`` to ``phpunit.xml``
8888
(which is git ignored), and to tailor it as you see fit.
8989
For instance, you might wish to exclude database tests, or automatically generate
9090
HTML code coverage reports.

admin/starter/tests/unit/HealthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testBaseUrlHasBeenSet(): void
2727

2828
if ($env) {
2929
// BaseURL in .env is a valid URL?
30-
// phpunit.xml.dist sets app.baseURL in $_SERVER
30+
// phpunit.dist.xml sets app.baseURL in $_SERVER
3131
// So if you set app.baseURL in .env, it takes precedence
3232
$config = new App();
3333
$this->assertTrue(
@@ -37,7 +37,7 @@ public function testBaseUrlHasBeenSet(): void
3737
}
3838

3939
// Get the baseURL in app/Config/App.php
40-
// You can't use Config\App, because phpunit.xml.dist sets app.baseURL
40+
// You can't use Config\App, because phpunit.dist.xml sets app.baseURL
4141
$reader = new ConfigReader();
4242

4343
// BaseURL in app/Config/App.php is a valid URL?

system/CLI/CLI.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public static function prompt(string $field, $options = null, $validation = null
237237
}
238238

239239
static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': ');
240+
static::$lastWrite = 'write';
240241

241242
// Read the input from keyboard.
242243
$input = trim(static::$io->input());
@@ -440,7 +441,8 @@ public static function write(string $text = '', ?string $foreground = null, ?str
440441
}
441442

442443
if (static::$lastWrite !== 'write') {
443-
$text = PHP_EOL . $text;
444+
$text = PHP_EOL . $text;
445+
444446
static::$lastWrite = 'write';
445447
}
446448

@@ -455,13 +457,20 @@ public static function write(string $text = '', ?string $foreground = null, ?str
455457
public static function error(string $text, string $foreground = 'light_red', ?string $background = null)
456458
{
457459
// Check color support for STDERR
458-
$stdout = static::$isColored;
460+
$stdout = static::$isColored;
461+
459462
static::$isColored = static::hasColorSupport(STDERR);
460463

461464
if ($foreground !== '' || (string) $background !== '') {
462465
$text = static::color($text, $foreground, $background);
463466
}
464467

468+
if (static::$lastWrite !== 'write') {
469+
$text = PHP_EOL . $text;
470+
471+
static::$lastWrite = 'write';
472+
}
473+
465474
static::fwrite(STDERR, $text . PHP_EOL);
466475

467476
// return STDOUT color support

system/Commands/Utilities/Environment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ final class Environment extends BaseCommand
8585
*/
8686
public function run(array $params)
8787
{
88-
if ($params === []) {
88+
if (! isset($params[0])) {
8989
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color(service('superglobals')->server('CI_ENVIRONMENT', ENVIRONMENT), 'green')));
9090
CLI::newLine();
9191

system/Commands/Utilities/Routes.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,26 @@ class Routes extends BaseCommand
7373
* @var array<string, string>
7474
*/
7575
protected $options = [
76-
'-h' => 'Sort by Handler.',
77-
'--host' => 'Specify hostname in request URI.',
76+
'--handler' => 'Sort by Handler.',
77+
'--host' => 'Specify hostname in request URI.',
7878
];
7979

8080
/**
8181
* Displays the help for the spark cli script itself.
8282
*/
8383
public function run(array $params)
8484
{
85-
$sortByHandler = array_key_exists('h', $params);
86-
$host = $params['host'] ?? null;
85+
$sortByHandler = array_key_exists('handler', $params);
86+
87+
if (! $sortByHandler && array_key_exists('h', $params)) {
88+
// Support -h as a shortcut but print a warning that it is not the intended use of -h.
89+
CLI::write('Warning: -h will be used as shortcut for --help in v4.8.0. Please use --handler to sort by handler.', 'yellow');
90+
CLI::newLine();
91+
92+
$sortByHandler = true;
93+
}
94+
95+
$host = $params['host'] ?? null;
8796

8897
// Set HTTP_HOST
8998
if ($host !== null) {

tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ as a comprehensive collection of HTML files that show the status of every line o
172172

173173
## PHPUnit XML Configuration
174174

175-
The repository has a ``phpunit.xml.dist`` file in the project root that's used for
175+
The repository has a ``phpunit.dist.xml`` file in the project root that's used for
176176
PHPUnit configuration. This is used to provide a default configuration if you
177177
do not have your own configuration file in the project root.
178178

179-
The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
179+
The normal practice would be to copy ``phpunit.dist.xml`` to ``phpunit.xml``
180180
(which is git ignored), and to tailor it as you see fit.
181181
For instance, you might wish to exclude database tests, or automatically generate
182182
HTML code coverage reports.

tests/system/CLI/CLITest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function setUp(): void
3737

3838
Services::injectMock('superglobals', new Superglobals());
3939

40+
CLI::reset();
4041
CLI::init();
4142
}
4243

@@ -393,24 +394,41 @@ public function testError(): void
393394
{
394395
CLI::error('test');
395396

396-
// red expected cuz stderr
397-
$expected = "\033[1;31mtest\033[0m" . PHP_EOL;
397+
$expected = PHP_EOL . "\033[1;31mtest\033[0m" . PHP_EOL;
398398
$this->assertSame($expected, $this->getStreamFilterBuffer());
399399
}
400400

401+
public function testMixedWriteError(): void
402+
{
403+
CLI::write('test 1');
404+
CLI::error('test 2');
405+
CLI::write('test 3');
406+
407+
$this->assertSame(
408+
<<<'EOT'
409+
410+
test 1
411+
test 2
412+
test 3
413+
414+
EOT,
415+
preg_replace('/\e\[[^m]+m/u', '', $this->getStreamFilterBuffer()),
416+
);
417+
}
418+
401419
public function testErrorForeground(): void
402420
{
403421
CLI::error('test', 'purple');
404422

405-
$expected = "\033[0;35mtest\033[0m" . PHP_EOL;
423+
$expected = PHP_EOL . "\033[0;35mtest\033[0m" . PHP_EOL;
406424
$this->assertSame($expected, $this->getStreamFilterBuffer());
407425
}
408426

409427
public function testErrorBackground(): void
410428
{
411429
CLI::error('test', 'purple', 'green');
412430

413-
$expected = "\033[0;35m\033[42mtest\033[0m" . PHP_EOL;
431+
$expected = PHP_EOL . "\033[0;35m\033[42mtest\033[0m" . PHP_EOL;
414432
$this->assertSame($expected, $this->getStreamFilterBuffer());
415433
}
416434

0 commit comments

Comments
 (0)