mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
#591 - tests
This commit is contained in:
2
.github/workflows/code-quality.yml
vendored
2
.github/workflows/code-quality.yml
vendored
@ -4,9 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 2.x
|
- 2.x
|
||||||
|
- 3.x
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 2.x
|
- 2.x
|
||||||
|
- 3.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
|
1
.github/workflows/code-style.yml
vendored
1
.github/workflows/code-style.yml
vendored
@ -6,6 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- 1.x
|
- 1.x
|
||||||
- 2.x
|
- 2.x
|
||||||
|
- 3.x
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
13
.github/workflows/tests.yml
vendored
13
.github/workflows/tests.yml
vendored
@ -6,6 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- 1.x
|
- 1.x
|
||||||
- 2.x
|
- 2.x
|
||||||
|
- 3.x
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -16,6 +17,7 @@ jobs:
|
|||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
php: [ 8.4 ]
|
php: [ 8.4 ]
|
||||||
|
node-version: [ "20.x" ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -44,5 +46,16 @@ jobs:
|
|||||||
- name: Set up the .env file
|
- name: Set up the .env file
|
||||||
run: touch .env
|
run: touch .env
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
|
||||||
|
- name: Install NPM Dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Build assets
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
- name: Run test suite
|
- name: Run test suite
|
||||||
run: php artisan test
|
run: php artisan test
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,3 +22,4 @@ yarn-error.log
|
|||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
laradumps.yaml
|
laradumps.yaml
|
||||||
|
/public/build
|
||||||
|
@ -34,7 +34,7 @@ class RedirectController extends Controller
|
|||||||
#[ResponseFromApiResource(RedirectResource::class, Redirect::class, collection: true, paginate: 25)]
|
#[ResponseFromApiResource(RedirectResource::class, Redirect::class, collection: true, paginate: 25)]
|
||||||
public function index(Project $project, Server $server, Site $site): ResourceCollection
|
public function index(Project $project, Server $server, Site $site): ResourceCollection
|
||||||
{
|
{
|
||||||
$this->authorize('view', [Redirect::class, $site, $server]);
|
$this->authorize('viewAny', [Redirect::class, $site, $server]);
|
||||||
|
|
||||||
$this->validateRoute($project, $server, $site);
|
$this->validateRoute($project, $server, $site);
|
||||||
|
|
||||||
@ -53,8 +53,6 @@ public function create(Request $request, Project $project, Server $server, Site
|
|||||||
|
|
||||||
$this->validateRoute($project, $server, $site);
|
$this->validateRoute($project, $server, $site);
|
||||||
|
|
||||||
$this->validate($request, CreateRedirect::rules($site));
|
|
||||||
|
|
||||||
$redirect = app(CreateRedirect::class)->create($site, $request->all());
|
$redirect = app(CreateRedirect::class)->create($site, $request->all());
|
||||||
|
|
||||||
return new RedirectResource($redirect);
|
return new RedirectResource($redirect);
|
||||||
@ -65,7 +63,7 @@ public function create(Request $request, Project $project, Server $server, Site
|
|||||||
#[Response(status: 204)]
|
#[Response(status: 204)]
|
||||||
public function delete(Project $project, Server $server, Site $site, Redirect $redirect): HttpResponse
|
public function delete(Project $project, Server $server, Site $site, Redirect $redirect): HttpResponse
|
||||||
{
|
{
|
||||||
$this->authorize('delete', [Redirect::class, $site, $server]);
|
$this->authorize('delete', [$redirect, $site, $server]);
|
||||||
|
|
||||||
$this->validateRoute($project, $server, $site);
|
$this->validateRoute($project, $server, $site);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class CronjobTest extends TestCase
|
|||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
public function test_see_cronjobs_list()
|
public function test_see_cronjobs_list(): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public function test_see_cronjobs_list()
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_create_cronjob()
|
public function test_create_cronjob(): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public function test_create_cronjob()
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_delete_cronjob()
|
public function test_delete_cronjob(): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public function test_cannot_delete_last_project(): void
|
|||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
|
|
||||||
$this->json('DELETE', "/api/projects/{$this->user->currentProject->id}")
|
$this->json('DELETE', "/api/projects/{$this->user->currentProject->id}")
|
||||||
->assertJsonValidationErrorFor('project');
|
->assertJsonValidationErrorFor('name');
|
||||||
|
|
||||||
$this->assertDatabaseHas('projects', [
|
$this->assertDatabaseHas('projects', [
|
||||||
'id' => $this->user->currentProject->id,
|
'id' => $this->user->currentProject->id,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ServerProvidersTest extends TestCase
|
class ServerProvidersTest extends TestCase
|
||||||
@ -13,8 +14,9 @@ class ServerProvidersTest extends TestCase
|
|||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @param array<string, mixed> $input
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_connect_provider(string $provider, array $input): void
|
public function test_connect_provider(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -40,8 +42,9 @@ public function test_connect_provider(string $provider, array $input): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @param array<string, mixed> $input
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_cannot_connect_to_provider(string $provider, array $input): void
|
public function test_cannot_connect_to_provider(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -82,9 +85,7 @@ public function test_see_providers_list(): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_delete_provider(string $provider): void
|
public function test_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -102,9 +103,7 @@ public function test_delete_provider(string $provider): void
|
|||||||
->assertNoContent();
|
->assertNoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_cannot_delete_provider(string $provider): void
|
public function test_cannot_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -128,6 +127,9 @@ public function test_cannot_delete_provider(string $provider): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array<int, mixed>>
|
||||||
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
use App\Facades\SSH;
|
use App\Facades\SSH;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ServicesTest extends TestCase
|
class ServicesTest extends TestCase
|
||||||
@ -57,9 +58,7 @@ public function test_show_service(): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_manage_service(string $action): void
|
public function test_manage_service(string $action): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -94,6 +93,10 @@ public function test_uninstall_service(): void
|
|||||||
]))
|
]))
|
||||||
->assertSuccessful()
|
->assertSuccessful()
|
||||||
->assertNoContent();
|
->assertNoContent();
|
||||||
|
|
||||||
|
$this->assertDatabaseMissing('services', [
|
||||||
|
'id' => $service->id,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cannot_uninstall_service_because_it_is_being_used(): void
|
public function test_cannot_uninstall_service_because_it_is_being_used(): void
|
||||||
@ -112,6 +115,9 @@ public function test_cannot_uninstall_service_because_it_is_being_used(): void
|
|||||||
->assertJsonValidationErrorFor('service');
|
->assertJsonValidationErrorFor('service');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array<string>>
|
||||||
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\Traits\PrepareLoadBalancer;
|
use Tests\Traits\PrepareLoadBalancer;
|
||||||
|
|
||||||
@ -27,8 +28,9 @@ protected function setUp(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider create_data
|
* @param array<string, mixed> $inputs
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('create_data')]
|
||||||
public function test_create_site(array $inputs): void
|
public function test_create_site(array $inputs): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
@ -383,10 +385,11 @@ public function test_update_env(): void
|
|||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'domain' => $site->domain,
|
'domain' => $site->domain,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
SSH::assertExecuted('edit-file');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array<array<string, mixed>>>
|
||||||
|
*/
|
||||||
public static function create_data(): array
|
public static function create_data(): array
|
||||||
{
|
{
|
||||||
return \Tests\Feature\SitesTest::create_data();
|
return \Tests\Feature\SitesTest::create_data();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SourceControlsTest extends TestCase
|
class SourceControlsTest extends TestCase
|
||||||
@ -13,8 +14,9 @@ class SourceControlsTest extends TestCase
|
|||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @param array<string, mixed> $input
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_connect_provider(string $provider, array $input): void
|
public function test_connect_provider(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -39,6 +41,7 @@ public function test_connect_provider(string $provider, array $input): void
|
|||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_delete_provider(string $provider): void
|
public function test_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -60,6 +63,7 @@ public function test_delete_provider(string $provider): void
|
|||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_cannot_delete_provider(string $provider): void
|
public function test_cannot_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -90,7 +94,10 @@ public function test_cannot_delete_provider(string $provider): void
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $input
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_edit_source_control(string $provider, array $input): void
|
public function test_edit_source_control(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
Http::fake();
|
Http::fake();
|
||||||
@ -124,6 +131,9 @@ public function test_edit_source_control(string $provider, array $input): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array<int, mixed>>
|
||||||
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class StorageProvidersTest extends TestCase
|
class StorageProvidersTest extends TestCase
|
||||||
@ -17,8 +18,9 @@ class StorageProvidersTest extends TestCase
|
|||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider createData
|
* @param array<string, mixed> $input
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('createData')]
|
||||||
public function test_create(array $input): void
|
public function test_create(array $input): void
|
||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||||
@ -106,7 +108,7 @@ public function test_cannot_delete_provider(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @TODO: complete FTP tests
|
* @return array<int, array<int, array<string, mixed>>>
|
||||||
*/
|
*/
|
||||||
public static function createData(): array
|
public static function createData(): array
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ApplicationTest extends TestCase
|
class ApplicationTest extends TestCase
|
||||||
@ -153,9 +154,8 @@ public function test_update_env_file(): void
|
|||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $webhook
|
* @param array<string, mixed> $webhook
|
||||||
* @param array<string, mixed> $payload
|
* @param array<string, mixed> $payload
|
||||||
*
|
|
||||||
* @dataProvider hookData
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('hookData')]
|
||||||
public function test_git_hook_deployment(string $provider, array $webhook, string $url, array $payload, bool $skip): void
|
public function test_git_hook_deployment(string $provider, array $webhook, string $url, array $payload, bool $skip): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
@ -143,7 +143,7 @@ public function test_cannot_create_cronjob_for_user_on_another_server(): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_create_custom_cronjob()
|
public function test_create_custom_cronjob(): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ public function test_create_custom_cronjob()
|
|||||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_enable_cronjob()
|
public function test_enable_cronjob(): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
|
||||||
|
@ -13,17 +13,14 @@
|
|||||||
use Illuminate\Support\Facades\Bus;
|
use Illuminate\Support\Facades\Bus;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class DatabaseBackupTest extends TestCase
|
class DatabaseBackupTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*
|
|
||||||
* @throws JsonException
|
|
||||||
*/
|
|
||||||
public function test_create_backup(string $db): void
|
public function test_create_backup(string $db): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
@ -156,11 +153,7 @@ public function test_update_backup(): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*
|
|
||||||
* @throws JsonException
|
|
||||||
*/
|
|
||||||
public function test_delete_backup(string $db): void
|
public function test_delete_backup(string $db): void
|
||||||
{
|
{
|
||||||
$this->setupDatabase($db);
|
$this->setupDatabase($db);
|
||||||
@ -190,11 +183,7 @@ public function test_delete_backup(string $db): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*
|
|
||||||
* @throws JsonException
|
|
||||||
*/
|
|
||||||
public function test_restore_backup(string $db): void
|
public function test_restore_backup(string $db): void
|
||||||
{
|
{
|
||||||
Http::fake();
|
Http::fake();
|
||||||
@ -247,6 +236,9 @@ private function setupDatabase(string $database): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<int, string>>
|
||||||
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use App\Facades\SSH;
|
use App\Facades\SSH;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class PHPTest extends TestCase
|
class PHPTest extends TestCase
|
||||||
@ -64,9 +65,7 @@ public function test_install_extension(): void
|
|||||||
$this->assertContains('gmp', $php->refresh()->type_data['extensions']);
|
$this->assertContains('gmp', $php->refresh()->type_data['extensions']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('php_ini_data')]
|
||||||
* @dataProvider php_ini_data
|
|
||||||
*/
|
|
||||||
public function test_get_php_ini(string $version, string $type): void
|
public function test_get_php_ini(string $version, string $type): void
|
||||||
{
|
{
|
||||||
SSH::fake('[PHP ini]');
|
SSH::fake('[PHP ini]');
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ServerProvidersTest extends TestCase
|
class ServerProvidersTest extends TestCase
|
||||||
@ -16,10 +17,9 @@ class ServerProvidersTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, mixed> $input
|
||||||
*
|
*
|
||||||
* @dataProvider data
|
|
||||||
*
|
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_connect_provider(string $provider, array $input): void
|
public function test_connect_provider(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -45,9 +45,8 @@ public function test_connect_provider(string $provider, array $input): void
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, mixed> $input
|
||||||
*
|
|
||||||
* @dataProvider data
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_cannot_connect_to_provider(string $provider, array $input): void
|
public function test_cannot_connect_to_provider(string $provider, array $input): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -86,10 +85,9 @@ public function test_see_providers_list(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
|
||||||
*
|
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_delete_provider(string $provider): void
|
public function test_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -108,9 +106,7 @@ public function test_delete_provider(string $provider): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_cannot_delete_provider(string $provider): void
|
public function test_cannot_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ServicesTest extends TestCase
|
class ServicesTest extends TestCase
|
||||||
@ -26,9 +27,7 @@ public function test_see_services_list(): void
|
|||||||
->assertInertia(fn (AssertableInertia $page) => $page->component('services/index'));
|
->assertInertia(fn (AssertableInertia $page) => $page->component('services/index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_restart_service(string $name): void
|
public function test_restart_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -50,9 +49,7 @@ public function test_restart_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::READY, $service->status);
|
$this->assertEquals(ServiceStatus::READY, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_failed_to_restart_service(string $name): void
|
public function test_failed_to_restart_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -72,9 +69,7 @@ public function test_failed_to_restart_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_stop_service(string $name): void
|
public function test_stop_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -94,9 +89,7 @@ public function test_stop_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::STOPPED, $service->status);
|
$this->assertEquals(ServiceStatus::STOPPED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_failed_to_stop_service(string $name): void
|
public function test_failed_to_stop_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -116,9 +109,7 @@ public function test_failed_to_stop_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_start_service(string $name): void
|
public function test_start_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -140,9 +131,7 @@ public function test_start_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::READY, $service->status);
|
$this->assertEquals(ServiceStatus::READY, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_failed_to_start_service(string $name): void
|
public function test_failed_to_start_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -162,9 +151,7 @@ public function test_failed_to_start_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_enable_service(string $name): void
|
public function test_enable_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -186,9 +173,7 @@ public function test_enable_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::READY, $service->status);
|
$this->assertEquals(ServiceStatus::READY, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_failed_to_enable_service(string $name): void
|
public function test_failed_to_enable_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -208,9 +193,7 @@ public function test_failed_to_enable_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_disable_service(string $name): void
|
public function test_disable_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -230,9 +213,7 @@ public function test_disable_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::DISABLED, $service->status);
|
$this->assertEquals(ServiceStatus::DISABLED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_failed_to_disable_service(string $name): void
|
public function test_failed_to_disable_service(string $name): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -252,9 +233,7 @@ public function test_failed_to_disable_service(string $name): void
|
|||||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('installData')]
|
||||||
* @dataProvider installData
|
|
||||||
*/
|
|
||||||
public function test_install_service(string $name, string $type, string $version): void
|
public function test_install_service(string $name, string $type, string $version): void
|
||||||
{
|
{
|
||||||
Http::fake([
|
Http::fake([
|
||||||
@ -357,11 +336,6 @@ public static function installData(): array
|
|||||||
'database',
|
'database',
|
||||||
'16',
|
'16',
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'vito-agent',
|
|
||||||
'monitoring',
|
|
||||||
'latest',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SitesTest extends TestCase
|
class SitesTest extends TestCase
|
||||||
@ -19,9 +20,8 @@ class SitesTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $inputs
|
* @param array<string, mixed> $inputs
|
||||||
*
|
|
||||||
* @dataProvider create_data
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('create_data')]
|
||||||
public function test_create_site(array $inputs): void
|
public function test_create_site(array $inputs): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
@ -55,9 +55,8 @@ public function test_create_site(array $inputs): void
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $inputs
|
* @param array<string, mixed> $inputs
|
||||||
*
|
|
||||||
* @dataProvider failure_create_data
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('failure_create_data')]
|
||||||
public function test_isolated_user_failure(array $inputs): void
|
public function test_isolated_user_failure(array $inputs): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
@ -67,9 +66,7 @@ public function test_isolated_user_failure(array $inputs): void
|
|||||||
->assertSessionHasErrors();
|
->assertSessionHasErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('create_failure_data')]
|
||||||
* @dataProvider create_failure_data
|
|
||||||
*/
|
|
||||||
public function test_create_site_failed_due_to_source_control(int $status): void
|
public function test_create_site_failed_due_to_source_control(int $status): void
|
||||||
{
|
{
|
||||||
$inputs = [
|
$inputs = [
|
||||||
@ -275,7 +272,7 @@ public function test_change_branch(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<array<string, mixed>>
|
* @return array<array<int, mixed>>
|
||||||
*/
|
*/
|
||||||
public static function failure_create_data(): array
|
public static function failure_create_data(): array
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
use App\Models\SourceControl;
|
use App\Models\SourceControl;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SourceControlsTest extends TestCase
|
class SourceControlsTest extends TestCase
|
||||||
@ -13,9 +14,8 @@ class SourceControlsTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, mixed> $input
|
||||||
*
|
|
||||||
* @dataProvider data
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_connect_provider(string $provider, ?string $customUrl, array $input): void
|
public function test_connect_provider(string $provider, ?string $customUrl, array $input): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -53,9 +53,7 @@ public function test_connect_provider(string $provider, ?string $customUrl, arra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_delete_provider(string $provider): void
|
public function test_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -75,9 +73,7 @@ public function test_delete_provider(string $provider): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_cannot_delete_provider(string $provider): void
|
public function test_cannot_delete_provider(string $provider): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -104,9 +100,8 @@ public function test_cannot_delete_provider(string $provider): void
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, mixed> $input
|
||||||
*
|
|
||||||
* @dataProvider data
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_edit_source_control(string $provider, ?string $url, array $input): void
|
public function test_edit_source_control(string $provider, ?string $url, array $input): void
|
||||||
{
|
{
|
||||||
Http::fake();
|
Http::fake();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
use App\Models\SshKey;
|
use App\Models\SshKey;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SshKeysTest extends TestCase
|
class SshKeysTest extends TestCase
|
||||||
@ -56,9 +57,8 @@ public function test_delete_key(): void
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $postBody
|
* @param array<string, string> $postBody
|
||||||
*
|
|
||||||
* @dataProvider ssh_key_data_provider
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('ssh_key_data_provider')]
|
||||||
public function test_create_ssh_key_handles_invalid_or_partial_keys(array $postBody, bool $expectedToSucceed): void
|
public function test_create_ssh_key_handles_invalid_or_partial_keys(array $postBody, bool $expectedToSucceed): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Inertia\Testing\AssertableInertia;
|
use Inertia\Testing\AssertableInertia;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class StorageProvidersTest extends TestCase
|
class StorageProvidersTest extends TestCase
|
||||||
@ -18,9 +19,8 @@ class StorageProvidersTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, mixed> $input
|
||||||
*
|
|
||||||
* @dataProvider createData
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('createData')]
|
||||||
public function test_create(array $input): void
|
public function test_create(array $input): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -104,8 +104,6 @@ public function test_cannot_delete_provider(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @TODO: complete FTP tests
|
|
||||||
*
|
|
||||||
* @return array<int, mixed>
|
* @return array<int, mixed>
|
||||||
*/
|
*/
|
||||||
public static function createData(): array
|
public static function createData(): array
|
||||||
|
@ -21,7 +21,9 @@ public function test_install_vito_agent(): void
|
|||||||
'https://api.github.com/repos/vitodeploy/agent/tags' => Http::response([['name' => '0.1.0']]),
|
'https://api.github.com/repos/vitodeploy/agent/tags' => Http::response([['name' => '0.1.0']]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
$this->server->monitoring()->delete();
|
||||||
|
|
||||||
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'monitoring',
|
'type' => 'monitoring',
|
||||||
'name' => 'vito-agent',
|
'name' => 'vito-agent',
|
||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
@ -34,12 +36,11 @@ public function test_install_vito_agent(): void
|
|||||||
'version' => '0.1.0',
|
'version' => '0.1.0',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_install_vito_agent_failed(): void
|
public function test_install_vito_agent_failed(): void
|
||||||
{
|
{
|
||||||
|
$this->server->monitoring()->delete();
|
||||||
$this->expectExceptionMessage('Failed to fetch tags');
|
$this->expectExceptionMessage('Failed to fetch tags');
|
||||||
SSH::fake('Active: inactive');
|
SSH::fake('Active: inactive');
|
||||||
Http::fake([
|
Http::fake([
|
||||||
@ -58,7 +59,7 @@ public function test_install_nginx(): void
|
|||||||
|
|
||||||
SSH::fake('Active: active');
|
SSH::fake('Active: active');
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'webserver',
|
'type' => 'webserver',
|
||||||
'name' => 'nginx',
|
'name' => 'nginx',
|
||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
@ -71,8 +72,6 @@ public function test_install_nginx(): void
|
|||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_install_caddy(): void
|
public function test_install_caddy(): void
|
||||||
@ -81,7 +80,7 @@ public function test_install_caddy(): void
|
|||||||
|
|
||||||
SSH::fake('Active: active');
|
SSH::fake('Active: active');
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'webserver',
|
'type' => 'webserver',
|
||||||
'name' => 'caddy',
|
'name' => 'caddy',
|
||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
@ -94,8 +93,6 @@ public function test_install_caddy(): void
|
|||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_install_mysql(): void
|
public function test_install_mysql(): void
|
||||||
@ -104,7 +101,7 @@ public function test_install_mysql(): void
|
|||||||
|
|
||||||
SSH::fake('Active: active');
|
SSH::fake('Active: active');
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'database',
|
'type' => 'database',
|
||||||
'name' => 'mysql',
|
'name' => 'mysql',
|
||||||
'version' => '8.0',
|
'version' => '8.0',
|
||||||
@ -117,8 +114,6 @@ public function test_install_mysql(): void
|
|||||||
'version' => '8.0',
|
'version' => '8.0',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_install_mysql_failed(): void
|
public function test_install_mysql_failed(): void
|
||||||
@ -137,7 +132,7 @@ public function test_install_supervisor(): void
|
|||||||
|
|
||||||
SSH::fake('Active: active');
|
SSH::fake('Active: active');
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'process_manager',
|
'type' => 'process_manager',
|
||||||
'name' => 'supervisor',
|
'name' => 'supervisor',
|
||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
@ -150,8 +145,6 @@ public function test_install_supervisor(): void
|
|||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_install_redis(): void
|
public function test_install_redis(): void
|
||||||
@ -160,7 +153,7 @@ public function test_install_redis(): void
|
|||||||
|
|
||||||
SSH::fake('Active: active');
|
SSH::fake('Active: active');
|
||||||
|
|
||||||
$service = app(Install::class)->install($this->server, [
|
app(Install::class)->install($this->server, [
|
||||||
'type' => 'memory_database',
|
'type' => 'memory_database',
|
||||||
'name' => 'redis',
|
'name' => 'redis',
|
||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
@ -173,7 +166,5 @@ public function test_install_redis(): void
|
|||||||
'version' => 'latest',
|
'version' => 'latest',
|
||||||
'status' => ServiceStatus::READY,
|
'status' => ServiceStatus::READY,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertNotNull($service->type_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ public function test_uninstall_vito_agent(): void
|
|||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
|
|
||||||
Service::factory()->create([
|
$this->server->monitoring()->delete();
|
||||||
|
|
||||||
|
$service = Service::factory()->create([
|
||||||
'server_id' => $this->server->id,
|
'server_id' => $this->server->id,
|
||||||
'name' => 'vito-agent',
|
'name' => 'vito-agent',
|
||||||
'type' => 'monitoring',
|
'type' => 'monitoring',
|
||||||
@ -31,11 +33,7 @@ public function test_uninstall_vito_agent(): void
|
|||||||
app(Uninstall::class)->uninstall($this->server->monitoring());
|
app(Uninstall::class)->uninstall($this->server->monitoring());
|
||||||
|
|
||||||
$this->assertDatabaseMissing('services', [
|
$this->assertDatabaseMissing('services', [
|
||||||
'server_id' => $this->server->id,
|
'id' => $service->id,
|
||||||
'name' => 'vito-agent',
|
|
||||||
'type' => 'monitoring',
|
|
||||||
'version' => 'latest',
|
|
||||||
'status' => ServiceStatus::READY,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
class AgentTest extends TestCase
|
class AgentTest extends TestCase
|
||||||
{
|
{
|
||||||
private $operatingSystems = [
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
private array $operatingSystems = [
|
||||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'Windows',
|
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'Windows',
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2' => 'OS X',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2' => 'OS X',
|
||||||
'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3' => 'iOS',
|
'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3' => 'iOS',
|
||||||
@ -18,7 +21,10 @@ class AgentTest extends TestCase
|
|||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' => 'Windows',
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' => 'Windows',
|
||||||
];
|
];
|
||||||
|
|
||||||
private $browsers = [
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
private array $browsers = [
|
||||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'IE',
|
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'IE',
|
||||||
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25' => 'Safari',
|
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25' => 'Safari',
|
||||||
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285' => 'Netscape',
|
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285' => 'Netscape',
|
||||||
@ -36,7 +42,10 @@ class AgentTest extends TestCase
|
|||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/86.0.180 Chrome/80.0.3987.180 Safari/537.36' => 'Coc Coc',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/86.0.180 Chrome/80.0.3987.180 Safari/537.36' => 'Coc Coc',
|
||||||
];
|
];
|
||||||
|
|
||||||
private $mobileDevices = [
|
/**
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
private array $mobileDevices = [
|
||||||
'Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5',
|
'Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5',
|
||||||
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25',
|
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25',
|
||||||
'Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; HTC Desire Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
|
'Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; HTC Desire Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
|
||||||
@ -45,7 +54,10 @@ class AgentTest extends TestCase
|
|||||||
'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; ASUS Transformer Pad TF300T Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
|
'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; ASUS Transformer Pad TF300T Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
|
||||||
];
|
];
|
||||||
|
|
||||||
private $desktops = [
|
/**
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
private array $desktops = [
|
||||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
|
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
|
||||||
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
|
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
|
||||||
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285',
|
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285',
|
||||||
@ -56,7 +68,7 @@ class AgentTest extends TestCase
|
|||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function test_operating_systems()
|
public function test_operating_systems(): void
|
||||||
{
|
{
|
||||||
$agent = new Agent;
|
$agent = new Agent;
|
||||||
|
|
||||||
@ -66,7 +78,7 @@ public function test_operating_systems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_browsers()
|
public function test_browsers(): void
|
||||||
{
|
{
|
||||||
$agent = new Agent;
|
$agent = new Agent;
|
||||||
|
|
||||||
@ -76,7 +88,7 @@ public function test_browsers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_desktop_devices()
|
public function test_desktop_devices(): void
|
||||||
{
|
{
|
||||||
$agent = new Agent;
|
$agent = new Agent;
|
||||||
|
|
||||||
@ -86,7 +98,7 @@ public function test_desktop_devices()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_mobile_devices()
|
public function test_mobile_devices(): void
|
||||||
{
|
{
|
||||||
$agent = new Agent;
|
$agent = new Agent;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class ServerModelTest extends TestCase
|
|||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
public function test_should_have_default_service()
|
public function test_should_have_default_service(): void
|
||||||
{
|
{
|
||||||
$php = $this->server->defaultService('php');
|
$php = $this->server->defaultService('php');
|
||||||
$php->update(['is_default' => false]);
|
$php->update(['is_default' => false]);
|
||||||
|
@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
use App\Facades\SSH;
|
use App\Facades\SSH;
|
||||||
use App\SSH\Services\Database\Database;
|
use App\SSH\Services\Database\Database;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class GetCharsetsTest extends TestCase
|
class GetCharsetsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var array<string, array<string, string|array<string>>>
|
||||||
|
*/
|
||||||
protected static array $mysqlCharsets = [
|
protected static array $mysqlCharsets = [
|
||||||
'armscii8' => [
|
'armscii8' => [
|
||||||
'default' => 'armscii8_general_ci',
|
'default' => 'armscii8_general_ci',
|
||||||
@ -33,8 +37,9 @@ class GetCharsetsTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data
|
* @param array<string, string|array<string>> $expected
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('data')]
|
||||||
public function test_update_charsets(string $name, string $version, string $output, array $expected): void
|
public function test_update_charsets(string $name, string $version, string $output, array $expected): void
|
||||||
{
|
{
|
||||||
$database = $this->server->database();
|
$database = $this->server->database();
|
||||||
@ -52,7 +57,7 @@ public function test_update_charsets(string $name, string $version, string $outp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return array<int, array<int, mixed>>
|
||||||
*/
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
|
@ -4,13 +4,12 @@
|
|||||||
|
|
||||||
use App\Facades\SSH;
|
use App\Facades\SSH;
|
||||||
use App\SSH\Services\Database\Database;
|
use App\SSH\Services\Database\Database;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class GetDatabasesTest extends TestCase
|
class GetDatabasesTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_get_databases(string $name, string $version, string $output): void
|
public function test_get_databases(string $name, string $version, string $output): void
|
||||||
{
|
{
|
||||||
$database = $this->server->database();
|
$database = $this->server->database();
|
||||||
@ -24,12 +23,11 @@ public function test_get_databases(string $name, string $version, string $output
|
|||||||
$databaseHandler = $database->handler();
|
$databaseHandler = $database->handler();
|
||||||
$databases = $databaseHandler->getDatabases();
|
$databases = $databaseHandler->getDatabases();
|
||||||
|
|
||||||
$this->assertIsArray($databases);
|
|
||||||
$this->assertEquals('vito', $databases[0][0]);
|
$this->assertEquals('vito', $databases[0][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return array<int, array<int, mixed>>
|
||||||
*/
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
|
@ -4,13 +4,12 @@
|
|||||||
|
|
||||||
use App\Facades\SSH;
|
use App\Facades\SSH;
|
||||||
use App\SSH\Services\Database\Database;
|
use App\SSH\Services\Database\Database;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class GetUsersTest extends TestCase
|
class GetUsersTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('data')]
|
||||||
* @dataProvider data
|
|
||||||
*/
|
|
||||||
public function test_get_users(string $name, string $version, string $output): void
|
public function test_get_users(string $name, string $version, string $output): void
|
||||||
{
|
{
|
||||||
$database = $this->server->database();
|
$database = $this->server->database();
|
||||||
@ -24,12 +23,11 @@ public function test_get_users(string $name, string $version, string $output): v
|
|||||||
$databaseHandler = $database->handler();
|
$databaseHandler = $database->handler();
|
||||||
$users = $databaseHandler->getUsers();
|
$users = $databaseHandler->getUsers();
|
||||||
|
|
||||||
$this->assertIsArray($users);
|
|
||||||
$this->assertEquals('vito', $users[0][0]);
|
$this->assertEquals('vito', $users[0][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return array<int, array<int, mixed>>
|
||||||
*/
|
*/
|
||||||
public static function data(): array
|
public static function data(): array
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
use App\Models\SourceControl;
|
use App\Models\SourceControl;
|
||||||
use App\SourceControlProviders\Gitlab;
|
use App\SourceControlProviders\Gitlab;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class GitlabTest extends TestCase
|
class GitlabTest extends TestCase
|
||||||
@ -36,9 +37,7 @@ public function test_default_gitlab_repo_url(): void
|
|||||||
$this->assertSame('git@gitlab.com-TEST_KEY:test/repo.git', $gitlab->fullRepoUrl($repo, $key));
|
$this->assertSame('git@gitlab.com-TEST_KEY:test/repo.git', $gitlab->fullRepoUrl($repo, $key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('customUrlData')]
|
||||||
* @dataProvider customUrlData
|
|
||||||
*/
|
|
||||||
public function test_custom_url(string $url, string $expected): void
|
public function test_custom_url(string $url, string $expected): void
|
||||||
{
|
{
|
||||||
$sourceControlModel = SourceControl::factory()
|
$sourceControlModel = SourceControl::factory()
|
||||||
@ -50,9 +49,7 @@ public function test_custom_url(string $url, string $expected): void
|
|||||||
$this->assertSame($expected, $gitlab->getApiUrl());
|
$this->assertSame($expected, $gitlab->getApiUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('customRepoUrlData')]
|
||||||
* @dataProvider customRepoUrlData
|
|
||||||
*/
|
|
||||||
public function test_custom_full_repository_url(string $url, string $expected): void
|
public function test_custom_full_repository_url(string $url, string $expected): void
|
||||||
{
|
{
|
||||||
$repo = 'test/repo';
|
$repo = 'test/repo';
|
||||||
@ -67,6 +64,9 @@ public function test_custom_full_repository_url(string $url, string $expected):
|
|||||||
$this->assertSame($expected, $gitlab->fullRepoUrl($repo, $key));
|
$this->assertSame($expected, $gitlab->fullRepoUrl($repo, $key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<int, string>>
|
||||||
|
*/
|
||||||
public static function customRepoUrlData(): array
|
public static function customRepoUrlData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -76,6 +76,9 @@ public static function customRepoUrlData(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<int, string>>
|
||||||
|
*/
|
||||||
public static function customUrlData(): array
|
public static function customUrlData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -15,7 +15,7 @@ class S3Test extends TestCase
|
|||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
public function test_s3_connect_successful()
|
public function test_s3_connect_successful(): void
|
||||||
{
|
{
|
||||||
$storageProvider = StorageProviderModel::factory()->create([
|
$storageProvider = StorageProviderModel::factory()->create([
|
||||||
'provider' => StorageProvider::S3,
|
'provider' => StorageProvider::S3,
|
||||||
@ -59,7 +59,7 @@ public function test_s3_connect_successful()
|
|||||||
$this->assertTrue($s3->connect());
|
$this->assertTrue($s3->connect());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_s3_connect_failure()
|
public function test_s3_connect_failure(): void
|
||||||
{
|
{
|
||||||
$storageProvider = StorageProviderModel::factory()->create([
|
$storageProvider = StorageProviderModel::factory()->create([
|
||||||
'provider' => StorageProvider::S3,
|
'provider' => StorageProvider::S3,
|
||||||
|
Reference in New Issue
Block a user