Subdomain-Cleanup-Commands
Neue Artisan-Commands DeleteAllKasSubdomains und DeletePartnerShopSubdomains zum Aufraeumen von KAS-/Partnershop-Subdomains, jeweils mit Feature-Tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9b7665c59a
commit
84238c7694
4 changed files with 677 additions and 0 deletions
113
tests/Feature/DeletePartnerShopSubdomainsCommandTest.php
Normal file
113
tests/Feature/DeletePartnerShopSubdomainsCommandTest.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Models\UserShop;
|
||||
use App\User;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Schema::dropIfExists('user_shops');
|
||||
Schema::dropIfExists('users');
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->char('lang', 2)->default('de');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('user_shops', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->string('name', 20)->unique();
|
||||
$table->string('slug', 40)->unique();
|
||||
$table->boolean('active')->default(false);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
Schema::dropIfExists('user_shops');
|
||||
Schema::dropIfExists('users');
|
||||
});
|
||||
|
||||
it('führt ohne force nur einen dry run aus', function () {
|
||||
UserShop::forceCreate([
|
||||
'user_id' => User::forceCreate([
|
||||
'email' => 'partner@example.test',
|
||||
'password' => 'secret',
|
||||
'lang' => 'de',
|
||||
])->id,
|
||||
'name' => 'Partner Shop',
|
||||
'slug' => 'partner',
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$kas = \Mockery::mock(KasController::class);
|
||||
$kas->shouldReceive('action')
|
||||
->once()
|
||||
->with('get_subdomains')
|
||||
->andReturn([
|
||||
['subdomain_name' => 'partner.mivita.care', 'subdomain_path' => '/mein.mivita.care/public/'],
|
||||
]);
|
||||
$this->app->instance(KasController::class, $kas);
|
||||
|
||||
$this->artisan('subdomains:delete-partnershops')->assertSuccessful();
|
||||
});
|
||||
|
||||
it('löscht passende partnershop subdomains mit force', function () {
|
||||
UserShop::forceCreate([
|
||||
'user_id' => User::forceCreate([
|
||||
'email' => 'shop@example.test',
|
||||
'password' => 'secret',
|
||||
'lang' => 'de',
|
||||
])->id,
|
||||
'name' => 'Shop Eins',
|
||||
'slug' => 'shop-eins',
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$kas = \Mockery::mock(KasController::class);
|
||||
$kas->shouldReceive('action')
|
||||
->once()
|
||||
->with('get_subdomains')
|
||||
->andReturn([
|
||||
['subdomain_name' => 'shop-eins.mivita.care', 'subdomain_path' => '/mein.mivita.care/public/'],
|
||||
['subdomain_name' => 'api.mivita.care', 'subdomain_path' => '/mein.mivita.care/public/'],
|
||||
['subdomain_name' => 'extern.mivita.care', 'subdomain_path' => '/andere-app/public/'],
|
||||
]);
|
||||
$kas->shouldReceive('action')
|
||||
->once()
|
||||
->with('delete_subdomain', ['subdomain_name' => 'shop-eins.mivita.care'])
|
||||
->andReturn('TRUE');
|
||||
|
||||
$this->app->instance(KasController::class, $kas);
|
||||
|
||||
$this->artisan('subdomains:delete-partnershops --force')->assertSuccessful();
|
||||
});
|
||||
|
||||
it('kann verwaiste partnershop subdomains über den kas pfad löschen', function () {
|
||||
$kas = \Mockery::mock(KasController::class);
|
||||
$kas->shouldReceive('action')
|
||||
->once()
|
||||
->with('get_subdomains')
|
||||
->andReturn([
|
||||
['subdomain_name' => 'alte-partnerin.mivita.care', 'subdomain_path' => '/mein.mivita.care/public/'],
|
||||
['subdomain_name' => 'preview.mivita.care', 'subdomain_path' => '/mein.mivita.care/public/'],
|
||||
]);
|
||||
$kas->shouldReceive('action')
|
||||
->once()
|
||||
->with('delete_subdomain', ['subdomain_name' => 'alte-partnerin.mivita.care'])
|
||||
->andReturn('TRUE');
|
||||
|
||||
$this->app->instance(KasController::class, $kas);
|
||||
|
||||
$this->artisan('subdomains:delete-partnershops --force --include-path-matches')->assertSuccessful();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue