$this->fail("Expected exception for no pk");
}
+ public function testCreateTableWithExplicitPk()
+ {
+ $table = $this->_conn->createTable('testings');
+ $table->column('foo', 'primaryKey');
+
+ $pkColumn = $table['foo'];
+ $this->assertEquals('`foo` int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', $pkColumn->toSql());
+ }
+
public function testCreateTableForce()
{
$this->_createTestTable('sports');
public function testAddColumnNotNullWithoutDefault()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string');
+ $table->column('foo', 'string');
$table->end();
$this->_conn->addColumn('testings', 'bar', 'string', array('null' => false, 'default' => ''));
$this->_conn->execute("INSERT INTO testings (foo, bar) VALUES ('hello', NULL)");
} catch (Exception $e) { return; }
$this->fail('Expected exception wasn\'t raised');
-
}
public function testAddColumnNotNullWithDefault()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string');
+ $table->column('foo', 'string');
$table->end();
$this->_conn->execute("INSERT INTO testings (id, foo) VALUES ('1', 'hello')");
public function testTransactionRollback()
{
$this->_conn->beginDbTransaction();
- $sql = "INSERT INTO unit_tests (id, integer_value) VALUES (7, 999)";
- $this->_conn->insert($sql);
- $this->_conn->rollbackDbTransaction();
+ $sql = "INSERT INTO unit_tests (id, integer_value) VALUES (7, 999)";
+ $this->_conn->insert($sql);
+ $this->_conn->rollbackDbTransaction();
- // make sure it inserted
- $sql = "SELECT integer_value FROM unit_tests WHERE id='7'";
- $this->assertEquals(null, $this->_conn->selectValue($sql));
+ // make sure it inserted
+ $sql = "SELECT integer_value FROM unit_tests WHERE id='7'";
+ $this->assertEquals(null, $this->_conn->selectValue($sql));
}
$this->fail("Expected exception for no pk");
}
+ public function testCreateTableWithExplicitPk()
+ {
+ $table = $this->_conn->createTable('testings');
+ $table->column('foo', 'primaryKey');
+
+ $pkColumn = $table['foo'];
+ $this->assertEquals('"foo" serial primary key', $pkColumn->toSql());
+ }
+
public function testCreateTableForce()
{
$this->_createTestTable('sports');
$this->fail("Expected exception for no pk");
}
+ public function testCreateTableWithExplicitPk()
+ {
+ $table = $this->_conn->createTable('testings');
+ $table->column('foo', 'primaryKey');
+
+ $pkColumn = $table['foo'];
+ $this->assertEquals('"foo" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL', $pkColumn->toSql());
+ }
+
public function testCreateTableForce()
{
$this->_createTestTable('sports');
public function testCreateTableAddsId()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string');
+ $table->column('foo', 'string');
$table->end();
$columns = array();
public function testCreateTableWithNotNullColumn()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string', array('null' => false));
+ $table->column('foo', 'string', array('null' => false));
$table->end();
try {
public function testCreateTableWithDefaults()
{
$table = $this->_conn->createTable('testings');
- $table->column('one', 'string', array('default' => 'hello'));
- $table->column('two', 'boolean', array('default' => true));
- $table->column('three', 'boolean', array('default' => false));
- $table->column('four', 'integer', array('default' => 1));
+ $table->column('one', 'string', array('default' => 'hello'));
+ $table->column('two', 'boolean', array('default' => true));
+ $table->column('three', 'boolean', array('default' => false));
+ $table->column('four', 'integer', array('default' => 1));
$table->end();
$columns = array();
public function testCreateTableWithLimits()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string', array('limit' => 80));
+ $table->column('foo', 'string', array('limit' => 80));
$table->end();
$columns = array();
{
try {
$table = $this->_conn->createTable('binary_testings');
- $table->column('data', 'binary', array('null' => false));
+ $table->column('data', 'binary', array('null' => false));
$table->end();
} catch (Exception $e) { $this->fail('Unexepected exception raised'); }
public function testAddColumnNotNullWithoutDefault()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string');
+ $table->column('foo', 'string');
$table->end();
$this->_conn->addColumn('testings', 'bar', 'string', array('null' => false, 'default' => ''));
$this->_conn->execute("INSERT INTO testings (foo, bar) VALUES ('hello', NULL)");
} catch (Exception $e) { return; }
$this->fail('Expected exception wasn\'t raised');
-
}
public function testAddColumnNotNullWithDefault()
{
$table = $this->_conn->createTable('testings');
- $table->column('foo', 'string');
+ $table->column('foo', 'string');
$table->end();
$this->_conn->execute("INSERT INTO testings (id, foo) VALUES ('1', 'hello')");