@@ -884,6 +884,48 @@ public function testChangeColumnDefaultToNull()
884
884
$ this ->assertNull ($ rows [1 ]['Default ' ]);
885
885
}
886
886
887
+ public function sqlTypeProvider ()
888
+ {
889
+ // TODO: add tests for missing types
890
+ return [
891
+ // tinyint
892
+ [AdapterInterface::PHINX_TYPE_TINY_INTEGER , null , 'tinyint ' , 4 ],
893
+ [AdapterInterface::PHINX_TYPE_TINY_INTEGER , 2 , 'tinyint ' , 2 ],
894
+ [AdapterInterface::PHINX_TYPE_TINY_INTEGER , MysqlAdapter::INT_TINY , 'tinyint ' , 4 ],
895
+ // smallint
896
+ [AdapterInterface::PHINX_TYPE_SMALL_INTEGER , null , 'smallint ' , 6 ],
897
+ [AdapterInterface::PHINX_TYPE_SMALL_INTEGER , 3 , 'smallint ' , 3 ],
898
+ [AdapterInterface::PHINX_TYPE_SMALL_INTEGER , MysqlAdapter::INT_SMALL , 'smallint ' , 6 ],
899
+ // medium
900
+ [AdapterInterface::PHINX_TYPE_MEDIUM_INTEGER , null , 'mediumint ' , 8 ],
901
+ [AdapterInterface::PHINX_TYPE_MEDIUM_INTEGER , 2 , 'mediumint ' , 2 ],
902
+ [AdapterInterface::PHINX_TYPE_MEDIUM_INTEGER , MysqlAdapter::INT_MEDIUM , 'mediumint ' , 8 ],
903
+ // integer
904
+ [AdapterInterface::PHINX_TYPE_INTEGER , null , 'int ' , 11 ],
905
+ [AdapterInterface::PHINX_TYPE_INTEGER , 4 , 'int ' , 4 ],
906
+ [AdapterInterface::PHINX_TYPE_INTEGER , MysqlAdapter::INT_TINY , 'tinyint ' , 4 ],
907
+ [AdapterInterface::PHINX_TYPE_INTEGER , MysqlAdapter::INT_SMALL , 'smallint ' , 6 ],
908
+ [AdapterInterface::PHINX_TYPE_INTEGER , MysqlAdapter::INT_MEDIUM , 'mediumint ' , 8 ],
909
+ [AdapterInterface::PHINX_TYPE_INTEGER , MysqlAdapter::INT_REGULAR , 'int ' , 11 ],
910
+ [AdapterInterface::PHINX_TYPE_INTEGER , MysqlAdapter::INT_BIG , 'bigint ' , 20 ],
911
+ // bigint
912
+ [AdapterInterface::PHINX_TYPE_BIG_INTEGER , null , 'bigint ' , 20 ],
913
+ [AdapterInterface::PHINX_TYPE_BIG_INTEGER , 4 , 'bigint ' , 4 ],
914
+ [AdapterInterface::PHINX_TYPE_BIG_INTEGER , MysqlAdapter::INT_BIG , 'bigint ' , 20 ],
915
+ ];
916
+ }
917
+
918
+ /**
919
+ * @dataProvider sqlTypeProvider
920
+ * The second argument is not typed as MysqlAdapter::INT_BIG is a float, and all other values are integers
921
+ */
922
+ public function testGetSqlType (string $ type , $ limit , string $ expectedType , int $ expectedLimit )
923
+ {
924
+ $ sqlType = $ this ->adapter ->getSqlType ($ type , $ limit );
925
+ $ this ->assertEquals ($ expectedType , $ sqlType ['name ' ]);
926
+ $ this ->assertEquals ($ expectedLimit , $ sqlType ['limit ' ]);
927
+ }
928
+
887
929
public function testLongTextColumn ()
888
930
{
889
931
$ table = new \Phinx \Db \Table ('t ' , [], $ this ->adapter );
0 commit comments