feat(blog): allow ROLE_IMPORTER to create drafts and access review queue

This commit is contained in:
hamed
2026-07-24 20:19:25 +03:30
parent c729bb13e0
commit 1a9eda3576
3 changed files with 72 additions and 8 deletions
+40
View File
@@ -52,6 +52,46 @@ class BlogReviewGateTest extends ApiTestCase
$this->assertSame(403, $this->responseCode());
}
public function testReviewQueueIsReadableByImporter(): void
{
// پنل کرالر با کاربر سیستمیِ ROLE_IMPORTER لاگین می‌کند؛ بدون این، صف
// همیشه «review-queue failed (403)» می‌داد.
$importer = $this->createUser(['ROLE_IMPORTER']);
$this->authJson('GET', '/api/v1/admin/blog/review-queue', $importer);
$this->assertSame(200, $this->responseCode());
}
// ── who may create a draft ────────────────────────────────────────────────
public function testImporterCreatesDraftForcedIntoTheReviewGate(): void
{
$importer = $this->createUser(['ROLE_IMPORTER']);
$res = $this->authJson('POST', '/api/v1/blog', $importer, [
'title' => 'مقاله خط تولید ' . bin2hex(random_bytes(3)),
'body' => 'متن آزمایشی مقاله برای تست',
'topic_slug' => 'importer-' . bin2hex(random_bytes(4)),
// تلاش برای انتشار مستقیم — باید نادیده گرفته شود
'status' => Blog::STATUS_PUBLISHED,
'review_status' => Blog::REVIEW_APPROVED,
]);
$this->assertSame(201, $this->responseCode());
$this->assertSame(Blog::STATUS_DRAFT, $res['data']['data']['status'],
'importer must never publish directly');
$this->assertSame(Blog::REVIEW_PENDING, $res['data']['data']['review_status'],
'importer draft must enter the doctor review gate');
}
public function testPlainUserCannotCreateBlog(): void
{
$user = $this->createUser(['ROLE_USER']);
$this->authJson('POST', '/api/v1/blog', $user, [
'title' => 'عنوان', 'body' => 'متن آزمایشی مقاله برای تست',
]);
$this->assertSame(403, $this->responseCode());
}
// ── approve ───────────────────────────────────────────────────────────────
public function testApprovePublishesAndRecordsReviewer(): void