feat(tests): update topic slug generation for blog identifier resolution tests
This commit is contained in:
@@ -53,10 +53,13 @@ class BlogIdentifierResolutionTest extends ApiTestCase
|
|||||||
public function testResolvesByTopicSlug(): void
|
public function testResolvesByTopicSlug(): void
|
||||||
{
|
{
|
||||||
$blog = $this->makePublished('راهنمای تشخیص آلرژی دارویی');
|
$blog = $this->makePublished('راهنمای تشخیص آلرژی دارویی');
|
||||||
$blog->setTopicSlug('allergy-immunology-symptoms-901');
|
// یکتا بهازای هر اجرا: topic_slug ستون unique است و دیتابیس تست بین
|
||||||
|
// اجراها پاک نمیشود.
|
||||||
|
$topicSlug = 'topic-' . substr($blog->getUuid(), 0, 8);
|
||||||
|
$blog->setTopicSlug($topicSlug);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
$body = $this->fetch('allergy-immunology-symptoms-901');
|
$body = $this->fetch($topicSlug);
|
||||||
|
|
||||||
$this->assertSame(200, $this->responseCode());
|
$this->assertSame(200, $this->responseCode());
|
||||||
$this->assertSame($blog->getSlug(), $body['data']['data']['slug']);
|
$this->assertSame($blog->getSlug(), $body['data']['data']['slug']);
|
||||||
@@ -96,11 +99,11 @@ class BlogIdentifierResolutionTest extends ApiTestCase
|
|||||||
public function testDraftStaysHiddenEvenThroughFallbackIdentifiers(): void
|
public function testDraftStaysHiddenEvenThroughFallbackIdentifiers(): void
|
||||||
{
|
{
|
||||||
$blog = new Blog($this->createUser(['ROLE_ADMIN']), 'پیشنویس منتشرنشده', 'متن آزمایشی مقاله برای تست');
|
$blog = new Blog($this->createUser(['ROLE_ADMIN']), 'پیشنویس منتشرنشده', 'متن آزمایشی مقاله برای تست');
|
||||||
$blog->setTopicSlug('draft-topic-901');
|
$blog->setTopicSlug('draft-topic-' . bin2hex(random_bytes(4)));
|
||||||
$this->em->persist($blog);
|
$this->em->persist($blog);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
$this->fetch('draft-topic-901');
|
$this->fetch($blog->getTopicSlug());
|
||||||
$this->assertSame(404, $this->responseCode());
|
$this->assertSame(404, $this->responseCode());
|
||||||
|
|
||||||
$this->fetch($blog->getUuid());
|
$this->fetch($blog->getUuid());
|
||||||
|
|||||||
Reference in New Issue
Block a user