99
1010namespace SymfonyCasts \Bundle \ResetPassword \Tests \Unit \Model ;
1111
12+ use Doctrine \DBAL \Types \Types ;
13+ use Doctrine \ORM \Mapping \Column ;
1214use PHPUnit \Framework \TestCase ;
1315use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestInterface ;
1416use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestTrait ;
@@ -26,21 +28,28 @@ public function testIsCompatibleWithInterface(): void
2628
2729 public function propertyDataProvider (): \Generator
2830 {
29- yield ['selector ' , ' @ORM\Column( type="string", length=20) ' ];
30- yield ['hashedToken ' , ' @ORM\Column( type="string", length= 100) ' ];
31- yield ['requestedAt ' , ' @ORM\Column( type="datetime_immutable") ' ];
32- yield ['expiresAt ' , ' @ORM\Column( type="datetime_immutable") ' ];
31+ yield ['selector ' , [ ' type ' => Types:: STRING , ' length ' => 20 ] ];
32+ yield ['hashedToken ' , [ ' type ' => Types:: STRING , ' length ' => 100 ] ];
33+ yield ['requestedAt ' , [ ' type ' => Types:: DATETIME_IMMUTABLE ] ];
34+ yield ['expiresAt ' , [ ' type ' => Types:: DATETIME_IMMUTABLE ] ];
3335 }
3436
3537 /**
3638 * @dataProvider propertyDataProvider
3739 */
38- public function testORMAnnotationSetOnProperty (string $ propertyName , string $ expectedAnnotation ): void
40+ public function testORMAnnotationSetOnProperty (string $ propertyName , array $ expectedAttributeProperties ): void
3941 {
4042 $ property = new \ReflectionProperty (ResetPasswordRequestTrait::class, $ propertyName );
41- $ result = $ property ->getDocComment ( );
43+ $ attributes = $ property ->getAttributes (Column::class );
4244
43- self ::assertStringContainsString ($ expectedAnnotation , $ result , sprintf ('%s::%s does not contain "%s" in the docBlock. ' , ResetPasswordRequestTrait::class, $ propertyName , $ expectedAnnotation ));
45+ self ::assertCount (1 , $ attributes );
46+
47+ foreach ($ expectedAttributeProperties as $ argumentName => $ expectedValue ) {
48+ $ attributeArguments = $ attributes [0 ]->getArguments ();
49+
50+ self ::assertArrayHasKey ($ argumentName , $ attributeArguments );
51+ self ::assertSame ($ expectedValue , $ attributeArguments [$ argumentName ]);
52+ }
4453 }
4554
4655 public function isExpiredDataProvider (): \Generator
0 commit comments