| @@ 618-630 (lines=13) @@ | ||
| 615 | /** |
|
| 616 | * @dependss testAddColumnComment |
|
| 617 | */ |
|
| 618 | public function testChangeColumnComment() |
|
| 619 | { |
|
| 620 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 621 | $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"')) |
|
| 622 | ->save(); |
|
| 623 | ||
| 624 | $table->changeColumn('field1', 'string', array('comment' => $comment = 'New Comments from column "field1"')) |
|
| 625 | ->save(); |
|
| 626 | ||
| 627 | $resultComment = $this->adapter->getColumnComment('table1', 'field1'); |
|
| 628 | ||
| 629 | $this->assertEquals($comment, $resultComment, 'Dont change column comment correctly'); |
|
| 630 | } |
|
| 631 | ||
| 632 | /** |
|
| 633 | * @depends testAddColumnComment |
|
| @@ 710-731 (lines=22) @@ | ||
| 707 | /** |
|
| 708 | * @depends testCanAddColumnComment |
|
| 709 | */ |
|
| 710 | public function testCanChangeColumnComment() |
|
| 711 | { |
|
| 712 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 713 | $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"')) |
|
| 714 | ->save(); |
|
| 715 | ||
| 716 | $table->changeColumn('field1', 'string', array('comment' => $comment = 'New Comments from column "field1"')) |
|
| 717 | ->save(); |
|
| 718 | ||
| 719 | $row = $this->adapter->fetchRow( |
|
| 720 | 'SELECT |
|
| 721 | (select pg_catalog.col_description(oid,cols.ordinal_position::int) |
|
| 722 | from pg_catalog.pg_class c |
|
| 723 | where c.relname=cols.table_name ) as column_comment |
|
| 724 | FROM information_schema.columns cols |
|
| 725 | WHERE cols.table_catalog=\''. TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE .'\' |
|
| 726 | AND cols.table_name=\'table1\' |
|
| 727 | AND cols.column_name = \'field1\'' |
|
| 728 | ); |
|
| 729 | ||
| 730 | $this->assertEquals($comment, $row['column_comment'], 'Dont change column comment correctly'); |
|
| 731 | } |
|
| 732 | ||
| 733 | /** |
|
| 734 | * @depends testCanAddColumnComment |
|
| @@ 736-757 (lines=22) @@ | ||
| 733 | /** |
|
| 734 | * @depends testCanAddColumnComment |
|
| 735 | */ |
|
| 736 | public function testCanRemoveColumnComment() |
|
| 737 | { |
|
| 738 | $table = new \Phinx\Db\Table('table1', array(), $this->adapter); |
|
| 739 | $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"')) |
|
| 740 | ->save(); |
|
| 741 | ||
| 742 | $table->changeColumn('field1', 'string', array('comment' => 'null')) |
|
| 743 | ->save(); |
|
| 744 | ||
| 745 | $row = $this->adapter->fetchRow( |
|
| 746 | 'SELECT |
|
| 747 | (select pg_catalog.col_description(oid,cols.ordinal_position::int) |
|
| 748 | from pg_catalog.pg_class c |
|
| 749 | where c.relname=cols.table_name ) as column_comment |
|
| 750 | FROM information_schema.columns cols |
|
| 751 | WHERE cols.table_catalog=\''. TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE .'\' |
|
| 752 | AND cols.table_name=\'table1\' |
|
| 753 | AND cols.column_name = \'field1\'' |
|
| 754 | ); |
|
| 755 | ||
| 756 | $this->assertEmpty($row['column_comment'], 'Dont remove column comment correctly'); |
|
| 757 | } |
|
| 758 | ||
| 759 | /** |
|
| 760 | * @depends testCanAddColumnComment |
|
| @@ 803-827 (lines=25) @@ | ||
| 800 | /** |
|
| 801 | * @depends testCanAddColumnComment |
|
| 802 | */ |
|
| 803 | public function testColumnsAreResetBetweenTables() |
|
| 804 | { |
|
| 805 | $table = new \Phinx\Db\Table('widgets', array(), $this->adapter); |
|
| 806 | $table->addColumn('transport', 'string', array( |
|
| 807 | 'comment' => $comment = 'One of: car, boat, truck, plane, train' |
|
| 808 | )) |
|
| 809 | ->save(); |
|
| 810 | ||
| 811 | $table = new \Phinx\Db\Table('things', array(), $this->adapter); |
|
| 812 | $table->addColumn('speed', 'integer') |
|
| 813 | ->save(); |
|
| 814 | ||
| 815 | $row = $this->adapter->fetchRow( |
|
| 816 | 'SELECT |
|
| 817 | (select pg_catalog.col_description(oid,cols.ordinal_position::int) |
|
| 818 | from pg_catalog.pg_class c |
|
| 819 | where c.relname=cols.table_name ) as column_comment |
|
| 820 | FROM information_schema.columns cols |
|
| 821 | WHERE cols.table_catalog=\''. TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE .'\' |
|
| 822 | AND cols.table_name=\'widgets\' |
|
| 823 | AND cols.column_name = \'transport\'' |
|
| 824 | ); |
|
| 825 | ||
| 826 | $this->assertEquals($comment, $row['column_comment'], 'Could not create column comment'); |
|
| 827 | } |
|
| 828 | ||
| 829 | /** |
|
| 830 | * Test that column names are properly escaped when creating Foreign Keys |
|