Fassung 1.7.0: verlässliche Installation, übersichtliche Verwaltung und bedienbare Bewegung
CMS quality / php (8.2) (push) Canceled after 0s
CMS quality / php (8.4) (push) Canceled after 0s
CMS quality / browser (push) Canceled after 0s
CMS quality / mysql (push) Canceled after 0s

This commit is contained in:
kantarci committed 2026-09-14 10:49:54 +02:00
1 parent b164c4edfe
commit 495b26896e
55 files changed
+1632 -423

No files matched your search

+32 -2
View File
@@ -115,6 +115,22 @@ final class UpdaterTest extends TestCase
self::assertStringContainsString('OK v1.1.0', $log[0]);
}
public function testTrackedEnvironmentFromAnOlderTagCannotReplaceInstallationSettings(): void
{
file_put_contents($this->author.'/.env', "DATABASE_URL=sqlite:///release-default.db\n");
$this->release('1.1.0', true);
$this->git(['fetch', '--tags', 'origin'], $this->work);
$this->git(['checkout', 'v1.1.0'], $this->work);
$settings = "DATABASE_URL=sqlite:///customer.db\nAPP_SECRET=customer-secret\n";
file_put_contents($this->work.'/.env', $settings);
$this->git(['update-index', '--assume-unchanged', '.env'], $this->work);
unlink($this->author.'/.env');
$this->release('1.2.0', true);
$result = $this->updater()->update();
self::assertTrue($result['ok'], $this->explain($result));
self::assertSame($settings, file_get_contents($this->work.'/.env'));
}
public function testAFailingSmokeTestRollsBackTheCodeAndTheDatabase(): void
{
// The new version ships a console that fails - as a broken release would.
@@ -126,6 +142,7 @@ final class UpdaterTest extends TestCase
$steps = array_column($result['steps'], 'step');
self::assertContains('Zurück auf den alten Stand', $steps);
self::assertContains('Datenbank zurückschreiben', $steps);
self::assertTrue($this->named($result['steps'], 'Datenbank zurückschreiben', 'step')['ok']);
// The migration is where it broke, so the database had to go back too.
self::assertSame('Migration', $this->firstFailed($result)['step']);
self::assertSame('1.0.0', $updater->version(), 'A failed update leaves the previous version installed.');
@@ -136,6 +153,16 @@ final class UpdaterTest extends TestCase
self::assertStringContainsString('FEHLER v1.2.0', $updater->log()[0]);
}
public function testAFailedDatabaseRestoreKeepsTheSiteInMaintenance(): void
{
$this->release('1.2.0', false, loseBackup: true);
$result = $this->updater()->update();
self::assertFalse($result['ok']);
self::assertFalse($this->named($result['steps'], 'Datenbank zurückschreiben', 'step')['ok']);
self::assertFileExists($this->work.'/'.Updater::MAINTENANCE_FILE);
self::assertNotContains('Wieder online', array_column($result['steps'], 'step'));
}
public function testAnUpdateThatChangesDependenciesStopsWhenComposerIsMissing(): void
{
// The installation carries the lock of 1.0.0; the new version brings a different one. On
@@ -217,7 +244,7 @@ final class UpdaterTest extends TestCase
* Publishes a release: VERSION, a .gitignore that keeps the installation out of Git, and the
* two stub commands the updater calls. `$healthy` decides whether they succeed.
*/
private function release(string $version, bool $healthy, string $lock = 'alt'): void
private function release(string $version, bool $healthy, string $lock = 'alt', bool $loseBackup = false): void
{
file_put_contents($this->author.'/composer.lock', json_encode(['packages' => [$lock]]));
file_put_contents($this->author.'/VERSION', $version."\n");
@@ -234,8 +261,11 @@ final class UpdaterTest extends TestCase
// Stubs, not the real console: this test is about the updater's order and its rollback.
$stub = $healthy
? "<?php\nfwrite(STDOUT, 'OK '.implode(' ', array_slice(\$argv, 1)).PHP_EOL);\nexit(0);\n"
: "<?php\nfwrite(STDOUT, 'Migration gescheitert'.PHP_EOL);\nexit(1);\n";
: "<?php\nfile_put_contents(__DIR__.'/../../var/cms.db', 'Unvollständige Migration');\nfwrite(STDOUT, 'Migration gescheitert'.PHP_EOL);\nexit(1);\n";
file_put_contents($this->author.'/bin/console', $healthy ? $stub : "<?php\nfwrite(STDOUT, 'OK'.PHP_EOL);\nexit(0);\n");
if ($loseBackup) {
$stub = str_replace('exit(1);', "foreach (glob(__DIR__.'/../../var/backups/update-*/cms.db') ?: [] as \$backup) { unlink(\$backup); } exit(1);", $stub);
}
file_put_contents($this->author.'/vendor/bin/doctrine-migrations', $stub);
$this->commit($this->author, 'Fassung '.$version);
$this->git(['tag', 'v'.$version], $this->author);