companies: Befehl zum Deaktivieren der Legacy-Linkspam-Registrierungen
4.391 aktive Firmen (2010-2022) tragen bbcode-/HTML-Linkspam in den Stammdaten und haben nie eine Meldung veroeffentlicht. Sie werden deaktiviert, nicht geloescht; IDs landen in storage/app, Besitzerkonten bleiben unangetastet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8ea5e52c84
commit
8cd76df0bb
3 changed files with 161 additions and 0 deletions
45
tests/Feature/RetireLinkSpamCompaniesTest.php
Normal file
45
tests/Feature/RetireLinkSpamCompaniesTest.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Legacy-Registrierungen mit bbcode-/HTML-Linkspam werden deaktiviert —
|
||||
* nur ohne veröffentlichte Meldung, nie gelöscht (17.09.2026).
|
||||
*/
|
||||
test('link spam companies without a published release are deactivated, the rest stays', function () {
|
||||
/** @var TestCase $this */
|
||||
Storage::fake('local');
|
||||
|
||||
$spam = Company::factory()->businessportal24()->create(['address' => '<strong><a href="http://www.outlet.example/">bags</a></strong>']);
|
||||
$bbcode = Company::factory()->presseecho()->create(['boilerplate' => '[b][url=http://www.copy.example]replica[/url][/b]']);
|
||||
$publicWithSpam = Company::factory()->businessportal24()->create(['address' => '[url=http://www.x.example]x[/url]']);
|
||||
PressRelease::factory()->published()->forPortal(Portal::Businessportal24)->create(['company_id' => $publicWithSpam->id]);
|
||||
$clean = Company::factory()->businessportal24()->create(['address' => 'Musterstraße 1, 12345 Musterstadt']);
|
||||
|
||||
$this->artisan('companies:retire-link-spam', ['--dry-run' => true])
|
||||
->expectsOutputToContain('[Dry-Run] 2 Firmen würden deaktiviert')
|
||||
->assertSuccessful();
|
||||
|
||||
expect($spam->fresh()->is_active)->toBeTrue();
|
||||
|
||||
$this->artisan('companies:retire-link-spam')
|
||||
->expectsOutputToContain('2 Firmen deaktiviert.')
|
||||
->assertSuccessful();
|
||||
|
||||
expect($spam->fresh()->is_active)->toBeFalse()
|
||||
->and($bbcode->fresh()->is_active)->toBeFalse()
|
||||
->and($publicWithSpam->fresh()->is_active)->toBeTrue()
|
||||
->and($clean->fresh()->is_active)->toBeTrue()
|
||||
->and($spam->fresh()->deleted_at)->toBeNull();
|
||||
|
||||
$files = Storage::disk('local')->files();
|
||||
expect($files)->toHaveCount(1)
|
||||
->and(Storage::disk('local')->get($files[0]))->toBe($spam->id."\n".$bbcode->id);
|
||||
|
||||
// Zweiter Lauf findet nichts mehr.
|
||||
$this->artisan('companies:retire-link-spam')->expectsOutputToContain('Keine Linkspam-Firmen gefunden.');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue