| @@ 258-314 (lines=57) @@ | ||
| 255 | self::assertCount(0, $tableDiff->changedColumns, "Nothing should be changed as all fields old & new have diff names."); |
|
| 256 | } |
|
| 257 | ||
| 258 | public function testCompareRemovedIndex() |
|
| 259 | { |
|
| 260 | $schema1 = new Schema(array( |
|
| 261 | 'bugdb' => new Table( |
|
| 262 | 'bugdb', |
|
| 263 | array ( |
|
| 264 | 'integerfield1' => new Column('integerfield1', Type::getType('integer')), |
|
| 265 | 'integerfield2' => new Column('integerfield2', Type::getType('integer')), |
|
| 266 | ), |
|
| 267 | array ( |
|
| 268 | 'primary' => new Index( |
|
| 269 | 'primary', |
|
| 270 | array( |
|
| 271 | 'integerfield1' |
|
| 272 | ), |
|
| 273 | true |
|
| 274 | ) |
|
| 275 | ) |
|
| 276 | ), |
|
| 277 | )); |
|
| 278 | $schema2 = new Schema(array( |
|
| 279 | 'bugdb' => new Table( |
|
| 280 | 'bugdb', |
|
| 281 | array ( |
|
| 282 | 'integerfield1' => new Column('integerfield1', Type::getType('integer')), |
|
| 283 | 'integerfield2' => new Column('integerfield2', Type::getType('integer')), |
|
| 284 | ) |
|
| 285 | ), |
|
| 286 | )); |
|
| 287 | ||
| 288 | $expected = new SchemaDiff( |
|
| 289 | array(), |
|
| 290 | array ( |
|
| 291 | 'bugdb' => new TableDiff( |
|
| 292 | 'bugdb', |
|
| 293 | array(), |
|
| 294 | array(), |
|
| 295 | array(), |
|
| 296 | array(), |
|
| 297 | array(), |
|
| 298 | array ( |
|
| 299 | 'primary' => new Index( |
|
| 300 | 'primary', |
|
| 301 | array( |
|
| 302 | 'integerfield1' |
|
| 303 | ), |
|
| 304 | true |
|
| 305 | ) |
|
| 306 | ) |
|
| 307 | ), |
|
| 308 | ) |
|
| 309 | ); |
|
| 310 | $expected->fromSchema = $schema1; |
|
| 311 | $expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb'); |
|
| 312 | ||
| 313 | self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); |
|
| 314 | } |
|
| 315 | ||
| 316 | public function testCompareNewIndex() |
|
| 317 | { |
|
| @@ 316-370 (lines=55) @@ | ||
| 313 | self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); |
|
| 314 | } |
|
| 315 | ||
| 316 | public function testCompareNewIndex() |
|
| 317 | { |
|
| 318 | $schema1 = new Schema(array( |
|
| 319 | 'bugdb' => new Table( |
|
| 320 | 'bugdb', |
|
| 321 | array ( |
|
| 322 | 'integerfield1' => new Column('integerfield1', Type::getType('integer')), |
|
| 323 | 'integerfield2' => new Column('integerfield2', Type::getType('integer')), |
|
| 324 | ) |
|
| 325 | ), |
|
| 326 | )); |
|
| 327 | $schema2 = new Schema(array( |
|
| 328 | 'bugdb' => new Table( |
|
| 329 | 'bugdb', |
|
| 330 | array ( |
|
| 331 | 'integerfield1' => new Column('integerfield1', Type::getType('integer')), |
|
| 332 | 'integerfield2' => new Column('integerfield2', Type::getType('integer')), |
|
| 333 | ), |
|
| 334 | array ( |
|
| 335 | 'primary' => new Index( |
|
| 336 | 'primary', |
|
| 337 | array( |
|
| 338 | 'integerfield1' |
|
| 339 | ), |
|
| 340 | true |
|
| 341 | ) |
|
| 342 | ) |
|
| 343 | ), |
|
| 344 | )); |
|
| 345 | ||
| 346 | $expected = new SchemaDiff( |
|
| 347 | array(), |
|
| 348 | array ( |
|
| 349 | 'bugdb' => new TableDiff( |
|
| 350 | 'bugdb', |
|
| 351 | array(), |
|
| 352 | array(), |
|
| 353 | array(), |
|
| 354 | array ( |
|
| 355 | 'primary' => new Index( |
|
| 356 | 'primary', |
|
| 357 | array( |
|
| 358 | 'integerfield1' |
|
| 359 | ), |
|
| 360 | true |
|
| 361 | ) |
|
| 362 | ) |
|
| 363 | ), |
|
| 364 | ) |
|
| 365 | ); |
|
| 366 | $expected->fromSchema = $schema1; |
|
| 367 | $expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb'); |
|
| 368 | ||
| 369 | self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); |
|
| 370 | } |
|
| 371 | ||
| 372 | public function testCompareChangedIndex() |
|
| 373 | { |
|