@@ -595,6 +595,7 @@ public function testCreateNamedParameter()
595595
596596 $ this ->assertEquals ('SELECT u.* FROM users u WHERE u.name = :dcValue1 ' , (string )$ qb );
597597 $ this ->assertEquals (10 , $ qb ->getParameter ('dcValue1 ' ));
598+ $ this ->assertEquals (\PDO ::PARAM_INT , $ qb ->getParameterType ('dcValue1 ' ));
598599 }
599600
600601 public function testCreateNamedParameterCustomPlaceholder ()
@@ -607,6 +608,7 @@ public function testCreateNamedParameterCustomPlaceholder()
607608
608609 $ this ->assertEquals ('SELECT u.* FROM users u WHERE u.name = :test ' , (string )$ qb );
609610 $ this ->assertEquals (10 , $ qb ->getParameter ('test ' ));
611+ $ this ->assertEquals (\PDO ::PARAM_INT , $ qb ->getParameterType ('test ' ));
610612 }
611613
612614 public function testCreatePositionalParameter ()
@@ -619,6 +621,7 @@ public function testCreatePositionalParameter()
619621
620622 $ this ->assertEquals ('SELECT u.* FROM users u WHERE u.name = ? ' , (string )$ qb );
621623 $ this ->assertEquals (10 , $ qb ->getParameter (1 ));
624+ $ this ->assertEquals (\PDO ::PARAM_INT , $ qb ->getParameterType (1 ));
622625 }
623626
624627 /**
@@ -763,4 +766,49 @@ public function testSelectAllWithoutTableAlias()
763766
764767 $ this ->assertEquals ("SELECT * FROM users " , (string ) $ qb );
765768 }
769+
770+ /**
771+ * @group DBAL-959
772+ */
773+ public function testGetParameterType ()
774+ {
775+ $ qb = new QueryBuilder ($ this ->conn );
776+
777+ $ qb ->select ('* ' )->from ('users ' );
778+
779+ $ this ->assertNull ($ qb ->getParameterType ('name ' ));
780+
781+ $ qb ->where ('name = :name ' );
782+ $ qb ->setParameter ('name ' , 'foo ' );
783+
784+ $ this ->assertNull ($ qb ->getParameterType ('name ' ));
785+
786+ $ qb ->setParameter ('name ' , 'foo ' , \PDO ::PARAM_STR );
787+
788+ $ this ->assertSame (\PDO ::PARAM_STR , $ qb ->getParameterType ('name ' ));
789+ }
790+
791+ /**
792+ * @group DBAL-959
793+ */
794+ public function testGetParameterTypes ()
795+ {
796+ $ qb = new QueryBuilder ($ this ->conn );
797+
798+ $ qb ->select ('* ' )->from ('users ' );
799+
800+ $ this ->assertSame (array (), $ qb ->getParameterTypes ());
801+
802+ $ qb ->where ('name = :name ' );
803+ $ qb ->setParameter ('name ' , 'foo ' );
804+
805+ $ this ->assertSame (array (), $ qb ->getParameterTypes ());
806+
807+ $ qb ->setParameter ('name ' , 'foo ' , \PDO ::PARAM_STR );
808+
809+ $ qb ->where ('is_active = :isActive ' );
810+ $ qb ->setParameter ('isActive ' , true , \PDO ::PARAM_BOOL );
811+
812+ $ this ->assertSame (array ('name ' => \PDO ::PARAM_STR , 'isActive ' => \PDO ::PARAM_BOOL ), $ qb ->getParameterTypes ());
813+ }
766814}
0 commit comments