Changeset 21481 for branches/version-2_12-dev/test/class/SC_Query_Test.php
- Timestamp:
- 2012/02/11 05:48:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/test/class/SC_Query_Test.php
r20764 r21481 84 84 function testGetAll() { 85 85 $result = $this->createTestTable(); 86 $result = $this->setTestData(1, "2", "f");87 88 $this->expected = array(array( "id" => "1",89 "column1" => "1",90 "column2" => "2",91 "column3" => "f"));86 $result = $this->setTestData(1, '2', 'f'); 87 88 $this->expected = array(array('id' => '1', 89 'column1' => '1', 90 'column2' => '2', 91 'column3' => 'f')); 92 92 $this->actual = $this->objQuery->getAll("SELECT * FROM test_table WHERE id = ?", array(1)); 93 93 … … 100 100 function testSelect() { 101 101 $this->createTestTable(); 102 $result = $this->setTestData(1, "2", "f");103 104 $this->expected = array(array( "id" => "1",105 "column1" => "1",106 "column2" => "2",107 "column3" => "f"));102 $result = $this->setTestData(1, '2', 'f'); 103 104 $this->expected = array(array('id' => '1', 105 'column1' => '1', 106 'column2' => '2', 107 'column3' => 'f')); 108 108 109 109 $this->actual = $this->objQuery->setWhere("id = ?") 110 ->setOrder( "id")111 ->select("*", "test_table", "", array(1));110 ->setOrder('id') 111 ->select("*", 'test_table', "", array(1)); 112 112 113 113 $this->verify(); … … 120 120 function testGetOne() { 121 121 $this->createTestTable(); 122 $this->setTestData(1, "2", "f");123 $this->setTestData(1, "2", "f");124 $this->setTestData(1, "2", "f");122 $this->setTestData(1, '2', 'f'); 123 $this->setTestData(1, '2', 'f'); 124 $this->setTestData(1, '2', 'f'); 125 125 126 126 $this->expected = 3; … … 135 135 function testGetRow() { 136 136 $this->createTestTable(); 137 $this->setTestData(1, "1", "f");138 $this->setTestData(2, "2", "f");139 $this->setTestData(3, "3", "f");140 141 $this->expected = array( "column1" => 1, "column2"=> 1);142 $this->actual = $this->objQuery->getRow("column1, column2", "test_table", "id = ?", array(1));137 $this->setTestData(1, '1', 'f'); 138 $this->setTestData(2, '2', 'f'); 139 $this->setTestData(3, '3', 'f'); 140 141 $this->expected = array('column1' => 1, 'column2' => 1); 142 $this->actual = $this->objQuery->getRow("column1, column2", 'test_table', "id = ?", array(1)); 143 143 $this->verify(); 144 144 } … … 149 149 function testGetCol() { 150 150 $this->createTestTable(); 151 $this->setTestData(1, "1", "f");152 $this->setTestData(2, "2", "f");153 $this->setTestData(3, "3", "f");151 $this->setTestData(1, '1', 'f'); 152 $this->setTestData(2, '2', 'f'); 153 $this->setTestData(3, '3', 'f'); 154 154 155 155 $this->expected = array(1, 2); 156 $this->actual = $this->objQuery->getCol( "column1", "test_table", "id < ?", array(3));156 $this->actual = $this->objQuery->getCol('column1', 'test_table', "id < ?", array(3)); 157 157 158 158 $this->verify(); … … 166 166 $this->createTestTable(); 167 167 $sql = "INSERT INTO test_table VALUES (?, ?, ?, ?)"; 168 $data = array( "1", "1", "1", "f");168 $data = array('1', '1', '1', 'f'); 169 169 170 170 $this->objQuery->query($sql, $data); 171 171 172 $this->expected = array(array( "id" => "1",173 "column1" => "1",174 "column2" => "1",175 "column3" => "f"));172 $this->expected = array(array('id' => '1', 173 'column1' => '1', 174 'column2' => '1', 175 'column3' => 'f')); 176 176 177 177 $this->actual = $this->objQuery->getAll("SELECT * FROM test_table"); … … 183 183 $this->createTestTable(); 184 184 185 $this->objQuery->insert( "test_table",186 array( "id" => "1",187 "column1" => "1",188 "column2" => "1",189 "column3" => "f"));190 191 $this->expected = array(array( "id" => "1",192 "column1" => "1",193 "column2" => "1",194 "column3" => "f"));185 $this->objQuery->insert('test_table', 186 array('id' => '1', 187 'column1' => '1', 188 'column2' => '1', 189 'column3' => 'f')); 190 191 $this->expected = array(array('id' => '1', 192 'column1' => '1', 193 'column2' => '1', 194 'column3' => 'f')); 195 195 196 196 $this->actual = $this->objQuery->getAll("SELECT * FROM test_table"); … … 204 204 function testQuery2() { 205 205 $this->createTestTable(); 206 $this->setTestData(1, "2", "f");206 $this->setTestData(1, '2', 'f'); 207 207 208 208 $sql = "UPDATE test_table SET column1 = ?, column2 = ? WHERE id = ?"; 209 $data = array( "2", "2", "1");209 $data = array('2', '2', '1'); 210 210 211 211 $this->objQuery->query($sql, $data); 212 212 213 $this->expected = array(array( "id" => "1",214 "column1" => "2",215 "column2" => "2",216 "column3" => "f"));213 $this->expected = array(array('id' => '1', 214 'column1' => '2', 215 'column2' => '2', 216 'column3' => 'f')); 217 217 218 218 $this->actual = $this->objQuery->getAll("SELECT * FROM test_table"); … … 223 223 function testUpdate() { 224 224 $this->createTestTable(); 225 $this->setTestData(1, "2", "f");226 227 $this->objQuery->update( "test_table",228 array( "id" => "1",229 "column1" => "2",230 "column2" => "2",231 "column3" => "f"),225 $this->setTestData(1, '2', 'f'); 226 227 $this->objQuery->update('test_table', 228 array('id' => '1', 229 'column1' => '2', 230 'column2' => '2', 231 'column3' => 'f'), 232 232 "id = ?", array(1)); 233 $this->expected = array(array( "id" => "1",234 "column1" => "2",235 "column2" => "2",236 "column3" => "f"));233 $this->expected = array(array('id' => '1', 234 'column1' => '2', 235 'column2' => '2', 236 'column3' => 'f')); 237 237 238 238 $this->actual = $this->objQuery->getAll("SELECT * FROM test_table"); … … 243 243 function testListTables() { 244 244 $tables = $this->objQuery->listTables(); 245 $this->assertTrue(in_array( "mtb_zip", $tables));245 $this->assertTrue(in_array('mtb_zip', $tables)); 246 246 } 247 247 248 248 function testListSequences() { 249 249 $sequences = $this->objQuery->listSequences(); 250 $this->assertTrue(in_array( "dtb_products_product_id", $sequences));250 $this->assertTrue(in_array('dtb_products_product_id', $sequences)); 251 251 } 252 252 253 253 function testListTableFields() { 254 $this->expected = array( "id", "name", "rank", "remarks");255 $this->actual = $this->objQuery->listTableFields( "mtb_constants");254 $this->expected = array('id', 'name', 'rank', 'remarks'); 255 $this->actual = $this->objQuery->listTableFields('mtb_constants'); 256 256 $this->verify(); 257 257 } 258 258 259 259 function testListTableIndexes() { 260 $indexes = $this->objQuery->listTableIndexes( "dtb_mobile_kara_mail");261 $this->assertTrue(in_array( "dtb_mobile_kara_mail_create_date_key", $indexes));260 $indexes = $this->objQuery->listTableIndexes('dtb_mobile_kara_mail'); 261 $this->assertTrue(in_array('dtb_mobile_kara_mail_create_date_key', $indexes)); 262 262 } 263 263 … … 274 274 function dropTestTable() { 275 275 $tables = $this->objQuery->listTables(); 276 if (in_array( "test_table", $tables)) {276 if (in_array('test_table', $tables)) { 277 277 $this->objQuery->query("DROP TABLE test_table"); 278 278 }
Note: See TracChangeset
for help on using the changeset viewer.
