client->request( 'POST', '/api/v1/pre-registration', server: ['CONTENT_TYPE' => 'application/json'], content: json_encode(['type' => 'independent_doctor', 'name' => $name, 'mobile' => $mobile]), ); return json_decode($this->client->getResponse()->getContent(), true) ?? []; } private function storedName(string $mobile): ?string { $this->em->clear(); $preReg = $this->em->getRepository(PreRegistration::class)->findOneBy(['mobile' => $mobile]); return $preReg?->getName(); } public function testTitleIsStrippedOnSubmit(): void { $mobile = $this->freshMobile(); $this->submit('دکتر حامد حسینی', $mobile); self::assertSame(201, $this->responseCode()); self::assertSame('حامد حسینی', $this->storedName($mobile)); } public function testPlainNameIsLeftAlone(): void { $mobile = $this->freshMobile(); $this->submit('حامد حسینی', $mobile); self::assertSame(201, $this->responseCode()); self::assertSame('حامد حسینی', $this->storedName($mobile)); } public function testRepeatedTitlePrefixIsCollapsed(): void { $mobile = $this->freshMobile(); $this->submit('دکتر دکتر حامد حسینی', $mobile); self::assertSame(201, $this->responseCode()); self::assertSame('حامد حسینی', $this->storedName($mobile)); } }