Skip to content

Commit 4061ea3

Browse files
committed
ci(config): Update configuration files and .gitignore
- Add '/public' to .gitignore to prevent public directory from being tracked. - Introduce 'testbench:workbench:install' command in composer.json for easier installation. - Modify SOAR_ENABLED and DSN_DISABLE settings in testbench.yaml for clarity. - Sync public and storage directories with workbench for better asset management. Signed-off-by: guanguans <ityaozm@gmail.com>
1 parent d5eb85a commit 4061ea3

11 files changed

Lines changed: 132 additions & 79 deletions

File tree

README-zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ composer checks:required
548548
composer test
549549
composer testbench soar:run
550550
composer testbench soar:score
551-
composer testbench:example-serve
552551
composer testbench:serve
553552
composer testbench:test
553+
composer testbench:user-serve
554554
```
555555

556556
## 变更日志

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ composer checks:required
548548
composer test
549549
composer testbench soar:run
550550
composer testbench soar:score
551-
composer testbench:example-serve
552551
composer testbench:serve
553552
composer testbench:test
553+
composer testbench:user-serve
554554
```
555555

556556
## Changelog

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,6 @@
456456
"testbench": "@php vendor/bin/testbench --ansi -vv",
457457
"testbench:build": "@testbench workbench:build",
458458
"testbench:clear": "@testbench package:purge-skeleton",
459-
"testbench:example-serve": [
460-
"@composer-config:disable-process-timeout",
461-
"@testbench:build",
462-
"@php -S localhost:8123 laravel/public/index.php"
463-
],
464459
"testbench:optimize:image": "@testbench optimize:image",
465460
"testbench:optimize:image-dry-run": "@testbench:optimize:image --dry-run",
466461
"testbench:prepare": "@testbench package:discover",
@@ -473,6 +468,12 @@
473468
"@testbench:clear",
474469
"@pest"
475470
],
471+
"testbench:user-serve": [
472+
"@composer-config:disable-process-timeout",
473+
"@testbench:build",
474+
"@php -S localhost:8123 workbench/public/index.php"
475+
],
476+
"testbench:workbench:install": "@testbench workbench:install",
476477
"todo-lint": "! git --no-pager grep --extended-regexp --ignore-case 'todo|fixme' -- '*.php' ':!*.blade.php' ':(exclude)resources/'",
477478
"touch:database-sqlite": "@php -r \"file_exists('vendor/orchestra/testbench-core/laravel/database/database.sqlite') || touch('vendor/orchestra/testbench-core/laravel/database/database.sqlite');\"",
478479
"trufflehog": "trufflehog git https://github.com/guanguans/laravel-soar --only-verified",

testbench.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ providers:
99

1010
env:
1111
APP_NAME: "Testbench"
12-
SOAR_ENABLED: true
12+
SOAR_ENABLED: (true)
1313
# SOAR_SUDO_PASSWORD: "password"
14-
SOAR_TEST_DSN_DISABLE: true
15-
SOAR_ONLINE_DSN_DISABLE: true
14+
SOAR_TEST_DSN_DISABLE: (true)
15+
SOAR_ONLINE_DSN_DISABLE: (true)
1616

1717
migrations:
1818
- workbench/database/migrations
@@ -35,9 +35,13 @@ workbench:
3535
- create-sqlite-db
3636
- db-wipe
3737
- migrate-fresh
38+
- public:link
3839
assets:
3940
- laravel-assets
4041
sync:
42+
- from: public
43+
to: workbench/public
44+
reverse: true
4145
- from: storage
4246
to: workbench/storage
4347
reverse: true

tests/Feature/ConsoleTest.php

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,45 @@
1919
* @see https://github.com/guanguans/laravel-soar
2020
*/
2121

22+
use Composer\Semver\Comparator;
2223
use Guanguans\LaravelSoar\Bootstrapper;
24+
use Illuminate\Console\Events\CommandFinished;
25+
use Illuminate\Foundation\Application;
2326
use Illuminate\Support\Arr;
24-
25-
beforeEach(function (): void {
26-
resolve(Bootstrapper::class)->boot();
27-
28-
$this->see = collect(Arr::first(Soar::arrayScores('select * from users')))
29-
->except(['ID', 'Fingerprint'])
30-
->keys()
31-
->push('Summary', 'Basic', 'Backtraces')
32-
->all();
33-
});
34-
35-
it('can not output soar scores', function (): void {
36-
config()->set('soar.except', ['output:all']);
37-
38-
$this->artisan('output:all')
39-
// ->expectsOutput(OutputManager::class)
40-
->expectsOutputToContain(OutputManager::class)
41-
->assertOk();
27+
use Illuminate\Support\Facades\Event;
28+
use Workbench\App\Support\Utils;
29+
30+
uses(WithConsoleEvents::class)
31+
->beforeEach(function (): void {
32+
resolve(Bootstrapper::class)->boot();
33+
34+
$this->see = collect(Arr::first(Soar::arrayScores('select * from users')))
35+
->except(['ID', 'Fingerprint'])
36+
->keys()
37+
->push('Summary', 'Basic', 'Backtraces')
38+
->all();
39+
});
40+
41+
it('is a console output example', function (): void {
42+
Event::fakeFor(function (): void {
43+
$this->artisan('output:example')
44+
// ->expectsOutput(Utils::CONSOLE_OUTPUT_PHRASE)
45+
->expectsOutputToContain(Utils::CONSOLE_OUTPUT_PHRASE)
46+
->assertOk();
47+
48+
// Event::assertDispatched(CommandFinished::class);
49+
});
4250
})->group(__DIR__, __FILE__);
4351

44-
it('can outputs console', function (): void {
45-
$this->artisan('output:all')
46-
// ->expectsOutput(OutputManager::class)
47-
->expectsOutputToContain(OutputManager::class)
48-
->assertOk();
49-
})->group(__DIR__, __FILE__);
52+
it('is a console output example with console events ', function (): void {
53+
Event::fakeFor(function (): void {
54+
$this->artisan('output:example')
55+
// ->expectsOutput(Utils::CONSOLE_OUTPUT_PHRASE)
56+
->expectsOutputToContain(Utils::CONSOLE_OUTPUT_PHRASE)
57+
->assertOk();
58+
59+
Event::assertDispatched(CommandFinished::class);
60+
});
61+
})
62+
->group(__DIR__, __FILE__)
63+
->skip(Comparator::lessThan(Application::VERSION, '11.0.0'));

tests/Feature/HttpTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121

2222
use Guanguans\LaravelSoar\Bootstrapper;
2323
use Guanguans\LaravelSoar\Facades\Soar;
24-
use Guanguans\LaravelSoar\OutputManager;
25-
use Guanguans\LaravelSoar\Outputs\JsonOutput;
2624
use Illuminate\Support\Arr;
25+
use Workbench\App\Support\Utils;
2726

2827
beforeEach(function (): void {
2928
resolve(Bootstrapper::class)->boot();
@@ -35,19 +34,19 @@
3534
->all();
3635
});
3736

38-
it('can output to all', function (): void {
37+
it('is a general output example', function (): void {
3938
$this
40-
->get('output/all-example')
39+
->get('general-example')
4140
->assertOk()
4241
->assertSee($this->see)
43-
->assertSee(OutputManager::class);
42+
->assertSee(Utils::GENERAL_OUTPUT_PHRASE);
4443
})->group(__DIR__, __FILE__);
4544

46-
it('can output to json', function (): void {
45+
it('is a json output example', function (): void {
4746
$this
48-
->getJson('output/json-example')
47+
->getJson('json-example')
4948
->assertOk()
5049
->assertJsonStructure()
5150
->assertSee($this->see)
52-
->assertSee(class_basename(JsonOutput::class));
51+
->assertSee(Utils::JSON_OUTPUT_PHRASE);
5352
})->group(__DIR__, __FILE__);

workbench/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.env
22
.env.dusk
3+
/public
34
/storage

workbench/app/Support/Utils.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222
use Guanguans\LaravelSoar\Outputs\LaraDumpsOutput;
2323
use Guanguans\LaravelSoar\Outputs\LogOutput;
2424
use Guanguans\LaravelSoar\Outputs\RayOutput;
25+
use Illuminate\Support\Facades\Artisan;
2526
use Workbench\App\Models\User;
2627
use Workbench\Database\Factories\UserFactory;
2728

2829
class Utils
2930
{
31+
public const CONSOLE_OUTPUT_PHRASE = 'This is a console output example.';
32+
public const GENERAL_OUTPUT_PHRASE = 'This is a general output example.';
33+
public const JSON_OUTPUT_PHRASE = 'This is a json output example.';
34+
3035
public static function extendOutputManager(null|array|string $outputs = null): void
3136
{
3237
$outputs ??= [
@@ -58,4 +63,25 @@ static function (OutputManager $outputManager) use ($outputs): OutputManager {
5863
UserFactory::new()->times(3)->create();
5964
User::query()->first();
6065
}
66+
67+
/**
68+
* @see \Illuminate\Foundation\Console\StorageLinkCommand
69+
*/
70+
public static function links(array $links, array $parameters = []): int
71+
{
72+
$originalLinks = config('filesystems.links', []);
73+
74+
config()->set('filesystems.links', $links);
75+
76+
$status = Artisan::call('storage:link', $parameters + [
77+
'--ansi' => true,
78+
'--verbose' => true,
79+
]);
80+
81+
config()->set('filesystems.links', $originalLinks);
82+
83+
// echo Artisan::output();
84+
85+
return $status;
86+
}
6187
}

workbench/routes/api.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
* @see https://github.com/guanguans/laravel-soar
1414
*/
1515

16+
use Guanguans\LaravelSoar\Outputs\ClockworkOutput;
17+
use Guanguans\LaravelSoar\Outputs\ConsoleOutput;
18+
use Guanguans\LaravelSoar\Outputs\DebugBarOutput;
19+
use Guanguans\LaravelSoar\Outputs\DumpOutput;
20+
use Guanguans\LaravelSoar\Outputs\JsonOutput;
21+
use Guanguans\LaravelSoar\Outputs\LaraDumpsOutput;
22+
use Guanguans\LaravelSoar\Outputs\LogOutput;
23+
use Guanguans\LaravelSoar\Outputs\RayOutput;
1624
use Illuminate\Http\Request;
1725
use Illuminate\Support\Facades\Route;
26+
use Workbench\App\Support\Utils;
1827

1928
/*
2029
|--------------------------------------------------------------------------
@@ -30,3 +39,18 @@
3039
// Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
3140
// return $request->user();
3241
// });
42+
43+
Route::get('json-example', static function (): array {
44+
Utils::extendOutputManager([
45+
ClockworkOutput::class,
46+
ConsoleOutput::class,
47+
DebugBarOutput::class,
48+
// DumpOutput::class,
49+
JsonOutput::class,
50+
LaraDumpsOutput::class,
51+
LogOutput::class,
52+
RayOutput::class,
53+
]);
54+
55+
return ['phrase' => Utils::JSON_OUTPUT_PHRASE];
56+
});

workbench/routes/console.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* @see https://github.com/guanguans/laravel-soar
1414
*/
1515

16-
use Guanguans\LaravelSoar\OutputManager;
1716
use Illuminate\Foundation\Inspiring;
1817
use Illuminate\Support\Collection;
1918
use Illuminate\Support\Facades\Artisan;
@@ -36,14 +35,23 @@
3635
*/
3736

3837
// Artisan::command('inspire', function () {
39-
// $this->comment(Inspiring::quote());
38+
// $this->components->comment(Inspiring::quote());
4039
// })->purpose('Display an inspiring quote');
4140

42-
Artisan::command('output:all', function (): void {
41+
Artisan::command('output:example', function (): void {
4342
Utils::extendOutputManager();
4443

4544
/** @var \Illuminate\Console\Command $this */
46-
$this->info(OutputManager::class);
45+
$this->components->info(Utils::CONSOLE_OUTPUT_PHRASE);
46+
});
47+
48+
Artisan::command('public:link', function (): void {
49+
Utils::links([
50+
__DIR__.'/../'.basename($target = __DIR__.'/../../vendor/orchestra/testbench-core/laravel/public/') => $target,
51+
]);
52+
53+
/** @var \Illuminate\Console\Command $this */
54+
$this->components->info('The [public] directory has been linked.');
4755
});
4856

4957
Artisan::command('optimize:image {--dry-run : Only list found images}', function (): void {

0 commit comments

Comments
 (0)