mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Move qsprintf() test cases from libphutil to Phabricator
Summary: Also move the other tests up so they'll trigger when this stuff is touched. Test Plan: liberate Reviewers: nh, btrahan, vrana Reviewed By: nh CC: aran Maniphest Tasks: T1283 Differential Revision: https://secure.phabricator.com/D3074
This commit is contained in:
parent
f0ee4946a6
commit
fc09bcf0a3
4 changed files with 60 additions and 2 deletions
|
@ -58,7 +58,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontHeadsupActionView' => 'view/layout/headsup/AphrontHeadsupActionView.php',
|
'AphrontHeadsupActionView' => 'view/layout/headsup/AphrontHeadsupActionView.php',
|
||||||
'AphrontHeadsupView' => 'view/layout/headsup/AphrontHeadsupView.php',
|
'AphrontHeadsupView' => 'view/layout/headsup/AphrontHeadsupView.php',
|
||||||
'AphrontIDPagerView' => 'view/control/AphrontIDPagerView.php',
|
'AphrontIDPagerView' => 'view/control/AphrontIDPagerView.php',
|
||||||
'AphrontIsolatedDatabaseConnectionTestCase' => 'infrastructure/storage/connection/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php',
|
'AphrontIsolatedDatabaseConnectionTestCase' => 'infrastructure/storage/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php',
|
||||||
'AphrontIsolatedHTTPSink' => 'aphront/sink/AphrontIsolatedHTTPSink.php',
|
'AphrontIsolatedHTTPSink' => 'aphront/sink/AphrontIsolatedHTTPSink.php',
|
||||||
'AphrontJSONResponse' => 'aphront/response/AphrontJSONResponse.php',
|
'AphrontJSONResponse' => 'aphront/response/AphrontJSONResponse.php',
|
||||||
'AphrontJavelinView' => 'view/AphrontJavelinView.php',
|
'AphrontJavelinView' => 'view/AphrontJavelinView.php',
|
||||||
|
@ -66,7 +66,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontListFilterView' => 'view/layout/AphrontListFilterView.php',
|
'AphrontListFilterView' => 'view/layout/AphrontListFilterView.php',
|
||||||
'AphrontMiniPanelView' => 'view/layout/AphrontMiniPanelView.php',
|
'AphrontMiniPanelView' => 'view/layout/AphrontMiniPanelView.php',
|
||||||
'AphrontMoreView' => 'view/layout/AphrontMoreView.php',
|
'AphrontMoreView' => 'view/layout/AphrontMoreView.php',
|
||||||
'AphrontMySQLDatabaseConnectionTestCase' => 'infrastructure/storage/connection/__tests__/AphrontMySQLDatabaseConnectionTestCase.php',
|
'AphrontMySQLDatabaseConnectionTestCase' => 'infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php',
|
||||||
'AphrontNullView' => 'view/AphrontNullView.php',
|
'AphrontNullView' => 'view/AphrontNullView.php',
|
||||||
'AphrontPHPHTTPSink' => 'aphront/sink/AphrontPHPHTTPSink.php',
|
'AphrontPHPHTTPSink' => 'aphront/sink/AphrontPHPHTTPSink.php',
|
||||||
'AphrontPageView' => 'view/page/AphrontPageView.php',
|
'AphrontPageView' => 'view/page/AphrontPageView.php',
|
||||||
|
@ -1081,6 +1081,7 @@ phutil_register_library_map(array(
|
||||||
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
|
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
|
||||||
'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php',
|
'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php',
|
||||||
'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php',
|
'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php',
|
||||||
|
'QueryFormattingTestCase' => 'infrastructure/storage/__tests__/QueryFormattingTestCase.php',
|
||||||
),
|
),
|
||||||
'function' =>
|
'function' =>
|
||||||
array(
|
array(
|
||||||
|
@ -2050,5 +2051,6 @@ phutil_register_library_map(array(
|
||||||
'PhrictionEditController' => 'PhrictionController',
|
'PhrictionEditController' => 'PhrictionController',
|
||||||
'PhrictionHistoryController' => 'PhrictionController',
|
'PhrictionHistoryController' => 'PhrictionController',
|
||||||
'PhrictionListController' => 'PhrictionController',
|
'PhrictionListController' => 'PhrictionController',
|
||||||
|
'QueryFormattingTestCase' => 'PhabricatorTestCase',
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2012 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class QueryFormattingTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
public function testQueryFormatting() {
|
||||||
|
$conn_r = id(new PhabricatorUser())->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(
|
||||||
|
"'<S>'",
|
||||||
|
qsprintf($conn_r, '%s', null));
|
||||||
|
|
||||||
|
$this->assertEqual(
|
||||||
|
'NULL',
|
||||||
|
qsprintf($conn_r, '%ns', null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue