businessportal24()->create(['address' => 'bags']); $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.'); });