snapshot of https://github.com/espocrm/espocrm.git (master, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 2s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 0s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-18 04:19:15 +05:00
commit 7cc7e6b4f3
10077 changed files with 900756 additions and 0 deletions

View File

@@ -0,0 +1,191 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace tests\unit\Espo\Core\Upgrades\Migration;
use Espo\Core\Console\IO;
use Espo\Core\DataManager;
use Espo\Core\Upgrades\Migration\ExtractedStepsProvider;
use Espo\Core\Upgrades\Migration\Runner;
use Espo\Core\Upgrades\Migration\StepRunner;
use Espo\Core\Upgrades\Migration\VersionDataProvider;
use Espo\Core\Utils\Config\ConfigWriter;
use PHPUnit\Framework\TestCase;
class RunnerTest extends TestCase
{
protected ?IO $io = null;
protected ?ExtractedStepsProvider $stepsProvider = null;
protected ?VersionDataProvider $versionDataProvider;
protected ?StepRunner $stepsRunner = null;
protected ?DataManager $dataManager = null;
protected ?ConfigWriter $configWriter = null;
protected function setUp(): void
{
$this->io = $this->createMock(IO::class);
$this->stepsProvider = $this->createMock(ExtractedStepsProvider::class);
$this->versionDataProvider = $this->createMock(VersionDataProvider::class);
$this->stepsRunner = $this->createMock(StepRunner::class);
$this->dataManager = $this->createMock(DataManager::class);
$this->configWriter = $this->createMock(ConfigWriter::class);
}
public function testRunMigration(): void
{
$this->versionDataProvider
->expects($this->once())
->method('getTargetVersion')
->willReturn('8.3.5');
$this->versionDataProvider
->expects($this->once())
->method('getPreviousVersion')
->willReturn('8.0.4');
$this->stepsProvider
->expects($this->once())
->method('getPrepare')
->willReturn([
'8.2',
'8.3',
]);
$this->stepsProvider
->expects($this->once())
->method('getAfterUpgrade')
->willReturn([
'8.1',
'8.3',
]);
$this->stepsRunner
->expects($this->any())
->method('runPrepare')
->willReturnMap([
['8.2', true],
['8.3', true],
]);
$this->stepsRunner
->expects($this->any())
->method('runAfterUpgrade')
->willReturnMap([
['8.1', true],
['8.3', true],
]);
$runner = new Runner(
$this->stepsProvider,
$this->versionDataProvider,
$this->stepsRunner,
$this->dataManager,
$this->configWriter
);
/** @noinspection PhpUnhandledExceptionInspection */
$runner->run($this->io);
}
public function testRunNoMigration(): void
{
$this->versionDataProvider
->expects($this->once())
->method('getTargetVersion')
->willReturn('9.3.4');
$this->versionDataProvider
->expects($this->once())
->method('getPreviousVersion')
->willReturn('9.2.7');
$this->stepsRunner
->expects($this->never())
->method('runPrepare');
$this->stepsRunner
->expects($this->never())
->method('runAfterUpgrade');
$this->configWriter
->expects($this->once())
->method('set')
->with('version', '9.3.4');
$runner = new Runner(
$this->stepsProvider,
$this->versionDataProvider,
$this->stepsRunner,
$this->dataManager,
$this->configWriter
);
/** @noinspection PhpUnhandledExceptionInspection */
$runner->run($this->io);
}
public function testRunSameVersion(): void
{
$this->versionDataProvider
->expects($this->once())
->method('getTargetVersion')
->willReturn('9.3.4');
$this->versionDataProvider
->expects($this->once())
->method('getPreviousVersion')
->willReturn('9.3.4');
$this->stepsRunner
->expects($this->never())
->method('runPrepare');
$this->stepsRunner
->expects($this->never())
->method('runAfterUpgrade');
$this->configWriter
->expects($this->never())
->method('set');
$runner = new Runner(
$this->stepsProvider,
$this->versionDataProvider,
$this->stepsRunner,
$this->dataManager,
$this->configWriter
);
/** @noinspection PhpUnhandledExceptionInspection */
$runner->run($this->io);
}
}

View File

@@ -0,0 +1,62 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace tests\unit\Espo\Core\Upgrades\Migration;
use Espo\Core\Upgrades\Migration\StepsProvider;
use Espo\Core\Utils\File\Manager;
use PHPUnit\Framework\TestCase;
class StepsProviderTest extends TestCase
{
public function testGet1(): void
{
$fileManager = $this->createMock(Manager::class);
$fileManager
->expects($this->once())
->method('getDirList')
->willReturn(['V7_5_1', 'V8_0', 'V8_1', 'V8_2', 'V8_2_2']);
$fileManager
->expects($this->any())
->method('isFile')
->willReturn(true);
$provider = new StepsProvider($fileManager);
$this->assertEquals([
'7.5.1',
'8.0',
'8.1',
'8.2',
'8.2.2',
], $provider->getAfterUpgrade());
}
}

View File

@@ -0,0 +1,271 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace tests\unit\Espo\Core\Upgrades\Migration;
use Espo\Core\Upgrades\Migration\VersionUtil;
use PHPUnit\Framework\TestCase;
class VersionUtilTest extends TestCase
{
public function testStepToVersion(): void
{
$this->assertEquals('8.0.0', VersionUtil::stepToVersion('8.0'));
$this->assertEquals('8.0.1', VersionUtil::stepToVersion('8.0.1'));
$this->assertEquals('8.1.0', VersionUtil::stepToVersion('8.1.0'));
}
public function testGet1(): void
{
$list = VersionUtil::extractSteps('8.0.0', '8.3.0', [
'7.0',
'7.5',
'8.0',
'8.0.1',
'8.0.3',
'8.1',
'8.1.4',
'8.3',
'8.3.1',
]);
$this->assertEquals([
'8.0.1',
'8.0.3',
'8.1',
'8.3',
], $list);
}
public function testGet2(): void
{
$list = VersionUtil::extractSteps('8.0.0', '8.3.1', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.1',
]);
$this->assertEquals([
'8.1',
'8.3',
], $list);
}
public function testGet3(): void
{
$list = VersionUtil::extractSteps('8.0.0', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
]);
$this->assertEquals([
'8.1',
'8.3',
], $list);
}
public function testGet4(): void
{
$list = VersionUtil::extractSteps('8.2.0', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
]);
$this->assertEquals([
'8.3',
], $list);
}
public function testGet5(): void
{
$list = VersionUtil::extractSteps('8.0.4', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
]);
$this->assertEquals([
'8.1',
'8.3',
], $list);
}
public function testGetMajor1(): void
{
$list = VersionUtil::extractSteps('7.5.4', '8.3.5', array_reverse([
'7.0',
'7.5',
'7.5.1',
'7.6',
'7.6.1',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
]));
$this->assertEquals([
'7.6',
'8.0',
'8.1',
'8.3',
], $list);
}
public function testGetPatch1(): void
{
$list = VersionUtil::extractSteps('8.3.0', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
'8.3.4',
]);
$this->assertEquals([
'8.3.2',
'8.3.4',
], $list);
}
public function testGetPatch2(): void
{
$list = VersionUtil::extractSteps('8.3.0', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
'8.3.4',
'8.3.5',
'8.6.1',
]);
$this->assertEquals([
'8.3.2',
'8.3.4',
'8.3.5',
], $list);
}
public function testGetPatch3(): void
{
$list = VersionUtil::extractSteps('8.3.0', '8.3.5', [
'8.3',
'8.3.0-beta',
'8.3.0-beta.1',
'8.3.0-beta.2',
'8.3.2',
'8.3.4',
'8.3.5',
'8.6.1',
]);
$this->assertEquals([
'8.3.2',
'8.3.4',
'8.3.5',
], $list);
}
public function testGetPatch4(): void
{
$list = VersionUtil::extractSteps('8.3.0-beta.1', '8.3.0', [
'8.3',
'8.3.0-beta.1',
'8.3.0-beta.2',
'8.3.0',
]);
$this->assertEquals([
'8.3.0-beta.2',
'8.3.0',
], $list);
}
public function testGetSame1(): void
{
$list = VersionUtil::extractSteps('8.3.5', '8.3.5', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
'8.3.4',
'8.3.5',
'8.6.1',
]);
$this->assertEquals([], $list);
}
public function testGetSame2(): void
{
$list = VersionUtil::extractSteps('8.6.1', '8.6.1', [
'7.0',
'7.5',
'8.0',
'8.1',
'8.1.4',
'8.3',
'8.3.2',
'8.3.4',
'8.3.5',
'8.6.1',
]);
$this->assertEquals([], $list);
}
}