@@ 387-426 (lines=40) @@ | ||
384 | $this->assertTrue($table->hasIndex('email')); |
|
385 | } |
|
386 | ||
387 | public function testDropIndex() |
|
388 | { |
|
389 | // single column index |
|
390 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
391 | $table->addColumn('email', 'string') |
|
392 | ->addIndex('email') |
|
393 | ->save(); |
|
394 | $this->assertTrue($table->hasIndex('email')); |
|
395 | $this->adapter->dropIndex($table->getName(), 'email'); |
|
396 | $this->assertFalse($table->hasIndex('email')); |
|
397 | ||
398 | // multiple column index |
|
399 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
400 | $table2->addColumn('fname', 'string') |
|
401 | ->addColumn('lname', 'string') |
|
402 | ->addIndex(array('fname', 'lname')) |
|
403 | ->save(); |
|
404 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
405 | $this->adapter->dropIndex($table2->getName(), array('fname', 'lname')); |
|
406 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
407 | ||
408 | // single column index with name specified |
|
409 | $table3 = new \Phinx\Db\Table('table3', array(), $this->adapter); |
|
410 | $table3->addColumn('email', 'string') |
|
411 | ->addIndex('email', array('name' => 'someindexname')) |
|
412 | ->save(); |
|
413 | $this->assertTrue($table3->hasIndex('email')); |
|
414 | $this->adapter->dropIndex($table3->getName(), 'email'); |
|
415 | $this->assertFalse($table3->hasIndex('email')); |
|
416 | ||
417 | // multiple column index with name specified |
|
418 | $table4 = new \Phinx\Db\Table('table4', array(), $this->adapter); |
|
419 | $table4->addColumn('fname', 'string') |
|
420 | ->addColumn('lname', 'string') |
|
421 | ->addIndex(array('fname', 'lname'), array('name' => 'multiname')) |
|
422 | ->save(); |
|
423 | $this->assertTrue($table4->hasIndex(array('fname', 'lname'))); |
|
424 | $this->adapter->dropIndex($table4->getName(), array('fname', 'lname')); |
|
425 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
426 | } |
|
427 | ||
428 | public function testDropIndexByName() |
|
429 | { |
@@ 452-491 (lines=40) @@ | ||
449 | $this->assertEquals(array('email', 'username'), $indexes['email_username']['columns']); |
|
450 | } |
|
451 | ||
452 | public function testDropIndex() |
|
453 | { |
|
454 | // single column index |
|
455 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
456 | $table->addColumn('email', 'string') |
|
457 | ->addIndex('email') |
|
458 | ->save(); |
|
459 | $this->assertTrue($table->hasIndex('email')); |
|
460 | $this->adapter->dropIndex($table->getName(), 'email'); |
|
461 | $this->assertFalse($table->hasIndex('email')); |
|
462 | return; |
|
463 | // multiple column index |
|
464 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
465 | $table2->addColumn('fname', 'string') |
|
466 | ->addColumn('lname', 'string') |
|
467 | ->addIndex(array('fname', 'lname')) |
|
468 | ->save(); |
|
469 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
470 | $this->adapter->dropIndex($table2->getName(), array('fname', 'lname')); |
|
471 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
472 | ||
473 | // index with name specified, but dropping it by column name |
|
474 | $table3 = new \Phinx\Db\Table('table3', array(), $this->adapter); |
|
475 | $table3->addColumn('email', 'string') |
|
476 | ->addIndex('email', array('name' => 'someindexname')) |
|
477 | ->save(); |
|
478 | $this->assertTrue($table3->hasIndex('email')); |
|
479 | $this->adapter->dropIndex($table3->getName(), 'email'); |
|
480 | $this->assertFalse($table3->hasIndex('email')); |
|
481 | ||
482 | // multiple column index with name specified |
|
483 | $table4 = new \Phinx\Db\Table('table4', array(), $this->adapter); |
|
484 | $table4->addColumn('fname', 'string') |
|
485 | ->addColumn('lname', 'string') |
|
486 | ->addIndex(array('fname', 'lname'), array('name' => 'multiname')) |
|
487 | ->save(); |
|
488 | $this->assertTrue($table4->hasIndex(array('fname', 'lname'))); |
|
489 | $this->adapter->dropIndex($table4->getName(), array('fname', 'lname')); |
|
490 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
491 | } |
|
492 | ||
493 | public function testDropIndexByName() |
|
494 | { |
@@ 501-540 (lines=40) @@ | ||
498 | $this->assertTrue($table->hasIndex('email')); |
|
499 | } |
|
500 | ||
501 | public function testDropIndex() |
|
502 | { |
|
503 | // single column index |
|
504 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
505 | $table->addColumn('email', 'string') |
|
506 | ->addIndex('email') |
|
507 | ->save(); |
|
508 | $this->assertTrue($table->hasIndex('email')); |
|
509 | $this->adapter->dropIndex($table->getName(), 'email'); |
|
510 | $this->assertFalse($table->hasIndex('email')); |
|
511 | ||
512 | // multiple column index |
|
513 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
514 | $table2->addColumn('fname', 'string') |
|
515 | ->addColumn('lname', 'string') |
|
516 | ->addIndex(array('fname', 'lname')) |
|
517 | ->save(); |
|
518 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
519 | $this->adapter->dropIndex($table2->getName(), array('fname', 'lname')); |
|
520 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
521 | ||
522 | // index with name specified, but dropping it by column name |
|
523 | $table3 = new \Phinx\Db\Table('table3', array(), $this->adapter); |
|
524 | $table3->addColumn('email', 'string') |
|
525 | ->addIndex('email', array('name' => 'someindexname')) |
|
526 | ->save(); |
|
527 | $this->assertTrue($table3->hasIndex('email')); |
|
528 | $this->adapter->dropIndex($table3->getName(), 'email'); |
|
529 | $this->assertFalse($table3->hasIndex('email')); |
|
530 | ||
531 | // multiple column index with name specified |
|
532 | $table4 = new \Phinx\Db\Table('table4', array(), $this->adapter); |
|
533 | $table4->addColumn('fname', 'string') |
|
534 | ->addColumn('lname', 'string') |
|
535 | ->addIndex(array('fname', 'lname'), array('name' => 'multiname')) |
|
536 | ->save(); |
|
537 | $this->assertTrue($table4->hasIndex(array('fname', 'lname'))); |
|
538 | $this->adapter->dropIndex($table4->getName(), array('fname', 'lname')); |
|
539 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
540 | } |
|
541 | ||
542 | public function testDropIndexByName() |
|
543 | { |