Commit a108327d authored by zYne's avatar zYne

--no commit message

--no commit message
parent 50c9cf3b
......@@ -86,6 +86,17 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($sql[0], 'CREATE TABLE mysql_group (id BIGINT AUTO_INCREMENT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB');
}
public function testExportModelFromDirectory()
{
Doctrine::export(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files2');
$this->assertEqual($this->adapter->pop(), 'COMMIT');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME, parent BIGINT, position MEDIUMINT, active BIGINT, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE cms__category ADD CONSTRAINT FOREIGN KEY (category_id) REFERENCES cms__category_languages(id) ON DELETE CASCADE');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT, category_id BIGINT, language_id BIGINT, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
}
}
class ForeignKeyTest extends Doctrine_Record
{
......@@ -172,3 +183,4 @@ class MysqlTestRecord extends Doctrine_Record
$this->option('type', 'INNODB');
}
}
<?php
class Cms_CategoryLanguages extends Doctrine_Record
{
public function setUp()
{
$this->setAttribute(Doctrine::ATTR_COLL_KEY, 'language_id');
$this->hasOne('Cms_Category as category', array('local' => 'category_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
}
public function setTableDefinition()
{
$this->hasColumn('name', 'string',256);
$this->hasColumn('category_id', 'integer',11);
$this->hasColumn('language_id', 'integer',11);
$this->option('collate', 'utf8_unicode_ci');
$this->option('charset', 'utf8');
$this->option('type', 'INNODB');
$this->index('index_category', array('fields' => 'category_id'));
$this->index('index_language', array('fields' => 'language_id'));
}
}
class Cms_Category extends Doctrine_Record
{
public function setUp()
{
$this->ownsMany('Cms_CategoryLanguages as langs', array('local' => 'id', 'foreign' => 'category_id'));
}
public function setTableDefinition()
{
$this->hasColumn('created', 'timestamp');
$this->hasColumn('parent', 'integer', 11);
$this->hasColumn('position', 'integer', 3);
$this->hasColumn('active', 'integer', 11);
$this->option('collate', 'utf8_unicode_ci');
$this->option('charset', 'utf8');
$this->option('type', 'INNODB');
$this->index('index_parent', array('fields' => 'parent'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment