|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\MakerBundle\Tests\Maker;
|
13 | 13 |
|
| 14 | +use Doctrine\ORM\Mapping\Driver\AttributeReader; |
14 | 15 | use Symfony\Bundle\MakerBundle\Maker\MakeResetPassword;
|
15 | 16 | use Symfony\Bundle\MakerBundle\Test\MakerTestCase;
|
16 | 17 | use Symfony\Bundle\MakerBundle\Test\MakerTestDetails;
|
@@ -159,9 +160,17 @@ public function getTestDetails()
|
159 | 160 | $this->assertStringContainsString('\'emailAddress\' => $emailFormData,', $contentResetPasswordController);
|
160 | 161 | $this->assertStringContainsString('$user->setMyPassword($encodedPassword);', $contentResetPasswordController);
|
161 | 162 | $this->assertStringContainsString('->to($user->getEmailAddress())', $contentResetPasswordController);
|
| 163 | + |
162 | 164 | // check ResetPasswordRequest
|
163 | 165 | $contentResetPasswordRequest = file_get_contents($runner->getPath('src/Entity/ResetPasswordRequest.php'));
|
164 |
| - $this->assertStringContainsString('ORM\ManyToOne(targetEntity=UserCustom::class)', $contentResetPasswordRequest); |
| 166 | + |
| 167 | + /* @legacy Drop annotation test when annotations are no longer supported. */ |
| 168 | + if ($this->useAttributes($runner)) { |
| 169 | + $this->assertStringContainsString('ORM\ManyToOne(targetEntity: UserCustom::class)', $contentResetPasswordRequest); |
| 170 | + } else { |
| 171 | + $this->assertStringContainsString('ORM\ManyToOne(targetEntity=UserCustom::class)', $contentResetPasswordRequest); |
| 172 | + } |
| 173 | + |
165 | 174 | // check ResetPasswordRequestFormType
|
166 | 175 | $contentResetPasswordRequestFormType = file_get_contents($runner->getPath('/src/Form/ResetPasswordRequestFormType.php'));
|
167 | 176 | $this->assertStringContainsString('->add(\'emailAddress\', EmailType::class, [', $contentResetPasswordRequestFormType);
|
@@ -198,4 +207,11 @@ private function makeUser(MakerTestRunner $runner, string $identifier = 'email',
|
198 | 207 | $checkPassword ? 'y' : 'n', // password
|
199 | 208 | ]);
|
200 | 209 | }
|
| 210 | + |
| 211 | + private function useAttributes(MakerTestRunner $runner): bool |
| 212 | + { |
| 213 | + return \PHP_VERSION_ID >= 80000 |
| 214 | + && $runner->doesClassExist(AttributeReader::class) |
| 215 | + && $runner->getSymfonyVersion() >= 50200; |
| 216 | + } |
201 | 217 | }
|
0 commit comments