This commit is contained in:
Bozhidar 2024-05-14 18:21:05 +03:00
parent af083890df
commit 333fb1e45f
2 changed files with 33 additions and 28 deletions

View file

@ -2,10 +2,42 @@
namespace tests\Unit;
class AutoInstallPanelTest extends ActionTestCase
use App\Installers\Server\Applications\PHPInstaller;
use App\SupportedApplicationTypes;
use Illuminate\Support\Str;
use Tests\TestCase;
class AutoInstallPanelTest extends TestCase
{
public function testInstall()
{
$this->assertTrue(Str::contains(php_uname(),'Ubuntu'));
//
// Make Apache+PHP Application Server with all supported php versions and modules
$installLogFilePath = storage_path('install-apache-php-log-unit-test.txt');
$phpInstaller = new PHPInstaller();
$phpInstaller->setPHPVersions(array_keys(SupportedApplicationTypes::getPHPVersions()));
$phpInstaller->setPHPModules(array_keys(SupportedApplicationTypes::getPHPModules()));
$phpInstaller->setLogFilePath($installLogFilePath);
$phpInstaller->install();
$installationSuccess = false;
for ($i = 1; $i <= 100; $i++) {
$logContent = file_get_contents($installLogFilePath);
if (str_contains($logContent, 'All packages installed successfully!')) {
$installationSuccess = true;
break;
}
sleep(3);
}
if (!$installationSuccess) {
$logContent = file_get_contents($installLogFilePath);
$this->fail('Apache+PHP installation failed. Log: '.$logContent);
}
$this->assertTrue($installationSuccess, 'Apache+PHP installation failed');
}
}

View file

@ -41,33 +41,6 @@ class HostingSubscriptionCreateTest extends ActionTestCase
function test_create()
{
$this->assertTrue(Str::contains(php_uname(),'Ubuntu'));
//
// Make Apache+PHP Application Server with all supported php versions and modules
$installLogFilePath = storage_path('install-apache-php-log-unit-test.txt');
$phpInstaller = new PHPInstaller();
$phpInstaller->setPHPVersions(array_keys(SupportedApplicationTypes::getPHPVersions()));
$phpInstaller->setPHPModules(array_keys(SupportedApplicationTypes::getPHPModules()));
$phpInstaller->setLogFilePath($installLogFilePath);
$phpInstaller->install();
$installationSuccess = false;
for ($i = 1; $i <= 100; $i++) {
$logContent = file_get_contents($installLogFilePath);
if (str_contains($logContent, 'All packages installed successfully!')) {
$installationSuccess = true;
break;
}
sleep(3);
}
if (!$installationSuccess) {
$logContent = file_get_contents($installLogFilePath);
$this->fail('Apache+PHP installation failed. Log: '.$logContent);
}
$this->assertTrue($installationSuccess, 'Apache+PHP installation failed');
// Make unauthorized call
$callUnauthorizedResponse = $this->callRouteAction('api.hosting-subscriptions.store')->json();
$this->assertArrayHasKey('error', $callUnauthorizedResponse);