public function testGetPhinxType()
 {
     $this->assertEquals('integer', $this->adapter->getPhinxType('int'));
     $this->assertEquals('integer', $this->adapter->getPhinxType('int4'));
     $this->assertEquals('integer', $this->adapter->getPhinxType('integer'));
     $this->assertEquals('biginteger', $this->adapter->getPhinxType('bigint'));
     $this->assertEquals('biginteger', $this->adapter->getPhinxType('int8'));
     $this->assertEquals('decimal', $this->adapter->getPhinxType('decimal'));
     $this->assertEquals('decimal', $this->adapter->getPhinxType('numeric'));
     $this->assertEquals('float', $this->adapter->getPhinxType('real'));
     $this->assertEquals('float', $this->adapter->getPhinxType('float4'));
     $this->assertEquals('boolean', $this->adapter->getPhinxType('bool'));
     $this->assertEquals('boolean', $this->adapter->getPhinxType('boolean'));
     $this->assertEquals('string', $this->adapter->getPhinxType('character varying'));
     $this->assertEquals('string', $this->adapter->getPhinxType('varchar'));
     $this->assertEquals('text', $this->adapter->getPhinxType('text'));
     $this->assertEquals('time', $this->adapter->getPhinxType('time'));
     $this->assertEquals('time', $this->adapter->getPhinxType('timetz'));
     $this->assertEquals('time', $this->adapter->getPhinxType('time with time zone'));
     $this->assertEquals('time', $this->adapter->getPhinxType('time without time zone'));
     $this->assertEquals('datetime', $this->adapter->getPhinxType('timestamp'));
     $this->assertEquals('datetime', $this->adapter->getPhinxType('timestamptz'));
     $this->assertEquals('datetime', $this->adapter->getPhinxType('timestamp with time zone'));
     $this->assertEquals('datetime', $this->adapter->getPhinxType('timestamp without time zone'));
 }
 public function testInsertData()
 {
     $table = new \Phinx\Db\Table('table1', array(), $this->adapter);
     $table->addColumn('column1', 'string')->addColumn('column2', 'integer')->insert(array("column1", "column2"), array(array('value1', 1), array('value2', 2)))->save();
     $rows = $this->adapter->fetchAll('SELECT * FROM table1');
     $this->assertEquals('value1', $rows[0]['column1']);
     $this->assertEquals('value2', $rows[1]['column1']);
     $this->assertEquals(1, $rows[0]['column2']);
     $this->assertEquals(2, $rows[1]['column2']);
 }
Exemplo n.º 3
0
 /**
  * @depends testCanAddColumnComment
  */
 public function testCanRemoveColumnComment()
 {
     $table = new \Phinx\Db\Table('table1', array(), $this->adapter);
     $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"'))->save();
     $table->changeColumn('field1', 'string', array('comment' => 'null'))->save();
     $row = $this->adapter->fetchRow('SELECT
             (select pg_catalog.col_description(oid,cols.ordinal_position::int)
         from pg_catalog.pg_class c 
         where c.relname=cols.table_name ) as column_comment
         FROM information_schema.columns cols 
         WHERE cols.table_catalog=\'' . TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE . '\'
         AND cols.table_name=\'table1\'
         AND cols.column_name = \'field1\'');
     $this->assertEmpty($row['column_comment'], 'Dont remove column comment correctly');
 }
Exemplo n.º 4
0
 public function testTimestampWithTimezone()
 {
     $table = new \Phinx\Db\Table('tztable', array('id' => false), $this->adapter);
     $table->addColumn('timestamp_tz', 'timestamp', array('timezone' => true))->addColumn('time_tz', 'time', array('timezone' => true))->addColumn('date_notz', 'date', array('timezone' => true))->addColumn('time_notz', 'timestamp')->save();
     $this->assertTrue($this->adapter->hasColumn('tztable', 'timestamp_tz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'time_tz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'date_notz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'time_notz'));
     $columns = $this->adapter->getColumns('tztable');
     foreach ($columns as $column) {
         if (substr($column->getName(), -4) === 'notz') {
             $this->assertFalse($column->isTimezone(), 'column: ' . $column->getName());
         } else {
             $this->assertTrue($column->isTimezone(), 'column: ' . $column->getName());
         }
     }
 }