Added unit tests for helpers and tests for commands

This commit is contained in:
Henry Whitaker
2020-08-25 18:26:21 +01:00
parent b30ec477f4
commit 94e4919b44
21 changed files with 927 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
<?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([]);
// }
}