diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a534a3e965..8ee7cc84e6 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -724,6 +724,7 @@ phutil_register_library_map(array( 'PhrictionEditController' => 'applications/phriction/controller/edit', 'PhrictionHistoryController' => 'applications/phriction/controller/history', 'PhrictionListController' => 'applications/phriction/controller/list', + 'QueryFormattingTestCase' => 'storage/qsprintf/__tests__', ), 'function' => array( @@ -1337,6 +1338,7 @@ phutil_register_library_map(array( 'PhrictionEditController' => 'PhrictionController', 'PhrictionHistoryController' => 'PhrictionController', 'PhrictionListController' => 'PhrictionController', + 'QueryFormattingTestCase' => 'PhabricatorTestCase', ), 'requires_interface' => array( diff --git a/src/storage/qsprintf/__tests__/QueryFormattingTestCase.php b/src/storage/qsprintf/__tests__/QueryFormattingTestCase.php new file mode 100644 index 0000000000..2d015948fc --- /dev/null +++ b/src/storage/qsprintf/__tests__/QueryFormattingTestCase.php @@ -0,0 +1,56 @@ +establishConnection('r'); + + $this->assertEqual( + 'NULL', + qsprintf($conn_r, '%nd', null)); + + $this->assertEqual( + '0', + qsprintf($conn_r, '%nd', 0)); + + $this->assertEqual( + '0', + qsprintf($conn_r, '%d', 0)); + + $raised = null; + try { + qsprintf($conn_r, '%d', 'derp'); + } catch (Exception $ex) { + $raised = $ex; + } + $this->assertEqual( + (bool)$raised, + true, + 'qsprintf should raise exception for invalid %d conversion.'); + + $this->assertEqual( + "''", + qsprintf($conn_r, '%s', null)); + + $this->assertEqual( + 'NULL', + qsprintf($conn_r, '%ns', null)); + } + +} diff --git a/src/storage/qsprintf/__tests__/__init__.php b/src/storage/qsprintf/__tests__/__init__.php new file mode 100644 index 0000000000..e929d136e1 --- /dev/null +++ b/src/storage/qsprintf/__tests__/__init__.php @@ -0,0 +1,16 @@ +