mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 17:02:34 +00:00
#591 - php
This commit is contained in:
@ -6,67 +6,13 @@
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Service;
|
||||
use App\Web\Pages\Servers\PHP\Index;
|
||||
use App\Web\Pages\Servers\PHP\Widgets\PHPList;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PHPTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_install_new_php(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(Index::class, ['server' => $this->server])
|
||||
->callAction('install', [
|
||||
'version' => '8.1',
|
||||
])
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => $this->server->id,
|
||||
'type' => 'php',
|
||||
'version' => '8.1',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_uninstall_php(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$php = new Service([
|
||||
'server_id' => $this->server->id,
|
||||
'type' => 'php',
|
||||
'type_data' => [
|
||||
'extensions' => [],
|
||||
'settings' => config('core.php_settings'),
|
||||
],
|
||||
'name' => 'php',
|
||||
'version' => '8.1',
|
||||
'status' => ServiceStatus::READY,
|
||||
'is_default' => true,
|
||||
]);
|
||||
$php->save();
|
||||
|
||||
Livewire::test(PHPList::class, [
|
||||
'server' => $this->server,
|
||||
])
|
||||
->callTableAction('uninstall', $php->id)
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseMissing('services', [
|
||||
'id' => $php->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_change_default_php_cli(): void
|
||||
{
|
||||
SSH::fake();
|
||||
@ -85,11 +31,13 @@ public function test_change_default_php_cli(): void
|
||||
'is_default' => false,
|
||||
]);
|
||||
|
||||
Livewire::test(PHPList::class, [
|
||||
$this->post(route('php.default-cli', [
|
||||
'server' => $this->server,
|
||||
'service' => $php->id,
|
||||
]), [
|
||||
'version' => '8.1',
|
||||
])
|
||||
->callTableAction('default-php-cli', $php->id)
|
||||
->assertSuccessful();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$php->refresh();
|
||||
|
||||
@ -102,17 +50,18 @@ public function test_install_extension(): void
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(PHPList::class, [
|
||||
'server' => $this->server,
|
||||
])
|
||||
->callTableAction('install-extension', $this->server->php()->id, [
|
||||
'extension' => 'gmp',
|
||||
])
|
||||
->assertSuccessful();
|
||||
|
||||
$php = $this->server->php('8.2');
|
||||
|
||||
$this->assertContains('gmp', $php->type_data['extensions']);
|
||||
$this->post(route('php.install-extension', [
|
||||
'server' => $this->server,
|
||||
'service' => $php->id,
|
||||
]), [
|
||||
'version' => '8.2',
|
||||
'extension' => 'gmp',
|
||||
])
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertContains('gmp', $php->refresh()->type_data['extensions']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,15 +73,20 @@ public function test_get_php_ini(string $version, string $type): void
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(PHPList::class, [
|
||||
$php = $this->server->php('8.2');
|
||||
|
||||
$this->get(route('php.ini', [
|
||||
'server' => $this->server,
|
||||
])
|
||||
->callTableAction('php-ini-'.$type, $this->server->php()->id, [
|
||||
'ini' => 'new-ini',
|
||||
])
|
||||
->assertSuccessful();
|
||||
'service' => $php->id,
|
||||
'version' => '8.2',
|
||||
'type' => $type,
|
||||
]))
|
||||
->assertSessionDoesntHaveErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array<int, string>>
|
||||
*/
|
||||
public static function php_ini_data(): array
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user