1
0
mirror of synced 2025-01-30 03:51:43 +03:00
doctrine2/tests/ExportSqliteTestCase.php
2006-12-21 22:06:08 +00:00

64 lines
2.6 KiB
PHP

<?php
class Doctrine_Export_Sqlite_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('sqlite');
}
public function testExportDoesntWorkWithExistingTable() {
$this->manager->setAttribute(Doctrine::ATTR_CREATE_TABLES, false);
$this->adapter->forceException('PDOException', 'table already exist', 123);
$reporter = $this->export->export('User');
// Class name is not valid. Double underscores are not allowed
$this->assertEqual($reporter->pop(), array(E_ERROR, Doctrine::ERR_ALREADY_EXISTS));
}
public function testCreateDatabaseDoesNotExecuteSql() {
try {
$this->export->createDatabase('db');
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testDropDatabaseDoesNotExecuteSql() {
try {
$this->export->dropDatabase('db');
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testCreateTableSupportsAutoincPks() {
$name = 'mytable';
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
$this->export->createTable($name, $fields);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INTEGER UNSIGNED PRIMARY KEY AUTOINCREMENT)');
}
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 INTEGER 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 INTEGER, PRIMARY KEY(name, type))');
}
}
?>