Skip to content

Commit 284e92e

Browse files
committed
Fixed test
1 parent 6e5bbf5 commit 284e92e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: tests/unit/helpers/AppHelperTest.php

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
use Craft;
1111
use craft\config\GeneralConfig;
12+
use craft\console\Application as ConsoleApplication;
13+
use craft\console\Request as ConsoleRequest;
1214
use craft\helpers\App;
1315
use craft\mail\transportadapters\Sendmail;
1416
use craft\models\MailSettings;
@@ -127,6 +129,19 @@ public function testCliOption(): void
127129
];
128130
$length = count($_SERVER['argv']);
129131

132+
// super hacky but no other choice
133+
$app = Craft::$app;
134+
Craft::$app = new ConsoleApplication([
135+
'id' => $app->id,
136+
'basePath' => $app->basePath,
137+
'components' => [
138+
'config' => fn() => $app->getConfig(),
139+
'projectConfig' => fn() => $app->getProjectConfig(),
140+
'request' => ConsoleRequest::class,
141+
'plugins' => fn() => $app->getPlugins(),
142+
],
143+
]);
144+
130145
self::assertSame('foo.sql', App::cliOption('--file-path'));
131146
self::assertSame('bar.sql', App::cliOption('-f', true));
132147
self::assertSame(true, App::cliOption('--zip'));
@@ -143,6 +158,8 @@ public function testCliOption(): void
143158
unset($_SERVER['argv']);
144159
}
145160

161+
Craft::$app = $app;
162+
146163
self::expectException(InvalidArgumentException::class);
147164
App::cliOption('no-dash');
148165
}

0 commit comments

Comments
 (0)