1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/tests/Export/PgsqlTestCase.php

45 lines
2.0 KiB
PHP
Raw Normal View History

2006-12-28 00:30:25 +03:00
<?php
class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase {
public function testCreateDatabaseExecutesSql() {
$this->export->createDatabase('db');
$this->assertEqual($this->adapter->pop(), 'CREATE DATABASE db');
}
public function testDropDatabaseExecutesSql() {
$this->export->dropDatabase('db');
$this->assertEqual($this->adapter->pop(), 'DROP DATABASE db');
}
public function testCreateTableSupportsAutoincPks() {
$name = 'mytable';
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
2007-02-10 23:48:45 +03:00
$options = array('primary' => array('id'));
$this->export->createTable($name, $fields, $options);
2006-12-28 00:30:25 +03:00
2007-02-10 23:48:45 +03:00
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id SERIAL, PRIMARY KEY(id))');
2006-12-28 00:30:25 +03:00
}
public function testCreateTableSupportsDefaultAttribute() {
$name = 'mytable';
$fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'),
'type' => array('type' => 'integer', 'length' => 3, 'default' => 12)
);
$options = array('primary' => array('name', 'type'));
$this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INT DEFAULT 12, PRIMARY KEY(name, type))');
}
public function testCreateTableSupportsMultiplePks() {
$name = 'mytable';
$fields = array('name' => array('type' => 'char', 'length' => 10),
'type' => array('type' => 'integer', 'length' => 3));
$options = array('primary' => array('name', 'type'));
$this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INT, PRIMARY KEY(name, type))');
}
}
?>