mirror of
https://github.com/koel/koel
synced 2025-01-06 17:58:46 +00:00
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Integration\Commands;
|
||
|
|
||
|
use App\Console\Commands\GenerateJwtSecretCommand;
|
||
|
use App\Console\Kernel;
|
||
|
use Jackiedo\DotenvEditor\DotenvEditor;
|
||
|
use Mockery;
|
||
|
use Mockery\MockInterface;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class GenerateJwtSecretCommandTest extends TestCase
|
||
|
{
|
||
|
/** @var DotenvEditor|MockInterface */
|
||
|
private $dotenvEditor;
|
||
|
|
||
|
/** @var GenerateJwtSecretCommand */
|
||
|
private $command;
|
||
|
|
||
|
public function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
|
||
|
$this->dotenvEditor = $this->mockIocDependency(DotenvEditor::class);
|
||
|
$this->command = app(GenerateJwtSecretCommand::class);
|
||
|
app(Kernel::class)->registerCommand($this->command);
|
||
|
}
|
||
|
|
||
|
public function testGenerateJwtSecret()
|
||
|
{
|
||
|
config(['jwt.secret' => false]);
|
||
|
|
||
|
$this->dotenvEditor
|
||
|
->shouldReceive('setKey')
|
||
|
->with('JWT_SECRET', Mockery::on(function ($key) {
|
||
|
return preg_match('/[a-f0-9]{32}$/i', $key);
|
||
|
}));
|
||
|
|
||
|
$this->artisan('koel:generate-jwt-secret');
|
||
|
}
|
||
|
|
||
|
public function testNotRegenerateJwtSecret()
|
||
|
{
|
||
|
config(['jwt.secret' => '12345678901234567890123456789012']);
|
||
|
|
||
|
$this->dotenvEditor
|
||
|
->shouldReceive('setKey')
|
||
|
->never();
|
||
|
|
||
|
$this->artisan('koel:generate-jwt-secret');
|
||
|
}
|
||
|
}
|