feat(blog): add representation blog management features including listing, creating, and editing blogs

This commit is contained in:
hamed
2026-07-23 22:13:37 +03:30
parent 62b2f28c4f
commit dab36058a3
9 changed files with 485 additions and 86 deletions
+19
View File
@@ -109,6 +109,25 @@ class BlogV2FieldsTest extends ApiTestCase
$this->assertNotContains("مالB-$tag", $titles, "another rep's post leaked");
}
public function testRepresentativeCanGetOwnPostButNotOthers(): void
{
$yasuj = $this->makeCity('یاسوج');
$repA = $this->makeRepresentation([$yasuj]);
$repB = $this->makeRepresentation([$yasuj]);
$created = $this->authJson('POST', '/api/v1/representation/blog', $repA->getUser(), [
'title' => 'مقالهٔ A', 'body' => 'متن آزمایشی مقاله برای تست', 'city_id' => $yasuj->getId(),
]);
$uuid = $created['data']['data']['uuid'];
$own = $this->authJson('GET', "/api/v1/representation/blog/$uuid", $repA->getUser());
$this->assertSame(200, $this->responseCode());
$this->assertSame('مقالهٔ A', $own['data']['data']['title']);
$this->authJson('GET', "/api/v1/representation/blog/$uuid", $repB->getUser());
$this->assertSame(404, $this->responseCode());
}
public function testRepresentativeCannotEditOthersPost(): void
{
$yasuj = $this->makeCity('یاسوج');