transactd 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +37 -4
- data/bin/common/tdclc_32_1_2.dll +0 -0
- data/bin/common/tdclc_64_1_2.dll +0 -0
- data/build/common/transactd_cl_common.cmake +0 -1
- data/build/common/transactd_common.cmake +26 -6
- data/build/swig/php/generate.cmake.in +58 -0
- data/build/swig/php/generate.cmd.in +41 -0
- data/build/swig/php/php.swg +155 -0
- data/build/swig/ruby/ruby.swg +38 -0
- data/build/swig/tdcl.i +133 -3
- data/build/tdclc/CMakeLists.txt +4 -1
- data/build/tdclc/tdclc_32.cbproj +1 -1
- data/build/tdclc/tdclc_64.cbproj +1 -1
- data/build/tdclcpp/CMakeLists.txt +1 -1
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +1 -4
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +0 -3
- data/build/tdclrb/CMakeLists.txt +1 -1
- data/build/tdclrb/GEM_VERSION +2 -2
- data/source/bzs/db/engine/mysql/IReadRecords.h +1 -1
- data/source/bzs/db/engine/mysql/bookmark.h +3 -3
- data/source/bzs/db/engine/mysql/database.cpp +95 -19
- data/source/bzs/db/engine/mysql/database.h +6 -6
- data/source/bzs/db/engine/mysql/mysqlInternal.h +43 -1
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +10 -8
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +1 -1
- data/source/bzs/db/protocol/tdap/btrDate.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +15 -8
- data/source/bzs/db/protocol/tdap/client/dbDef.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +0 -5
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +0 -4
- data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -484
- data/source/bzs/db/protocol/tdap/client/filter.h +696 -84
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +13 -3
- data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -6
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -1
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +1 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +519 -75
- data/source/bzs/db/protocol/tdap/client/table.h +49 -7
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +145 -124
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +39 -0
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +872 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +8 -8
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +7 -9
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +406 -195
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +64 -13
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +2 -1
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +35 -3
- data/source/bzs/db/protocol/tdap/tdapSchema.h +11 -3
- data/source/bzs/db/protocol/tdap/tdapcapi.h +63 -53
- data/source/bzs/env/crosscompile.h +8 -3
- data/source/bzs/example/connection_pool_c.cpp +1 -7
- data/source/bzs/example/useORM.cpp +585 -0
- data/source/bzs/rtl/exception.h +6 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +12 -7
- data/source/bzs/test/tdclphp/transactd_Test.php +1845 -0
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +325 -0
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +183 -0
- data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +212 -0
- data/source/bzs/test/tdclrb/transactd_blob_spec.rb +332 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +256 -1
- data/source/bzs/test/trdclengn/test_blob.cpp +327 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +485 -5
- data/source/global/tdclatl/QueryBase.cpp +231 -0
- data/source/global/tdclatl/QueryBase.h +96 -0
- data/source/global/tdclatl/Table.cpp +24 -0
- data/source/global/tdclatl/Table.h +2 -1
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +88 -2
- metadata +16 -3
- data/bin/common/tdclc_32_1_1.dll +0 -0
- data/bin/common/tdclc_64_1_1.dll +0 -0
@@ -0,0 +1,325 @@
|
|
1
|
+
<?php
|
2
|
+
/* ================================================================
|
3
|
+
Copyright (C) 2013 BizStation Corp All rights reserved.
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU General Public License
|
7
|
+
as published by the Free Software Foundation; either version 2
|
8
|
+
of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License
|
16
|
+
along with this program; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
18
|
+
02111-1307, USA.
|
19
|
+
================================================================ */
|
20
|
+
mb_internal_encoding('UTF-8');
|
21
|
+
|
22
|
+
require_once("transactd.php");
|
23
|
+
|
24
|
+
define("HOSTNAME", "localhost/");
|
25
|
+
define("URL", "tdap://" . HOSTNAME . "test_blob?dbfile=test.bdf");
|
26
|
+
define("TABLENAME", "comments");
|
27
|
+
define("FDI_ID", 0);
|
28
|
+
define("FDI_USER_ID", 1);
|
29
|
+
define("FDI_BODY", 2);
|
30
|
+
define("FDI_IMAGE", 3);
|
31
|
+
|
32
|
+
define("TYPE_SCHEMA_BDF", 0);
|
33
|
+
|
34
|
+
class transactdBlobTest extends PHPUnit_Framework_TestCase
|
35
|
+
{
|
36
|
+
private function getDbObj()
|
37
|
+
{
|
38
|
+
return database::createObject();
|
39
|
+
}
|
40
|
+
private function deleteDbObj($db)
|
41
|
+
{
|
42
|
+
$db->close();
|
43
|
+
$db = NULL;
|
44
|
+
}
|
45
|
+
private function dropDatabase($db, $url)
|
46
|
+
{
|
47
|
+
$db->open($url);
|
48
|
+
$this->assertEquals($db->stat(), 0);
|
49
|
+
$db->drop();
|
50
|
+
$this->assertEquals($db->stat(), 0);
|
51
|
+
}
|
52
|
+
private function createDatabase($db, $url)
|
53
|
+
{
|
54
|
+
$db->create($url);
|
55
|
+
if ($db->stat() == transactd::STATUS_TABLE_EXISTS_ERROR)
|
56
|
+
{
|
57
|
+
$this->dropDatabase($db, $url);
|
58
|
+
$db->create($url);
|
59
|
+
}
|
60
|
+
$this->assertEquals($db->stat(), 0);
|
61
|
+
}
|
62
|
+
private function openDatabase($db, $url)
|
63
|
+
{
|
64
|
+
$db->open($url, TYPE_SCHEMA_BDF, transactd::TD_OPEN_NORMAL);
|
65
|
+
$this->assertEquals($db->stat(), 0);
|
66
|
+
}
|
67
|
+
private function createTable($db, $tableid, $tablename)
|
68
|
+
{
|
69
|
+
$dbdef = $db->dbDef();
|
70
|
+
$this->assertNotEquals($dbdef, NULL);
|
71
|
+
$td = new tabledef();
|
72
|
+
// Set table schema codepage to UTF-8
|
73
|
+
// - codepage for field NAME and tableNAME
|
74
|
+
$td->schemaCodePage = transactd::CP_UTF8;
|
75
|
+
$td->setTableName($tablename);
|
76
|
+
$td->setFileName($tablename . '.dat');
|
77
|
+
// Set table default charaset index
|
78
|
+
// - default charset for field VALUE
|
79
|
+
$td->charsetIndex = transactd::charsetIndex(transactd::CP_UTF8);
|
80
|
+
//
|
81
|
+
$td->id = $tableid;
|
82
|
+
$td->pageSize = 2048;
|
83
|
+
$dbdef->insertTable($td);
|
84
|
+
$this->assertEquals($dbdef->stat(), 0);
|
85
|
+
// id
|
86
|
+
$fd = $dbdef->insertField($tableid, FDI_ID);
|
87
|
+
$fd->setName('id');
|
88
|
+
$fd->type = transactd::ft_autoinc;
|
89
|
+
$fd->len = 4;
|
90
|
+
$dbdef->updateTableDef($tableid);
|
91
|
+
$this->assertEquals($dbdef->stat(), 0);
|
92
|
+
// user_id
|
93
|
+
$fd = $dbdef->insertField($tableid, FDI_USER_ID);
|
94
|
+
$fd->setName('user_id');
|
95
|
+
$fd->type = transactd::ft_integer;
|
96
|
+
$fd->len = 4;
|
97
|
+
$dbdef->updateTableDef($tableid);
|
98
|
+
$this->assertEquals($dbdef->stat(), 0);
|
99
|
+
// body
|
100
|
+
$fd = $dbdef->insertField($tableid, FDI_BODY);
|
101
|
+
$fd->setName('body');
|
102
|
+
$fd->type = transactd::ft_mytext;
|
103
|
+
$fd->len = 10; // 9:TYNYTEXT 10:TEXT 11:MIDIUMTEXT 12:LONGTEXT
|
104
|
+
$dbdef->updateTableDef($tableid);
|
105
|
+
$this->assertEquals($dbdef->stat(), 0);
|
106
|
+
// image
|
107
|
+
$fd = $dbdef->insertField($tableid, FDI_IMAGE);
|
108
|
+
$fd->setName('image');
|
109
|
+
$fd->type = transactd::ft_myblob;
|
110
|
+
$fd->len = 10; // 9:TYNYBLOB 10:BLOB 11:MIDIUMBLOB 12:LONGBLOB
|
111
|
+
$dbdef->updateTableDef($tableid);
|
112
|
+
$this->assertEquals($dbdef->stat(), 0);
|
113
|
+
// key
|
114
|
+
$kd = $dbdef->insertKey($tableid, 0);
|
115
|
+
$kd->segment(0)->fieldNum = 0;
|
116
|
+
$kd->segment(0)->flags->bit8 = 1;
|
117
|
+
$kd->segment(0)->flags->bit1 = 1;
|
118
|
+
$kd->segmentCount = 1;
|
119
|
+
$dbdef->updateTableDef($tableid);
|
120
|
+
$this->assertEquals($dbdef->stat(), 0);
|
121
|
+
}
|
122
|
+
private function openTable($db, $tablename)
|
123
|
+
{
|
124
|
+
$tb = $db->openTable($tablename);
|
125
|
+
$this->assertEquals($db->stat(), 0);
|
126
|
+
return $tb;
|
127
|
+
}
|
128
|
+
private function getTestBinary() {
|
129
|
+
$image_base64 = 'R0lGODdhEAAQAKEBAGZmZv///5mZmczMzCwAAAAAEAAQAAACRowzIgA6BxebTMAgG60nW5NM1kAZikGFHAmgYvYgJpW12FfTyLpJjz+IVSSXR4IlQCoUgCCG8ds0D5xZT3TJYS8IZiMJKQAAOw==';
|
130
|
+
return base64_decode($image_base64);
|
131
|
+
}
|
132
|
+
|
133
|
+
public function testCreate()
|
134
|
+
{
|
135
|
+
$db = $this->getDbObj();
|
136
|
+
$this->createDatabase($db, URL);
|
137
|
+
$this->openDatabase($db, URL);
|
138
|
+
$this->createTable($db, 1, TABLENAME);
|
139
|
+
$tb = $this->openTable($db, TABLENAME);
|
140
|
+
$tb->close();
|
141
|
+
$this->deleteDbObj($db);
|
142
|
+
}
|
143
|
+
public function testInsert()
|
144
|
+
{
|
145
|
+
$image = $this->getTestBinary();
|
146
|
+
$db = $this->getDbObj();
|
147
|
+
$this->openDatabase($db, URL);
|
148
|
+
$tb = $this->openTable($db, TABLENAME);
|
149
|
+
$this->assertNotEquals($tb, NULL);
|
150
|
+
// 1
|
151
|
+
$tb->clearBuffer();
|
152
|
+
$tb->setFV(FDI_USER_ID, 1);
|
153
|
+
$tb->setFV(FDI_BODY, "1\ntest\nテスト\n\nあいうえおあいうえお");
|
154
|
+
$tb->setFV(FDI_IMAGE, $image, strlen($image));
|
155
|
+
$tb->insert();
|
156
|
+
$this->assertEquals($tb->stat(), 0);
|
157
|
+
// 2
|
158
|
+
$tb->clearBuffer();
|
159
|
+
$tb->setFV('user_id', 1);
|
160
|
+
$tb->setFV('body', "2\ntest\nテスト\n\nあいうえおあいうえお");
|
161
|
+
$str = "2\ntest\nテスト\n\nあいうえおあいうえお";
|
162
|
+
$tb->setFV('image', $str, strlen($str));
|
163
|
+
$tb->insert();
|
164
|
+
$this->assertEquals($tb->stat(), 0);
|
165
|
+
// 3
|
166
|
+
$tb->clearBuffer();
|
167
|
+
$tb->setFV(FDI_USER_ID, 2);
|
168
|
+
$tb->setFV(FDI_BODY, "3\ntest\nテスト\n\nあいうえおあいうえお");
|
169
|
+
$str = "3\ntest\nテスト\n\nあいうえおあいうえお";
|
170
|
+
$tb->setFV(FDI_IMAGE, $str, strlen($str));
|
171
|
+
$tb->insert();
|
172
|
+
$this->assertEquals($tb->stat(), 0);
|
173
|
+
// close
|
174
|
+
$tb->close();
|
175
|
+
$this->deleteDbObj($db);
|
176
|
+
}
|
177
|
+
public function testSeek()
|
178
|
+
{
|
179
|
+
$db = $this->getDbObj();
|
180
|
+
$this->openDatabase($db, URL);
|
181
|
+
$tb = $this->openTable($db, TABLENAME);
|
182
|
+
$this->assertNotEquals($tb, NULL);
|
183
|
+
// 1
|
184
|
+
$tb->clearBuffer();
|
185
|
+
$tb->setFV(FDI_ID, 1);
|
186
|
+
$tb->seek();
|
187
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
188
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
189
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "1\ntest\nテスト\n\nあいうえおあいうえお");
|
190
|
+
$image = $this->getTestBinary();
|
191
|
+
$this->assertEquals($tb->getFVbin(FDI_IMAGE), $image);
|
192
|
+
// 2
|
193
|
+
$tb->seekNext();
|
194
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 2);
|
195
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
196
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
197
|
+
$this->assertEquals($tb->getFVbin(FDI_IMAGE), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
198
|
+
// 3
|
199
|
+
$tb->seekNext();
|
200
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 3);
|
201
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 2);
|
202
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "3\ntest\nテスト\n\nあいうえおあいうえお");
|
203
|
+
$this->assertEquals($tb->getFVbin(FDI_IMAGE), "3\ntest\nテスト\n\nあいうえおあいうえお");
|
204
|
+
// 2
|
205
|
+
$tb->seekPrev();
|
206
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 2);
|
207
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
208
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
209
|
+
$this->assertEquals($tb->getFVbin(FDI_IMAGE), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
210
|
+
// close
|
211
|
+
$tb->close();
|
212
|
+
$this->deleteDbObj($db);
|
213
|
+
}
|
214
|
+
public function testFind()
|
215
|
+
{
|
216
|
+
$db = $this->getDbObj();
|
217
|
+
$this->openDatabase($db, URL);
|
218
|
+
$tb = $this->openTable($db, TABLENAME);
|
219
|
+
$this->assertNotEquals($tb, NULL);
|
220
|
+
// 1
|
221
|
+
$tb->setKeyNum(0);
|
222
|
+
$tb->clearBuffer();
|
223
|
+
$tb->setFilter('id >= 1 and id < 3', 1, 0);
|
224
|
+
$this->assertEquals($tb->stat(), 0);
|
225
|
+
$tb->setFV(FDI_ID, 1);
|
226
|
+
$tb->find(table::findForword);
|
227
|
+
$this->assertEquals($tb->stat(), 0);
|
228
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
229
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
230
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "1\ntest\nテスト\n\nあいうえおあいうえお");
|
231
|
+
// 2
|
232
|
+
$tb->findNext(true);
|
233
|
+
$this->assertEquals($tb->stat(), 0);
|
234
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 2);
|
235
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
236
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
237
|
+
// 3... but not found because filtered
|
238
|
+
$tb->findNext(true);
|
239
|
+
$this->assertEquals($tb->stat(), transactd::STATUS_EOF);
|
240
|
+
// 2... but changing seek-direction is not allowed
|
241
|
+
$tb->findPrev(true);
|
242
|
+
$this->assertEquals($tb->stat(), transactd::STATUS_PROGRAM_ERROR);
|
243
|
+
// close
|
244
|
+
$tb->close();
|
245
|
+
$this->deleteDbObj($db);
|
246
|
+
}
|
247
|
+
public function testUpdate()
|
248
|
+
{
|
249
|
+
$db = $this->getDbObj();
|
250
|
+
$this->openDatabase($db, URL);
|
251
|
+
$tb = $this->openTable($db, TABLENAME);
|
252
|
+
$this->assertNotEquals($tb, NULL);
|
253
|
+
// select 1
|
254
|
+
$tb->clearBuffer();
|
255
|
+
$tb->setFV(FDI_ID, 1);
|
256
|
+
$tb->seek();
|
257
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
258
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
259
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "1\ntest\nテスト\n\nあいうえおあいうえお");
|
260
|
+
// update
|
261
|
+
$tb->setFV(FDI_BODY, "1\nテスト\ntest\n\nABCDEFG");
|
262
|
+
$tb->update();
|
263
|
+
$this->assertEquals($tb->stat(), 0);
|
264
|
+
// select 2
|
265
|
+
$tb->seekNext();
|
266
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 2);
|
267
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
268
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
269
|
+
// update
|
270
|
+
$tb->setFV(FDI_BODY, "2\nテスト\ntest\n\nABCDEFG");
|
271
|
+
$tb->update();
|
272
|
+
$this->assertEquals($tb->stat(), 0);
|
273
|
+
// check 1
|
274
|
+
$tb->seekPrev();
|
275
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
276
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
277
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "1\nテスト\ntest\n\nABCDEFG");
|
278
|
+
// check 2
|
279
|
+
$tb->seekNext();
|
280
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 2);
|
281
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
282
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\nテスト\ntest\n\nABCDEFG");
|
283
|
+
// close
|
284
|
+
$tb->close();
|
285
|
+
$this->deleteDbObj($db);
|
286
|
+
}
|
287
|
+
public function testDelete()
|
288
|
+
{
|
289
|
+
$db = $this->getDbObj();
|
290
|
+
$this->openDatabase($db, URL);
|
291
|
+
$tb = $this->openTable($db, TABLENAME);
|
292
|
+
$this->assertNotEquals($tb, NULL);
|
293
|
+
// delete 2
|
294
|
+
$tb->clearBuffer();
|
295
|
+
$tb->setFV(FDI_ID, 2);
|
296
|
+
$tb->seek();
|
297
|
+
$this->assertEquals($tb->stat(), 0);
|
298
|
+
$tb->del();
|
299
|
+
$this->assertEquals($tb->stat(), 0);
|
300
|
+
// select 1
|
301
|
+
$tb->clearBuffer();
|
302
|
+
$tb->setFV(FDI_ID, 1);
|
303
|
+
$tb->seek();
|
304
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
305
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
306
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "1\nテスト\ntest\n\nABCDEFG");
|
307
|
+
// next is 3
|
308
|
+
$tb->seekNext();
|
309
|
+
$this->assertEquals($tb->getFVint(FDI_ID), 3);
|
310
|
+
$this->assertEquals($tb->getFVint(FDI_USER_ID), 2);
|
311
|
+
$this->assertEquals($tb->getFVstr(FDI_BODY), "3\ntest\nテスト\n\nあいうえおあいうえお");
|
312
|
+
// eof
|
313
|
+
$tb->seekNext();
|
314
|
+
$this->assertEquals($tb->stat(), transactd::STATUS_EOF);
|
315
|
+
// close
|
316
|
+
$tb->close();
|
317
|
+
$this->deleteDbObj($db);
|
318
|
+
}
|
319
|
+
public function testDrop()
|
320
|
+
{
|
321
|
+
$db = $this->getDbObj();
|
322
|
+
$this->dropDatabase($db, URL);
|
323
|
+
$this->deleteDbObj($db);
|
324
|
+
}
|
325
|
+
}
|
@@ -0,0 +1,183 @@
|
|
1
|
+
<?php
|
2
|
+
/* ================================================================
|
3
|
+
Copyright (C) 2013 BizStation Corp All rights reserved.
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU General Public License
|
7
|
+
as published by the Free Software Foundation; either version 2
|
8
|
+
of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License
|
16
|
+
along with this program; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
18
|
+
02111-1307, USA.
|
19
|
+
================================================================ */
|
20
|
+
mb_internal_encoding('UTF-8');
|
21
|
+
|
22
|
+
require_once("transactd.php");
|
23
|
+
|
24
|
+
class transactdDatetimeTest extends PHPUnit_Framework_TestCase
|
25
|
+
{
|
26
|
+
public function testGetBtrdate()
|
27
|
+
{
|
28
|
+
$i_nowdate = transactd::getNowDate(); // get today as integer
|
29
|
+
$s_i_nowdate = transactd::btrdtoa($i_nowdate);
|
30
|
+
$s_i_nowdate2 = transactd::btrdtoa($i_nowdate, true);
|
31
|
+
//print_r($i_nowdate);
|
32
|
+
//print_r($s_i_nowdate);
|
33
|
+
//print_r($s_i_nowdate2);
|
34
|
+
$nowdate = new btrDate();
|
35
|
+
$nowdate->i = $i_nowdate; // get today as BtrDate
|
36
|
+
$s_nowdate = transactd::btrdtoa($nowdate);
|
37
|
+
$s_nowdate2 = transactd::btrdtoa($nowdate, true);
|
38
|
+
$cs_nowdate = transactd::c_str($nowdate);
|
39
|
+
//print_r($nowdate);
|
40
|
+
//print_r($s_nowdate);
|
41
|
+
//print_r($s_nowdate2);
|
42
|
+
//print_r($cs_nowdate);
|
43
|
+
$this->assertEquals($s_i_nowdate, $s_nowdate);
|
44
|
+
$this->assertEquals($s_i_nowdate2, $s_nowdate2);
|
45
|
+
$this->assertEquals($cs_nowdate, $s_nowdate);
|
46
|
+
}
|
47
|
+
public function testGetBtrtime()
|
48
|
+
{
|
49
|
+
$i_nowtime = transactd::getNowTime(); // get now time as integer
|
50
|
+
$s_i_nowtime = transactd::btrttoa($i_nowtime);
|
51
|
+
$s_i_nowtime2 = transactd::btrttoa($i_nowtime, true);
|
52
|
+
//print_r($i_nowtime);
|
53
|
+
//print_r($s_i_nowtime);
|
54
|
+
//print_r($s_i_nowtime2);
|
55
|
+
$nowtime = new btrTime();
|
56
|
+
$nowtime->i = $i_nowtime; // get now time as BtrTime
|
57
|
+
$s_nowtime = transactd::btrttoa($nowtime);
|
58
|
+
$s_nowtime2 = transactd::btrttoa($nowtime, true);
|
59
|
+
$cs_nowtime = transactd::c_str($nowtime);
|
60
|
+
//print_r($nowtime);
|
61
|
+
//print_r($s_nowtime);
|
62
|
+
//print_r($s_nowtime2);
|
63
|
+
//print_r($cs_nowtime);
|
64
|
+
$this->assertEquals($s_i_nowtime, $s_nowtime);
|
65
|
+
$this->assertEquals($s_i_nowtime2, $s_nowtime2);
|
66
|
+
$this->assertEquals($cs_nowtime, $s_nowtime);
|
67
|
+
}
|
68
|
+
public function testGetBtrdatetime()
|
69
|
+
{
|
70
|
+
$d = transactd::atobtrd("2012-08-22");
|
71
|
+
//print_r($d);
|
72
|
+
$s_date = transactd::btrdtoa($d);
|
73
|
+
$this->assertEquals($s_date, '2012/08/22');
|
74
|
+
//print_r($s_date);
|
75
|
+
$t = transactd::atobtrt("15:37:00");
|
76
|
+
$s_time = transactd::btrttoa($t);
|
77
|
+
$this->assertEquals($s_time, '15:37:00');
|
78
|
+
//print_r($t);
|
79
|
+
//print_r($s_time);
|
80
|
+
$dt = transactd::atobtrs('2012-08-22 15:37:00');
|
81
|
+
$s_datetime = transactd::btrstoa($dt);
|
82
|
+
$s_datetime2 = transactd::btrstoa($dt, true);
|
83
|
+
$this->assertEquals($s_datetime, '2012/08/22 15:37:00');
|
84
|
+
$this->assertEquals($s_datetime2, '2012-08-22T15:37:00');
|
85
|
+
//print_r($dt);
|
86
|
+
//print_r($s_datetime);
|
87
|
+
//print_r($s_datetime2);
|
88
|
+
$s_datetime_d = transactd::btrdtoa($dt->date);
|
89
|
+
$s_datetime_t = transactd::btrttoa($dt->time);
|
90
|
+
$this->assertEquals($s_datetime_d . ' ' . $s_datetime_t, '2012/08/22 15:37:00');
|
91
|
+
//print_r($s_datetime_d . ' ' . $s_datetime_t);
|
92
|
+
}
|
93
|
+
public function testGetBdate()
|
94
|
+
{
|
95
|
+
$bd = transactd::atobtrd('2012-08-22');
|
96
|
+
$bdate = new bdate($bd->i);
|
97
|
+
$bdate2 = new bdate(transactd::btrdtoa($bd));
|
98
|
+
//print_r($bdate);
|
99
|
+
//print_r($bdate2);
|
100
|
+
$btrdate = $bdate->btr_date();
|
101
|
+
$btrdate2 = $bdate2->btr_date();
|
102
|
+
//print_r($btrdate);
|
103
|
+
//print_r($btrdate2);
|
104
|
+
$s_bdate = $bdate->c_str();
|
105
|
+
$s_bdate2 = $bdate2->c_str();
|
106
|
+
$this->assertEquals($s_bdate, $s_bdate2);
|
107
|
+
//print_r($s_bdate);
|
108
|
+
//print_r($s_bdate2);
|
109
|
+
$this->assertEquals($bdate->year(), 2012);
|
110
|
+
$this->assertEquals($bdate->month(), 8);
|
111
|
+
$this->assertEquals($bdate->date(), 22);
|
112
|
+
$this->assertEquals($bdate->year_str(), '2012');
|
113
|
+
$this->assertEquals($bdate->month_str(), '8');
|
114
|
+
$this->assertEquals($bdate->date_str(), '22');
|
115
|
+
//print_r($bdate->year());
|
116
|
+
//print_r($bdate->month());
|
117
|
+
//print_r($bdate->date());
|
118
|
+
//print_r($bdate->year_str());
|
119
|
+
//print_r($bdate->month_str());
|
120
|
+
//print_r($bdate->date_str());
|
121
|
+
}
|
122
|
+
public function testGetBtrtimestampFromString()
|
123
|
+
{
|
124
|
+
$d = transactd::atobtrd('2012-08-22');
|
125
|
+
$t = transactd::atobtrt('15:37:00');
|
126
|
+
$btrts = new btrTimeStamp('2012-08-22 15:37:00');
|
127
|
+
$btrts2 = new btrTimeStamp($d, $t);
|
128
|
+
$s_btrts = $btrts->toString();
|
129
|
+
$s_btrts2 = $btrts2->toString();
|
130
|
+
//print_r($btrts);
|
131
|
+
//print_r($btrts2);
|
132
|
+
//print_r($s_btrts);
|
133
|
+
//print_r($s_btrts2);
|
134
|
+
$this->assertEquals($s_btrts, $s_btrts2);
|
135
|
+
$this->assertEquals($s_btrts, '2012/08/22 15:37:00');
|
136
|
+
}
|
137
|
+
public function testGetBtrtimestampFromBtrdateAndBtrtime()
|
138
|
+
{
|
139
|
+
$i_nowdate = transactd::getNowDate();
|
140
|
+
$nowdate = new btrDate();
|
141
|
+
$nowdate->i = $i_nowdate;
|
142
|
+
$i_nowtime = transactd::getNowTime();
|
143
|
+
$nowtime = new btrTime();
|
144
|
+
$nowtime->i = $i_nowtime;
|
145
|
+
$nowdatetime = new btrTimeStamp($nowdate, $nowtime);
|
146
|
+
$s_nowdate = transactd::btrdtoa($nowdate);
|
147
|
+
$s_nowtime = transactd::btrttoa($nowtime);
|
148
|
+
$s_nowdatetime = $nowdatetime->toString();
|
149
|
+
$this->assertEquals($s_nowdatetime, $s_nowdate . ' ' . $s_nowtime);
|
150
|
+
//print_r($nowdatetime);
|
151
|
+
//print_r($s_nowdatetime);
|
152
|
+
//print_r($s_nowdate . ' ' . $s_nowtime);
|
153
|
+
}
|
154
|
+
public function testLastYear()
|
155
|
+
{
|
156
|
+
$i_nowdate = transactd::getNowDate();
|
157
|
+
$nowdate = new btrDate();
|
158
|
+
$nowdate->i = $i_nowdate;
|
159
|
+
$nowyear_yy = $nowdate->yy;
|
160
|
+
$i_nowtime = transactd::getNowTime();
|
161
|
+
$nowtime = new btrTime();
|
162
|
+
$nowtime->i = $i_nowtime;
|
163
|
+
$nowdatetime = new btrTimeStamp($nowdate, $nowtime);
|
164
|
+
$s_nowdatetime = $nowdatetime->toString();
|
165
|
+
$lastyear = $nowdate;
|
166
|
+
$lastyear->yy = $lastyear->yy - 1;
|
167
|
+
$lastyear_yy = $lastyear->yy;
|
168
|
+
$s_lastyear = transactd::btrdtoa($lastyear);
|
169
|
+
$lastyeardatetime = new btrTimeStamp($lastyear, $nowtime);
|
170
|
+
$s_lastyeardatetime = $lastyeardatetime->toString();
|
171
|
+
$this->assertEquals($nowyear_yy - 1, $lastyear_yy);
|
172
|
+
$this->assertEquals($s_lastyeardatetime, str_replace($nowyear_yy, $lastyear_yy, $s_nowdatetime));
|
173
|
+
//print_r($lastyeardatetime);
|
174
|
+
//print_r($s_lastyear);
|
175
|
+
//print_r($s_lastyeardatetime);
|
176
|
+
}
|
177
|
+
public function testTypename()
|
178
|
+
{
|
179
|
+
$typename = transactd::getTypeName(transactd::ft_integer);
|
180
|
+
//print_r($typename);
|
181
|
+
$this->assertEquals($typename, 'Integer');
|
182
|
+
}
|
183
|
+
}
|