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