1<?php
2
3class Doctrine_Ticket_932_TestCase extends Doctrine_UnitTestCase
4{
5	public function prepareTables()
6	{
7		$this->tables[] = "UserNoAutoIncrement";
8		parent::prepareTables();
9	}
10
11	public function prepareData()
12	{
13	}
14
15	public function testInit()
16	{
17		$this->dbh = new Doctrine_Adapter_Mock('pgsql');
18		$this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh);
19		$this->assertEqual(Doctrine_Core::IDENTIFIER_NATURAL, $this->conn->getTable('UserNoAutoIncrement')->getIdentifierType());
20	}
21
22	public function testCreateNewUserNoAutoIncrement()
23	{
24		$newUser = new UserNoAutoIncrement();
25		$newUser->id = 1;
26		$newUser->display_name = "Mah Name";
27		$newUser->save();
28		$this->assertEqual(Doctrine_Record::STATE_CLEAN, $newUser->state());
29		$this->assertEqual(1, $newUser->id);
30	}
31}
32
33class UserNoAutoIncrement extends Doctrine_Record
34{
35	public function setTableDefinition()
36	{
37		$this->hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => false, 'notnull' => true));
38		$this->hasColumn('display_name', 'string', 255, array('notnull' => true));
39	}
40}
41