44
55namespace Tests \Unit \MartinGeorgiev \Doctrine \DBAL \Types ;
66
7+ use Doctrine \DBAL \ParameterType ;
8+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
79use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
810use MartinGeorgiev \Doctrine \DBAL \Types \Exceptions \InvalidLtreeForDatabaseException ;
911use MartinGeorgiev \Doctrine \DBAL \Types \Exceptions \InvalidLtreeForPHPException ;
1618
1719final class LtreeTest extends TestCase
1820{
19- /**
20- * @var MockObject&PostgreSQLPlatform
21- */
22- private MockObject $ platform ;
21+ private MockObject &PostgreSQLPlatform $ platform ;
2322
2423 private Ltree $ fixture ;
2524
@@ -33,14 +32,29 @@ protected function setUp(): void
3332 #[Test]
3433 public function has_name (): void
3534 {
36- self ::assertEquals ('ltree ' , $ this ->fixture ->getName ());
35+ self ::assertSame ('ltree ' , $ this ->fixture ->getName ());
36+ }
37+
38+ public function test_get_sql_declaration (): void
39+ {
40+ self ::assertSame ('ltree ' , $ this ->fixture ->getSQLDeclaration ([], $ this ->platform ));
41+ }
42+
43+ public function test_get_binding_type (): void
44+ {
45+ self ::assertSame (ParameterType::STRING , $ this ->fixture ->getBindingType ());
46+ }
47+
48+ public function test_get_mapped_database_types (): void
49+ {
50+ self ::assertSame (['ltree ' ], $ this ->fixture ->getMappedDatabaseTypes ($ this ->platform ));
3751 }
3852
3953 #[DataProvider('provideValidTransformations ' )]
4054 #[Test]
4155 public function can_transform_from_php_value (?LtreeValueObject $ ltreeValueObject , ?string $ postgresValue ): void
4256 {
43- self ::assertEquals ($ postgresValue , $ this ->fixture ->convertToDatabaseValue ($ ltreeValueObject , $ this ->platform ));
57+ self ::assertSame ($ postgresValue , $ this ->fixture ->convertToDatabaseValue ($ ltreeValueObject , $ this ->platform ));
4458 }
4559
4660 #[DataProvider('provideValidTransformations ' )]
@@ -120,4 +134,25 @@ public static function provideInvalidPHPValueInputs(): array
120134 'object input ' => [new \stdClass ()],
121135 ];
122136 }
137+
138+ public function test_get_sql_declaration_throws_on_non_postgresql_platform (): void
139+ {
140+ $ this ->expectException (\LogicException::class);
141+ $ this ->fixture ->getSQLDeclaration ([], self ::createStub (AbstractPlatform::class));
142+ }
143+
144+ public function test_convert_to_database_value_throws_on_non_postgresql_platform (): void
145+ {
146+ $ this ->expectException (\LogicException::class);
147+ $ this ->fixture ->convertToDatabaseValue (
148+ new LtreeValueObject (['valid ' , 'ltree ' ]),
149+ self ::createStub (AbstractPlatform::class),
150+ );
151+ }
152+
153+ public function test_convert_to_php_value_throws_on_non_postgresql_platform (): void
154+ {
155+ $ this ->expectException (\LogicException::class);
156+ $ this ->fixture ->convertToPHPValue ('valid.ltree ' , self ::createStub (AbstractPlatform::class));
157+ }
123158}
0 commit comments