commits('main', 10); expect($commits)->toHaveCount(3) ->and($commits[0]['subject'])->toBe('harmadik commit') ->and($commits[2]['subject'])->toBe('első commit') ->and($commits[0]['hash'])->toHaveLength(40) ->and($commits[0]['file_count'])->toBe(2) // A törzs a tárgysor nélkül jön, és nem tapad hozzá a --shortstat sora sem. ->and($commits[1]['body'])->toBe('A törzsben említett árlista részlet.') ->and($commits[0]['body'])->toBe(''); deploymentCleanup($repository['path']); }); test('a diff felismeri az új, módosult, törölt és átnevezett fájlokat', function () { $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $files = collect(app(GitRepository::class)->changedFiles($first, $third))->keyBy('path'); expect($files->get('app/Elso.php')['status'])->toBe('M') ->and($files->get('app/Regi.php')['status'])->toBe('D') ->and($files->get('app/Atnevezett.php')['status'])->toBe('R') ->and($files->get('app/Atnevezett.php')['old_path'])->toBe('app/Atnevezendo.php') // Ékezetes útvonal: core.quotePath=false nélkül "app/\303\201rlista.php" jönne vissza. ->and($files->has('app/Árlista.php'))->toBeTrue(); deploymentCleanup($repository['path']); }); test('az elemzés kizárja a tiltott fájlokat és külön kezeli a törlendőket', function () { $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $changedFiles = app(GitRepository::class)->changedFiles($first, $third); $changeSet = app(ChangeSetAnalyzer::class)->analyze($changedFiles); expect($changeSet['copied'])->toContain('app/Árlista.php', 'app/Atnevezett.php', 'app/Elso.php') ->and($changeSet['copied'])->not->toContain('.env') ->and($changeSet['counts']['excluded'])->toBe(1) // A törölt fájl mellett az átnevezés régi útvonala is törlendő a célgépen. ->and($changeSet['deleted'])->toContain('app/Regi.php', 'app/Atnevezendo.php'); $titles = collect($changeSet['warnings'])->pluck('title')->implode(' | '); expect($titles)->toContain('Migráció') ->and($titles)->toContain('Seeder') ->and($titles)->toContain('Törlendő fájl'); deploymentCleanup($repository['path']); }); test('az érvénytelen commit azonosítót nem adja tovább a gitnek', function () { $repository = deploymentTestRepository(); $git = app(GitRepository::class); expect($git->resolveCommit('../../etc/passwd'))->toBeNull() ->and($git->resolveCommit('main; rm -rf /'))->toBeNull() ->and($git->resolveCommit('HEAD'))->toBeNull() ->and($git->resolveCommit($repository['commits'][0]))->toBe($repository['commits'][0]); deploymentCleanup($repository['path']); }); test('a fordított tartomány felismerhető', function () { $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $git = app(GitRepository::class); expect($git->isAncestor($first, $third))->toBeTrue() ->and($git->isAncestor($third, $first))->toBeFalse(); deploymentCleanup($repository['path']); });