tests: Kategorie-Portal in den API-Tests festlegen
Die Kategorie-Factory würfelt das Portal; seit der Portal-Prüfung im API-Store (Audit F11) schlug 'api submitted html text is sanitized' zufällig mit 422 fehl. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
226fb8131a
commit
207f103118
5 changed files with 14 additions and 12 deletions
|
|
@ -107,7 +107,7 @@ test('a company on the other portal becomes both and the release lands on the re
|
|||
/** @var TestCase $this */
|
||||
$user = assignmentApiUser(Portal::Presseecho);
|
||||
$existing = Company::factory()->create(['email' => 'info@muster.de', 'name' => 'Muster GmbH', 'portal' => 'businessportal24']);
|
||||
$category = Category::factory()->create();
|
||||
$category = Category::factory()->create(['portal' => Portal::Both]);
|
||||
Queue::fake();
|
||||
|
||||
$id = postApiCompany();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ test('legacy press release creation uses the request domain portal over the comp
|
|||
$user = portalResolutionApiUser(Portal::Businessportal24);
|
||||
$company = Company::factory()->businessportal24()->create(['owner_user_id' => $user->id]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
$category = Category::factory()->create(['legacy_id' => 4711]);
|
||||
$category = Category::factory()->create(['portal' => Portal::Both, 'legacy_id' => 4711]);
|
||||
|
||||
config()->set('app.theme', 'presseecho');
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ test('legacy press release creation accepts an explicit portal parameter over th
|
|||
$user = portalResolutionApiUser(Portal::Businessportal24);
|
||||
$company = Company::factory()->businessportal24()->create(['owner_user_id' => $user->id]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
$category = Category::factory()->create(['legacy_id' => 4712]);
|
||||
$category = Category::factory()->create(['portal' => Portal::Both, 'legacy_id' => 4712]);
|
||||
|
||||
config()->set('app.theme', 'businessportal24');
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ test('legacy press release creation falls back to the company portal without dom
|
|||
$user = portalResolutionApiUser(Portal::Businessportal24);
|
||||
$company = Company::factory()->businessportal24()->create(['owner_user_id' => $user->id]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
$category = Category::factory()->create(['legacy_id' => 4713]);
|
||||
$category = Category::factory()->create(['portal' => Portal::Both, 'legacy_id' => 4713]);
|
||||
|
||||
config()->set('app.theme', 'portal');
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ test('v1 press release creation resolves the portal from parameter and domain',
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->businessportal24()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']);
|
||||
|
|
@ -176,7 +176,7 @@ test('v1 press release creation rejects the portal value both', function () {
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->businessportal24()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\NewsletterSubscription;
|
||||
|
|
@ -37,7 +38,7 @@ test('api user can read only own companies', function () {
|
|||
test('api user can list categories with press release read ability', function () {
|
||||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
Category::factory()->withTranslations()->create();
|
||||
Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read']);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ test('api user can create list update and delete own press releases', function (
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']);
|
||||
|
|
@ -59,7 +59,7 @@ test('api submitted html text is sanitized before persistence', function () {
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']);
|
||||
|
|
@ -85,7 +85,7 @@ test('api write ability is required to create press releases', function () {
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:read']);
|
||||
|
|
@ -131,7 +131,7 @@ test('a soft deleted company is neither listed nor usable for new press releases
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->presseecho()->create(['name' => 'Geloeschte Firma']);
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
$company->delete();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Enums\PressReleaseStatus;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
|
|
@ -15,7 +16,7 @@ test('api create always produces a draft and ignores any status input', function
|
|||
/** @var TestCase $this */
|
||||
$user = User::factory()->create();
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$category = Category::factory()->withTranslations()->create();
|
||||
$category = Category::factory()->withTranslations()->create(['portal' => Portal::Both]);
|
||||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
Sanctum::actingAs($user, ['press-releases:write']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue