@@ -2859,6 +2859,46 @@ public function testDefaultNullValue() {
2859
2859
);
2860
2860
}
2861
2861
2862
+ public function testCurrentTimestamp () {
2863
+ // SELECT
2864
+ $ results = $ this ->assertQuery (
2865
+ 'SELECT
2866
+ current_timestamp AS t1,
2867
+ CURRENT_TIMESTAMP AS t2,
2868
+ current_timestamp() AS t3,
2869
+ CURRENT_TIMESTAMP() AS t4 '
2870
+ );
2871
+ $ this ->assertIsArray ( $ results );
2872
+ $ this ->assertCount ( 1 , $ results );
2873
+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ results [0 ]->t1 );
2874
+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ results [0 ]->t2 );
2875
+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ results [0 ]->t3 );
2876
+
2877
+ // INSERT
2878
+ $ this ->assertQuery (
2879
+ "INSERT INTO _dates (option_name, option_value) VALUES ('first', current_timestamp()) "
2880
+ );
2881
+ $ results = $ this ->assertQuery ( 'SELECT option_value AS t FROM _dates ' );
2882
+ $ this ->assertCount ( 1 , $ results );
2883
+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ results [0 ]->t );
2884
+
2885
+ // UPDATE
2886
+ $ this ->assertQuery ( 'UPDATE _dates SET option_value = NULL ' );
2887
+ $ results = $ this ->assertQuery ( 'SELECT option_value AS t FROM _dates ' );
2888
+ $ this ->assertCount ( 1 , $ results );
2889
+ $ this ->assertEmpty ( $ results [0 ]->t );
2890
+
2891
+ $ this ->assertQuery ( 'UPDATE _dates SET option_value = CURRENT_TIMESTAMP() ' );
2892
+ $ results = $ this ->assertQuery ( 'SELECT option_value AS t FROM _dates ' );
2893
+ $ this ->assertCount ( 1 , $ results );
2894
+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ results [0 ]->t );
2895
+
2896
+ // DELETE
2897
+ // We can only assert that the query passes. It is not guaranteed that we'll actually
2898
+ // delete the existing record, as the delete query could fall into a different second.
2899
+ $ this ->assertQuery ( 'DELETE FROM _dates WHERE option_value = CURRENT_TIMESTAMP() ' );
2900
+ }
2901
+
2862
2902
/**
2863
2903
* @dataProvider mysqlVariablesToTest
2864
2904
*/
0 commit comments