1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 20:04:24 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Alexander Skvortsov
ce01822ff6 Add console test 2021-05-05 18:48:14 -04:00
Daniël Klabbers
7708be2fe6 Update src/Console/ConsoleServiceProvider.php 2021-05-06 00:36:20 +02:00
Daniël Klabbers
bddfb5605d Update src/Console/ConsoleServiceProvider.php 2021-05-06 00:35:05 +02:00
Daniel Klabbers
a56c748ad4 Fix unavailable translator catalogue for cli use
Fixes #2836

When there's no locale cache, cli cannot translate. This re-instantiates
that cache when needed.
2021-05-05 10:57:22 +02:00
2 changed files with 62 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Console\AssetsPublishCommand;
use Flarum\Foundation\Console\CacheClearCommand;
use Flarum\Foundation\Console\InfoCommand;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Console\Scheduling\Schedule as LaravelSchedule;
use Illuminate\Console\Scheduling\ScheduleListCommand;
use Illuminate\Console\Scheduling\ScheduleRunCommand;
@@ -65,5 +66,9 @@ class ConsoleServiceProvider extends AbstractServiceProvider
$event = $schedule->command($scheduled['command'], $scheduled['args']);
$scheduled['callback']($event);
}
$container->make('flarum.locales')->getTranslator()->getCatalogue(
$container->make(SettingsRepositoryInterface::class)->get('default_locale', 'en')
);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Tests\integration\console;
use Flarum\Console\AbstractCommand;
use Flarum\Extend;
use Flarum\Locale\Translator;
use Flarum\Testing\integration\ConsoleTestCase;
class AbstractCommandTest extends ConsoleTestCase
{
/**
* @test
*/
public function scheduled_command_exists_when_added()
{
$this->extend(
(new Extend\Console())
->command(CustomEchoTranslationsCommand::class)
);
$input = [
'command' => 'customEchoTranslationsCommand'
];
// Arbitrary translation
$this->assertEquals('Flarum Email Test', $this->runCommand($input));
}
}
class CustomEchoTranslationsCommand extends AbstractCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('customEchoTranslationsCommand');
}
/**
* {@inheritdoc}
*/
protected function fire()
{
$translator = resolve(Translator::class);
$this->info($translator->trans('core.emails.send_test.subject'));
}
}