| @@ 743-763 (lines=21) @@ | ||
| 740 | $this->assertTrue($table4->hasIndex(array('fname', 'lname'))); |
|
| 741 | } |
|
| 742 | ||
| 743 | public function testDropIndexByName() |
|
| 744 | { |
|
| 745 | // single column index |
|
| 746 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 747 | $table->addColumn('email', 'string') |
|
| 748 | ->addIndex('email', array('name' => 'myemailindex')) |
|
| 749 | ->save(); |
|
| 750 | $this->assertTrue($table->hasIndex('email')); |
|
| 751 | $this->adapter->dropIndexByName($table->getName(), 'myemailindex'); |
|
| 752 | $this->assertFalse($table->hasIndex('email')); |
|
| 753 | ||
| 754 | // multiple column index |
|
| 755 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
| 756 | $table2->addColumn('fname', 'string') |
|
| 757 | ->addColumn('lname', 'string') |
|
| 758 | ->addIndex(array('fname', 'lname'), array('name' => 'twocolumnindex')) |
|
| 759 | ->save(); |
|
| 760 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
| 761 | $this->adapter->dropIndexByName($table2->getName(), 'twocolumnindex'); |
|
| 762 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
| 763 | } |
|
| 764 | ||
| 765 | public function testAddForeignKey() |
|
| 766 | { |
|
| @@ 428-448 (lines=21) @@ | ||
| 425 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
| 426 | } |
|
| 427 | ||
| 428 | public function testDropIndexByName() |
|
| 429 | { |
|
| 430 | // single column index |
|
| 431 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 432 | $table->addColumn('email', 'string') |
|
| 433 | ->addIndex('email', array('name' => 'myemailindex')) |
|
| 434 | ->save(); |
|
| 435 | $this->assertTrue($table->hasIndex('email')); |
|
| 436 | $this->adapter->dropIndexByName($table->getName(), 'myemailindex'); |
|
| 437 | $this->assertFalse($table->hasIndex('email')); |
|
| 438 | ||
| 439 | // multiple column index |
|
| 440 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
| 441 | $table2->addColumn('fname', 'string') |
|
| 442 | ->addColumn('lname', 'string') |
|
| 443 | ->addIndex(array('fname', 'lname'), array('name' => 'twocolumnindex')) |
|
| 444 | ->save(); |
|
| 445 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
| 446 | $this->adapter->dropIndexByName($table2->getName(), 'twocolumnindex'); |
|
| 447 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
| 448 | } |
|
| 449 | ||
| 450 | public function testAddForeignKey() |
|
| 451 | { |
|
| @@ 493-514 (lines=22) @@ | ||
| 490 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
| 491 | } |
|
| 492 | ||
| 493 | public function testDropIndexByName() |
|
| 494 | { |
|
| 495 | // single column index |
|
| 496 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 497 | $table->addColumn('email', 'string') |
|
| 498 | ->addIndex('email', array('name' => 'myemailindex')) |
|
| 499 | ->save(); |
|
| 500 | $this->assertTrue($table->hasIndex('email')); |
|
| 501 | $this->adapter->dropIndexByName($table->getName(), 'myemailindex'); |
|
| 502 | $this->assertFalse($table->hasIndex('email')); |
|
| 503 | ||
| 504 | // multiple column index |
|
| 505 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
| 506 | $table2->addColumn('fname', 'string') |
|
| 507 | ->addColumn('lname', 'string') |
|
| 508 | ->addIndex(array('fname', 'lname'), |
|
| 509 | array('name' => 'twocolumnuniqueindex', 'unique' => true)) |
|
| 510 | ->save(); |
|
| 511 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
| 512 | $this->adapter->dropIndexByName($table2->getName(), 'twocolumnuniqueindex'); |
|
| 513 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
| 514 | } |
|
| 515 | ||
| 516 | public function testAddForeignKey() |
|
| 517 | { |
|
| @@ 542-563 (lines=22) @@ | ||
| 539 | $this->assertFalse($table4->hasIndex(array('fname', 'lname'))); |
|
| 540 | } |
|
| 541 | ||
| 542 | public function testDropIndexByName() |
|
| 543 | { |
|
| 544 | // single column index |
|
| 545 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 546 | $table->addColumn('email', 'string') |
|
| 547 | ->addIndex('email', array('name' => 'myemailindex')) |
|
| 548 | ->save(); |
|
| 549 | $this->assertTrue($table->hasIndex('email')); |
|
| 550 | $this->adapter->dropIndexByName($table->getName(), 'myemailindex'); |
|
| 551 | $this->assertFalse($table->hasIndex('email')); |
|
| 552 | ||
| 553 | // multiple column index |
|
| 554 | $table2 = new \Phinx\Db\Table('table2', array(), $this->adapter); |
|
| 555 | $table2->addColumn('fname', 'string') |
|
| 556 | ->addColumn('lname', 'string') |
|
| 557 | ->addIndex(array('fname', 'lname'), |
|
| 558 | array('name' => 'twocolumnuniqueindex', 'unique' => true)) |
|
| 559 | ->save(); |
|
| 560 | $this->assertTrue($table2->hasIndex(array('fname', 'lname'))); |
|
| 561 | $this->adapter->dropIndexByName($table2->getName(), 'twocolumnuniqueindex'); |
|
| 562 | $this->assertFalse($table2->hasIndex(array('fname', 'lname'))); |
|
| 563 | } |
|
| 564 | ||
| 565 | public function testAddForeignKey() |
|
| 566 | { |
|