55namespace Cycle \ORM \Entity \Behavior \Tests \Functional \Driver \Common \Schema ;
66
77use Cycle \Database \ColumnInterface ;
8+ use Cycle \ORM \Entity \Behavior \Exception \BehaviorCompilationException ;
89use Cycle \ORM \Entity \Behavior \Schema \RegistryModifier ;
910use Cycle \ORM \Entity \Behavior \Tests \Fixtures \CustomTypecast ;
1011use Cycle \ORM \Entity \Behavior \Tests \Functional \Driver \Common \BaseTest ;
@@ -57,6 +58,28 @@ public function testAddIntegerField(): void
5758 $ this ->assertSame ('version_int ' , $ fields ->get ('version ' )->getColumn ());
5859 }
5960
61+ public function testAddBigIntegerField (): void
62+ {
63+ $ this ->modifier ->addBigIntegerColumn ('snowflake_column ' , 'snowflake ' );
64+
65+ $ entity = $ this ->registry ->getEntity (self ::ROLE_TEST );
66+ $ fields = $ entity ->getFields ();
67+
68+ $ this ->assertTrue ($ fields ->has ('snowflake ' ));
69+ $ this ->assertSame ('bigInteger ' , $ fields ->get ('snowflake ' )->getType ());
70+ $ this ->assertSame ('snowflake_column ' , $ fields ->get ('snowflake ' )->getColumn ());
71+ }
72+
73+ public function testAddBigIntegerFieldThrowsException (): void
74+ {
75+ $ this ->modifier ->addIntegerColumn ('snowflake_column ' , 'snowflake ' );
76+
77+ $ this ->expectException (BehaviorCompilationException::class);
78+ $ this ->expectExceptionMessage ('Field snowflake must be of type big integer. ' );
79+
80+ $ this ->modifier ->addBigIntegerColumn ('snowflake_column ' , 'snowflake ' );
81+ }
82+
6083 public function testAddUuidField (): void
6184 {
6285 $ this ->modifier ->addUuidColumn ('uuid_column ' , 'uuid ' );
@@ -73,15 +96,19 @@ public function testAddTypecast(): void
7396 {
7497 $ this ->modifier ->addUuidColumn ('uuid_column ' , 'uuid ' );
7598 $ this ->modifier ->addIntegerColumn ('counter_column ' , 'counter ' );
99+ $ this ->modifier ->addBigIntegerColumn ('snowflake_column ' , 'snowflake ' );
76100 $ field1 = $ this ->registry ->getEntity (self ::ROLE_TEST )->getFields ()->get ('uuid ' );
77101 $ field2 = $ this ->registry ->getEntity (self ::ROLE_TEST )->getFields ()->get ('counter ' );
102+ $ field3 = $ this ->registry ->getEntity (self ::ROLE_TEST )->getFields ()->get ('snowflake ' );
78103
79104 $ this ->modifier ->setTypecast ($ field1 , [Uuid::class, 'fromString ' ]);
80105 $ this ->modifier ->setTypecast ($ field2 , 'int ' , CustomTypecast::class);
106+ $ this ->modifier ->setTypecast ($ field3 , 'int ' , CustomTypecast::class);
81107
82108 // field has custom UUID typecast
83109 $ this ->assertSame ([Uuid::class, 'fromString ' ], $ field1 ->getTypecast ());
84110 $ this ->assertSame ('int ' , $ field2 ->getTypecast ());
111+ $ this ->assertSame ('int ' , $ field3 ->getTypecast ());
85112
86113 // entity has default typecast
87114 $ this ->assertSame (
0 commit comments