docker-itmgmt/speedtest/volumes/config/www/tests/Feature/Commands/AuthenticationCommandTest.php
2023-03-29 15:20:05 +00:00

74 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature\Commands;
use App\Console\Commands\AuthenticationCommand;
use App\Helpers\SettingsHelper;
use Artisan;
use Illuminate\Console\Command;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\TestCase;
class AuthenticationCommandTest extends TestCase
{
use RefreshDatabase;
/**
* Enable app auth
*
* @return void
*/
public function testEnableAuth()
{
SettingsHelper::set('auth', false);
$this->assertEquals(Artisan::call('speedtest:auth', [ '--enable' => true ]), 0);
$this->assertTrue((bool)SettingsHelper::get('auth')->value);
}
/**
* Disable app auth
*
* @return void
*/
public function testDisableAuth()
{
SettingsHelper::set('auth', true);
$this->assertEquals(Artisan::call('speedtest:auth', [ '--disable' => true ]), 0);
$this->assertFalse((bool)SettingsHelper::get('auth')->value);
}
/**
* Test invalid params for command
*
* @return void
*/
// public function testAuthBothOptions()
// {
// $command = new AuthenticationCommand();
// $command->setLaravel($this->app);
// $tester = new CommandTester($command);
// $tester->setInputs([]);
// $tester->execute([ '--enable' => true, '--disable' => true ]);
// }
/**
* Test invalid params for command
*
* @return void
*/
// public function testAuthNoOptions()
// {
// $command = new AuthenticationCommand();
// $command->setLaravel($this->app);
// $tester = new CommandTester($command);
// $tester->setInputs([]);
// $tester->execute([]);
// }
}