Changeset 22567 for branches/version-2_12-dev/test/class/SC_Query_Test.php
- Timestamp:
- 2013/02/18 19:09:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/test/class/SC_Query_Test.php
r22206 r22567 33 33 * @version $Id$ 34 34 */ 35 class SC_Query_Test extends PHPUnit_Framework_TestCase { 35 class SC_Query_Test extends PHPUnit_Framework_TestCase 36 { 36 37 37 38 /** SC_Query インスタンス */ … … 41 42 var $actual; 42 43 43 function setUp() { 44 function setUp() 45 { 44 46 $this->objQuery = new SC_Query(); 45 47 $this->objQuery->begin(); 46 48 } 47 49 48 function tearDown() { 50 function tearDown() 51 { 49 52 // MySQL では CREATE TABLE がロールバックされないので DROP TABLE を行う 50 53 $this->dropTestTable(); … … 53 56 } 54 57 55 function verify() { 58 function verify() 59 { 56 60 $this->assertEquals($this->expected, $this->actual); 57 61 } … … 60 64 * インスタンスを取得するテストケース. 61 65 */ 62 function testGetInstance() { 66 function testGetInstance() 67 { 63 68 $this->expected = true; 64 69 $this->actual = is_object($this->objQuery); … … 70 75 * SC_Query::query() を使用して, CREATE TABLE を実行するテストケース. 71 76 */ 72 function testCreateTable() { 77 function testCreateTable() 78 { 73 79 $result = $this->createTestTable(); 74 80 … … 82 88 * SC_Query::getAll() のテストケース. 83 89 */ 84 function testGetAll() { 90 function testGetAll() 91 { 85 92 $result = $this->createTestTable(); 86 93 $result = $this->setTestData(1, '2', 'f'); … … 98 105 * SC_Query::select() のテストケース. 99 106 */ 100 function testSelect() { 107 function testSelect() 108 { 101 109 $this->createTestTable(); 102 110 $result = $this->setTestData(1, '2', 'f'); … … 118 126 * SC_Query::getOne() のテストケース. 119 127 */ 120 function testGetOne() { 128 function testGetOne() 129 { 121 130 $this->createTestTable(); 122 131 $this->setTestData(1, '2', 'f'); … … 133 142 * SC_Query::getRow() のテストケース. 134 143 */ 135 function testGetRow() { 144 function testGetRow() 145 { 136 146 $this->createTestTable(); 137 147 $this->setTestData(1, '1', 'f'); … … 147 157 * SC_Query::getCol() のテストケース. 148 158 */ 149 function testGetCol() { 159 function testGetCol() 160 { 150 161 $this->createTestTable(); 151 162 $this->setTestData(1, '1', 'f'); … … 163 174 * SC_Query::query() で INSERT を実行するテストケース. 164 175 */ 165 function testQuery1() { 176 function testQuery1() 177 { 166 178 $this->createTestTable(); 167 179 $sql = "INSERT INTO test_table VALUES (?, ?, ?, ?)"; … … 180 192 } 181 193 182 function testInsert() { 194 function testInsert() 195 { 183 196 $this->createTestTable(); 184 197 … … 202 215 * SC_Query::query() で UPDATE を実行するテストケース. 203 216 */ 204 function testQuery2() { 217 function testQuery2() 218 { 205 219 $this->createTestTable(); 206 220 $this->setTestData(1, '2', 'f'); … … 221 235 } 222 236 223 function testUpdate() { 237 function testUpdate() 238 { 224 239 $this->createTestTable(); 225 240 $this->setTestData(1, '2', 'f'); … … 241 256 } 242 257 243 function testListTables() { 258 function testListTables() 259 { 244 260 $tables = $this->objQuery->listTables(); 245 261 $this->assertTrue(in_array('mtb_zip', $tables)); 246 262 } 247 263 248 function testListSequences() { 264 function testListSequences() 265 { 249 266 $sequences = $this->objQuery->listSequences(); 250 267 $this->assertTrue(in_array('dtb_products_product_id', $sequences)); 251 268 } 252 269 253 function testListTableFields() { 270 function testListTableFields() 271 { 254 272 $this->expected = array('id', 'name', 'rank', 'remarks'); 255 273 $this->actual = $this->objQuery->listTableFields('mtb_constants'); … … 257 275 } 258 276 259 function testListTableIndexes() { 277 function testListTableIndexes() 278 { 260 279 $indexes = $this->objQuery->listTableIndexes('dtb_mobile_kara_mail'); 261 280 $this->assertTrue(in_array('dtb_mobile_kara_mail_create_date_key', $indexes)); 262 281 } 263 282 264 function createTestTable() { 283 function createTestTable() 284 { 265 285 $sql = "CREATE TABLE test_table (" 266 286 . "id SERIAL PRIMARY KEY," … … 272 292 } 273 293 274 function dropTestTable() { 294 function dropTestTable() 295 { 275 296 $tables = $this->objQuery->listTables(); 276 297 if (in_array('test_table', $tables)) { … … 280 301 } 281 302 282 function setTestData($column1, $column2, $column3) { 303 function setTestData($column1, $column2, $column3) 304 { 283 305 $fields_values = array($column1, $column2, $column3); 284 306 $sql = "INSERT INTO test_table (column1, column2, column3) VALUES (?, ?, ?)";
Note: See TracChangeset
for help on using the changeset viewer.