This commit is contained in:
root
2023-03-29 15:20:05 +00:00
parent 5ec489e0e0
commit a0bb8f2d1e
25468 changed files with 3063105 additions and 28 deletions

View File

@@ -0,0 +1,21 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class AcceptEULACommandTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function testAcceptEULA()
{
$response = $this->artisan('speedtest:eula')
->assertExitCode(0);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class AppVersionTest extends TestCase
{
/**
* Test the version CLI command
*
* @return void
*/
public function testVersionCommand()
{
$response = $this->artisan('speedtest:version')
->expectsOutput('Speedtest Tracker v' . config('speedtest.version'));
}
}

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([]);
// }
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ClearOldSessionCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testClearSessionsCommand()
{
$this->artisan('speedtest:clear-sessions')
->expectsOutput('Invalidated expired sessions')
->assertExitCode(0);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ClearQueueCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testClearQueue()
{
$this->artisan('queue:clear')
->assertExitCode(0);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Tests\Feature\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class GetConfigCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testGetConfig()
{
$configJson = json_encode(SettingsHelper::getConfig(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$this->artisan('speedtest:config')
->expectsOutput($configJson)
->assertExitCode(0);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\Feature\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class SetSlackWebhookCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testSetSlackWebhook()
{
SettingsHelper::set('slack_webhook', 'pre-test');
$this->artisan('speedtest:slack', [ 'webhook' => 'test' ])
->expectsOutput('Slack webhook updated')
->assertExitCode(0);
$this->assertEquals(SettingsHelper::get('slack_webhook')->value, 'test');
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Tests\Feature\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class SetTelegramOptionsCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testSetTelegramOptions()
{
SettingsHelper::set('telegram_bot_token', 'pre-test-bot');
SettingsHelper::set('telegram_chat_id', 'pre-test-bot');
$this->artisan('speedtest:telegram', [
'--bot' => 'test-bot',
'--chat' => 'test-chat'
])->expectsOutput('Telegram options updated')
->assertExitCode(0);
$this->assertEquals(SettingsHelper::get('telegram_bot_token')->value, 'test-bot');
$this->assertEquals(SettingsHelper::get('telegram_chat_id')->value, 'test-chat');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class SpeedtestOverviewCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testOverviewCommand()
{
$this->artisan('speedtest:overview')
->assertExitCode(0);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\Feature\Commands;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class TestNotificationCommandTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function testTestNotificationCommand()
{
$this->artisan('speedtest:notification')
->assertExitCode(0);
}
}