9
9
10
10
namespace SymfonyCasts \Bundle \ResetPassword \Tests \Unit \Model ;
11
11
12
+ use Doctrine \DBAL \Types \Types ;
13
+ use Doctrine \ORM \Mapping \Column ;
12
14
use PHPUnit \Framework \TestCase ;
13
15
use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestInterface ;
14
16
use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestTrait ;
@@ -26,21 +28,28 @@ public function testIsCompatibleWithInterface(): void
26
28
27
29
public function propertyDataProvider (): \Generator
28
30
{
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 ] ];
33
35
}
34
36
35
37
/**
36
38
* @dataProvider propertyDataProvider
37
39
*/
38
- public function testORMAnnotationSetOnProperty (string $ propertyName , string $ expectedAnnotation ): void
40
+ public function testORMAnnotationSetOnProperty (string $ propertyName , array $ expectedAttributeProperties ): void
39
41
{
40
42
$ property = new \ReflectionProperty (ResetPasswordRequestTrait::class, $ propertyName );
41
- $ result = $ property ->getDocComment ( );
43
+ $ attributes = $ property ->getAttributes (Column::class );
42
44
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
+ }
44
53
}
45
54
46
55
public function isExpiredDataProvider (): \Generator
0 commit comments