Commit e360684d authored by meus's avatar meus

moved all models to trunk/models. removed some old invalid testcases

parent 7127f12e
<?php
class Account extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('entity_id', 'integer');
$this->hasColumn('amount', 'integer');
}
}
<?php
class Address extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('User', array('local' => 'address_id',
'foreign' => 'user_id',
'refClass' => 'EntityAddress'));
}
public function setTableDefinition() {
$this->hasColumn('address', 'string', 200);
}
}
<?php
class Album extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Song', 'Song.album_id');
}
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
<?php
class App extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 32);
$this->hasColumn('user_id', 'integer', 11);
$this->hasColumn('app_category_id', 'integer', 11);
}
public function setUp() {
$this->hasOne('User', 'User.id');
$this->hasMany('App_Category as Category', 'App_Category.id');
}
}
<?php
class App_Category extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 32);
$this->hasColumn('parent_id', 'integer');
}
public function setUp() {
$this->hasMany('App', 'App.app_category_id');
$this->hasMany('App_Category as Parent', 'App_Category.parent_id');
}
}
<?php
class App_User extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('first_name', 'string', 32);
$this->hasColumn('last_name', 'string', 32);
$this->hasColumn('email', 'string', 128, 'email');
$this->hasColumn('username', 'string', 16, 'unique, nospace');
$this->hasColumn('password', 'string', 128, 'notblank');
$this->hasColumn('country', 'string', 2, 'country');
$this->hasColumn('zipcode', 'string', 9, 'nospace');
}
public function setUp() {
$this->hasMany('App', 'App.user_id');
}
}
<?php
class Assignment extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('task_id', 'integer');
$this->hasColumn('resource_id', 'integer');
}
}
<?php
class Auth extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('roleid', 'integer', 10);
$this->hasColumn('name', 'string', 50);
}
public function setUp()
{
$this->hasOne('Role', array('local' => 'roleid', 'foreign' => 'id'));
}
}
<?php
class Author extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('book_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
<?php
class BadLyNamed__Class extends Doctrine_Record {
public function setTableDefinition() {
}
public function setUp() { }
}
<?php
class BarRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('bar');
$this->hasColumn('name', 'string', 200);
}
public function setUp()
{
$this->hasMany('FooRecord as Foo', array('local' => 'barId', 'foreign' => 'fooId', 'refClass' => 'FooBarRecord'));
}
}
<?php
class BoardWithPosition extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('position', 'integer');
$this->hasColumn('category_id', 'integer');
}
public function setUp() {
$this->hasOne('CategoryWithPosition as Category', 'BoardWithPosition.category_id');
}
}
<?php
class Book extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Author', 'Author.book_id');
}
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
<?php
class BooleanTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('is_working', 'boolean');
$this->hasColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true));
}
}
<?php
class CPK_Association extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('test1_id', 'integer', 11, 'primary');
$this->hasColumn('test2_id', 'integer', 11, 'primary');
}
}
<?php
class CPK_Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasMany('CPK_Test2 as Test', 'CPK_Association.test2_id');
}
}
<?php
class CPK_Test2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasMany('CPK_Test as Test', 'CPK_Association.test1_id');
}
}
<?php
class CascadeDeleteRelatedTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('cscd_id', 'integer');
}
public function setUp()
{
$this->hasOne('CascadeDeleteTest', array('local' => 'cscd_id',
'foreign' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'SET NULL'));
$this->hasMany('CascadeDeleteRelatedTest2 as Related',
array('local' => 'id',
'foreign' => 'cscd_id'));
}
}
<?php
class CascadeDeleteRelatedTest2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('cscd_id', 'integer');
}
public function setUp()
{
$this->hasOne('CascadeDeleteRelatedTest', array('local' => 'cscd_id',
'foreign' => 'id',
'onDelete' => 'SET NULL'));
}
}
<?php
class CascadeDeleteTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
public function setUp()
{
$this->hasMany('CascadeDeleteRelatedTest as Related',
array('local' => 'id',
'foreign' => 'cscd_id'));
}
}
<?php
class CategoryWithPosition extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('position', 'integer');
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->ownsMany('BoardWithPosition as Boards', 'BoardWithPosition.category_id');
}
}
<?php
class CheckConstraintTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('price', 'decimal', 2, array('max' => 5000, 'min' => 100));
$this->hasColumn('discounted_price', 'decimal', 2);
$this->check('price > discounted_price');
}
}
<?php
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' => array('parent')));
}
}
......@@ -19,23 +19,3 @@ class Cms_CategoryLanguages extends Doctrine_Record
$this->index('index_language', array('fields' => array('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' => array('parent')));
}
}
<?php
class ColumnAliasTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('column1 as alias1', 'string', 200);
$this->hasColumn('column2 as alias2', 'integer', 11);
}
public function setUp()
{
}
}
<?php
class ConcreteEmail extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('EmailTemplate');
}
}
<?php
class ConcreteGroup extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('GroupTemplate');
}
}
<?php
class ConcreteGroupUser extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('GroupUserTemplate');
}
}
<?php
class ConcreteInheritanceTestParent extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
}
class ConcreteInheritanceTestChild extends ConcreteInheritanceTestParent
{
public function setTableDefinition()
{
$this->hasColumn('age', 'integer');
parent::setTableDefinition();
}
}
<?php
class ConcreteUser extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('UserTemplate');
}
}
<?php
class CoverageCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('coverage_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
<?php
class CustomPK extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('uid', 'integer',11, 'autoincrement|primary');
$this->hasColumn('name', 'string',255);
}
}
<?php
class CustomSequenceRecord extends Doctrine_Record {
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', null, array('primary', 'sequence' => 'custom_seq'));
$this->hasColumn('name', 'string');
}
}
<?php
class Data_File extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('filename', 'string');
$this->hasColumn('file_owner_id', 'integer');
}
public function setUp() {
$this->hasOne('File_Owner', 'Data_File.file_owner_id');
}
}
<?php
class DateTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('date', 'date', 20);
}
}
<?php
class Description extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('description', 'string',3000);
$this->hasColumn('file_md5', 'string',32);
}
}
<?php
class Element extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
$this->hasColumn('parent_id', 'integer');
}
public function setUp() {
$this->hasMany('Element as Child', 'Child.parent_id');
$this->hasOne('Element as Parent', 'Element.parent_id');
}
}
<?php
class Email extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('address', 'string', 150, 'email|unique');
}
}
<?php
class Entity extends Doctrine_Record
{
public function setUp()
{
$this->ownsOne('Email', array('local' => 'email_id'));
$this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id'));
$this->ownsOne('Account', array('foreign' => 'entity_id'));
$this->hasMany('Entity', array('local' => 'entity1',
'refClass' => 'EntityReference',
'foreign' => 'entity2',
'equal' => true));
}
public function setTableDefinition()
{
$this->hasColumn('id', 'integer',20, 'autoincrement|primary');
$this->hasColumn('name', 'string',50);
$this->hasColumn('loginname', 'string',20, array('unique'));
$this->hasColumn('password', 'string',16);
$this->hasColumn('type', 'integer',1);
$this->hasColumn('created', 'integer',11);
$this->hasColumn('updated', 'integer',11);
$this->hasColumn('email_id', 'integer');
$this->setSubclasses(array("User" => array("type" => 0), "Group" => array("type" => 1)));
}
}
<?php
class EntityAddress extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('address_id', 'integer', null, array('primary' => true));
}
}
<?php
class EntityReference extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('entity1', 'integer', null, 'primary');
$this->hasColumn('entity2', 'integer', null, 'primary');
//$this->setPrimaryKey(array('entity1', 'entity2'));
}
}
<?php
class EnumTest extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
$this->hasColumn('text', 'string');
}
public function setUp() {
$this->hasMany('EnumTest2 as Enum2', array('local' => 'id', 'foreign' => 'enum_test_id'));
$this->hasMany('EnumTest3 as Enum3', array('local' => 'text', 'foreign' => 'text'));
}
}
<?php
class EnumTest2 extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
$this->hasColumn('enum_test_id', 'integer');
}
}
<?php
class EnumTest3 extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('text', 'string', 10, array('primary' => true));
}
}
<?php
class Error extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Description', 'Description.file_md5', 'file_md5');
}
public function setTableDefinition() {
$this->hasColumn('message', 'string',200);
$this->hasColumn('code', 'integer',11);
$this->hasColumn('file_md5', 'string',32, 'primary');
}
}
<?php
class EventListenerChainTest extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
}
public function setUp() {
$chain = new Doctrine_EventListener_Chain();
$chain->add(new Doctrine_EventListener_TestA());
$chain->add(new Doctrine_EventListener_TestB());
}
}
class Doctrine_EventListener_TestA extends Doctrine_EventListener
{
}
class Doctrine_EventListener_TestB extends Doctrine_EventListener
{
}
<?php
class EventListenerTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("name", "string", 100);
$this->hasColumn("password", "string", 8);
}
public function setUp() {
//$this->attribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker());
}
public function getName($name) {
return strtoupper($name);
}
public function setPassword($password) {
return md5($password);
}
}
<?php
class ExpressionTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('amount', 'integer');
}
}
<?php
class FieldNameTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('someColumn', 'string', 200, array('default' => 'some string'));
$this->hasColumn('someEnum', 'enum', 4, array('default' => 'php', 'values' => array('php', 'java', 'python')));
$this->hasColumn('someArray', 'array', 100, array('default' => array()));
$this->hasColumn('someObject', 'object', 200, array('default' => new stdClass));
$this->hasColumn('someInt', 'integer', 20, array('default' => 11));
}
}
<?php
class File_Owner extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasOne('Data_File', 'Data_File.file_owner_id');
}
}
<?php
class FilterTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
}
public function setUp() {
$this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id');
}
}
<?php
class FilterTest2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
$this->hasColumn('test1_id', 'integer');
}
}
<?php
class FooBarRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('fooId', 'integer', null, array('primary' => true));
$this->hasColumn('barId', 'integer', null, array('primary' => true));
}
}
<?php
class FooForeignlyOwned extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
$this->hasColumn('fooId', 'integer');
}
}
<?php
class FooForeignlyOwnedWithPk extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
}
public function setUp()
{
$this->hasOne('FooRecord', array('local' => 'id', 'foreign' => 'id'));
}
}
<?php
class FooLocallyOwned extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
}
}
<?php
class FooRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('foo');
$this->hasColumn('name', 'string', 200, array('notnull' => true));
$this->hasColumn('parent_id', 'integer');
$this->hasColumn('local_foo', 'integer');
}
public function setUp()
{
$this->hasMany('FooRecord as FooFriend', array('local' => 'foo1',
'foreign' => 'foo2',
'equal' => true,
'refClass' => 'FooReferenceRecord',
));
$this->hasMany('FooRecord as FooParents', array('local' => 'foo1',
'foreign' => 'foo2',
'refClass' => 'FooReferenceRecord',
'onDelete' => 'RESTRICT',
));
$this->hasMany('FooRecord as FooChildren', array('local' => 'foo2',
'foreign' => 'foo1',
'refClass' => 'FooReferenceRecord',
));
$this->hasMany('FooRecord as Children', array('local' => 'id', 'foreign' => 'parent_id'));
$this->hasOne('FooRecord as Parent', array('local' => 'parent_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('FooForeignlyOwnedWithPk', array('local' => 'id', 'foreign' => 'id', 'constraint' => true));
$this->hasOne('FooLocallyOwned', array('local' => 'local_foo', 'onDelete' => 'RESTRICT'));
$this->hasMany('BarRecord as Bar', array('local' => 'fooId',
'foreign' => 'barId',
'refClass' => 'FooBarRecord',
'onUpdate' => 'RESTRICT'));
}
}
class FooReferenceRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('foo_reference');
$this->hasColumn('foo1', 'integer', null, array('primary' => true));
$this->hasColumn('foo2', 'integer', null, array('primary' => true));
}
}
class FooBarRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('fooId', 'integer', null, array('primary' => true));
$this->hasColumn('barId', 'integer', null, array('primary' => true));
}
}
class BarRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('bar');
$this->hasColumn('name', 'string', 200);
}
public function setUp()
{
$this->hasMany('FooRecord as Foo', array('local' => 'barId', 'foreign' => 'fooId', 'refClass' => 'FooBarRecord'));
}
}
class FooLocallyOwned extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
}
}
class FooForeignlyOwned extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
$this->hasColumn('fooId', 'integer');
}
}
class FooForeignlyOwnedWithPk extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
}
public function setUp()
{
$this->hasOne('FooRecord', array('local' => 'id', 'foreign' => 'id'));
}
}
<?php
class FooRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('foo');
$this->hasColumn('name', 'string', 200, array('notnull' => true));
$this->hasColumn('parent_id', 'integer');
$this->hasColumn('local_foo', 'integer');
}
public function setUp()
{
$this->hasMany('FooRecord as FooFriend', array('local' => 'foo1',
'foreign' => 'foo2',
'equal' => true,
'refClass' => 'FooReferenceRecord',
));
$this->hasMany('FooRecord as FooParents', array('local' => 'foo1',
'foreign' => 'foo2',
'refClass' => 'FooReferenceRecord',
'onDelete' => 'RESTRICT',
));
$this->hasMany('FooRecord as FooChildren', array('local' => 'foo2',
'foreign' => 'foo1',
'refClass' => 'FooReferenceRecord',
));
$this->hasMany('FooRecord as Children', array('local' => 'id', 'foreign' => 'parent_id'));
$this->hasOne('FooRecord as Parent', array('local' => 'parent_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('FooForeignlyOwnedWithPk', array('local' => 'id', 'foreign' => 'id', 'constraint' => true));
$this->hasOne('FooLocallyOwned', array('local' => 'local_foo', 'onDelete' => 'RESTRICT'));
$this->hasMany('BarRecord as Bar', array('local' => 'fooId',
'foreign' => 'barId',
'refClass' => 'FooBarRecord',
'onUpdate' => 'RESTRICT'));
}
}
<?php
class FooReferenceRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('foo_reference');
$this->hasColumn('foo1', 'integer', null, array('primary' => true));
$this->hasColumn('foo2', 'integer', null, array('primary' => true));
}
}
<?php
class ForeignKeyTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasColumn('code', 'integer', 4);
$this->hasColumn('content', 'string', 4000);
$this->hasColumn('parent_id', 'integer');
$this->hasOne('ForeignKeyTest as Parent',
array('local' => 'parent_id',
'foreign' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'RESTRICT')
);
$this->hasMany('ForeignKeyTest as Children',
'ForeignKeyTest.parent_id');
$this->option('type', 'INNODB');
}
}
<?php
class ForeignKeyTest2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasColumn('foreignkey', 'integer');
$this->hasOne('ForeignKeyTest', 'ForeignKeyTest2.foreignkey');
}
}
<?php
class Forum_Board extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('category_id', 'integer', 10);
$this->hasColumn('name', 'string', 100);
$this->hasColumn('description', 'string', 5000);
}
public function setUp() {
$this->hasOne('Forum_Category as Category', 'Forum_Board.category_id');
$this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id');
}
}
<?php
class Forum_Category extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('root_category_id', 'integer', 10);
$this->hasColumn('parent_category_id', 'integer', 10);
$this->hasColumn('name', 'string', 50);
$this->hasColumn('description', 'string', 99999);
}
public function setUp() {
$this->hasMany('Forum_Category as Subcategory', 'Subcategory.parent_category_id');
$this->hasOne('Forum_Category as Parent', 'Forum_Category.parent_category_id');
$this->hasOne('Forum_Category as Rootcategory', 'Forum_Category.root_category_id');
}
}
<?php
class Forum_Entry extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('author', 'string', 50);
$this->hasColumn('topic', 'string', 100);
$this->hasColumn('message', 'string', 99999);
$this->hasColumn('parent_entry_id', 'integer', 10);
$this->hasColumn('thread_id', 'integer', 10);
$this->hasColumn('date', 'integer', 10);
}
public function setUp() {
$this->hasOne('Forum_Entry as Parent', 'Forum_Entry.parent_entry_id');
$this->hasOne('Forum_Thread as Thread', 'Forum_Entry.thread_id');
}
}
<?php
class Forum_Thread extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('board_id', 'integer', 10);
$this->hasColumn('updated', 'integer', 10);
$this->hasColumn('closed', 'integer', 1);
}
public function setUp() {
$this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id');
$this->ownsMany('Forum_Entry as Entries', 'Forum_Entry.thread_id');
}
}
<?php
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection
// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called
class GroupTable { }
class Group extends Entity {
public function setUp() {
parent::setUp();
$this->hasMany('User', 'Groupuser.user_id');
// $this->option('inheritanceMap', array('type' => 1));
}
}
<?php
class Groupuser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('added', 'integer');
$this->hasColumn('group_id', 'integer');
$this->hasColumn('user_id', 'integer');
}
}
<?php
class GzipTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('gzip', 'gzip', 100000);
}
}
<?php
class InheritanceTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('type', 'string');
$this->setSubclasses(array('InheritanceChildTest' => array('type' => 'type 1'),
'InheritanceChild2Test' => array('type' => 'type 2')));
}
}
class InheritanceChildTest extends InheritanceTest
{ }
class InheritanceChild2Test extends InheritanceTest
{ }
<?php
class JC1 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
<?php
class JC2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
<?php
class JC3 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
<?php
class LiabilityCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('liability_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
<?php
class LocationI18n extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 50, array());
$this->hasColumn('id', 'integer', 10, array('primary' => true));
$this->hasColumn('culture', 'string', 2);
}
public function setUp()
{
$this->hasOne('Location as Location', array('local' => 'id'));
}
}
<?php
class Log_Entry extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('stamp', 'timestamp');
$this->hasColumn('status_id', 'integer');
}
public function setUp() {
$this->hasOne('Log_Status', 'Log_Entry.status_id');
}
}
<?php
class Log_Status extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
}
<?php
class M2MTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
$this->hasColumn('child_id', 'integer');
}
public function setUp() {
$this->hasMany('RTC1 as RTC1', 'JC1.c1_id');
$this->hasMany('RTC2 as RTC2', 'JC1.c1_id');
$this->hasMany('RTC3 as RTC3', 'JC2.c1_id');
$this->hasMany('RTC3 as RTC4', 'JC1.c1_id');
}
}
<?php
class M2MTest2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary'));
$this->hasColumn('name', 'string', 20);
}
public function setUp() {
$this->hasMany('RTC4 as RTC5', 'JC3.c1_id');
}
}
<?php
class MyGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_group');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('name', 'string', 255, array ( 'notnull' => true,));
$this->hasColumn('description', 'string', 4000, array ());
}
public function setUp()
{
$this->hasMany('MyUser as users', array('refClass' => 'MyUserGroup', 'local' => 'group_id', 'foreign' => 'user_id'));
}
}
<?php
class MyOneThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
$this->hasColumn('user_id', 'integer');
}
public function setUp() {
$this->hasMany('MyUserOneThing', 'MyUserOneThing.one_thing_id');
}
}
<?php
class MyOtherThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
$this->hasColumn('user_id', 'integer');
}
public function setUp() {
$this->hasMany('MyUserOtherThing', 'MyUserOtherThing.other_thing_id');
}
}
<?php
class MyUser extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
}
public function setUp() {
$this->hasMany('MyOneThing', 'MyOneThing.user_id');
$this->hasMany('MyOtherThing', 'MyOtherThing.user_id');
}
}
<?php
class MyUser2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_user');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('username', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('algorithm', 'string', 128, array ( 'default' => 'sha1', 'notnull' => true,));
$this->hasColumn('salt', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('password', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('last_login', 'timestamp', null, array ());
$this->hasColumn('is_active', 'boolean', null, array ( 'default' => 1, 'notnull' => true,));
$this->hasColumn('is_super_admin', 'boolean', null, array ( 'default' => 0, 'notnull' => true,));
}
public function setUp()
{
$this->hasMany('MyGroup as groups', array('refClass' => 'MyUserGroup', 'local' => 'user_id', 'foreign' => 'group_id'));
}
}
<?php
class MyUserGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_user_group');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('group_id', 'integer', 4, array ());
$this->hasColumn('user_id', 'integer', 4, array ());
}
public function setUp()
{
$this->hasOne('MyGroup as MyGroup', 'MyUserGroup.group_id');
$this->hasOne('MyUser as MyUser', 'MyUserGroup.user_id');
}
}
<?php
class MyUserOneThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('one_thing_id', 'integer');
}
}
<?php
class MyUserOtherThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('other_thing_id', 'integer');
}
}
<?php
class MysqlGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasMany('MysqlUser', 'MysqlGroupMember.user_id');
}
}
<?php
class MysqlGroupMember extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('group_id', 'integer', null, 'primary');
$this->hasColumn('user_id', 'integer', null, 'primary');
}
}
<?php
class MysqlTestRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, 'primary');
$this->hasColumn('code', 'integer', null, 'primary');
$this->option('type', 'INNODB');
}
}
<?php
class MysqlUser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasMany('MysqlGroup', 'MysqlGroupMember.group_id');
}
}
<?php
class NestReference extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('parent_id', 'integer', 4, 'primary');
$this->hasColumn('child_id', 'integer', 4, 'primary');
}
}
<?php
class NestTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
public function setUp()
{
$this->hasMany('NestTest as Parents', array('local' => 'child_id',
'refClass' => 'NestReference',
'foreign' => 'parent_id'));
$this->hasMany('NestTest as Children', array('local' => 'parent_id',
'refClass' => 'NestReference',
'foreign' => 'child_id'));
$this->hasMany('NestTest as Relatives', array('local' => 'child_id',
'refClass' => 'NestReference',
'foreign' => 'parent_id',
'equal' => true));
}
}
<?php
class NestedSetTest_SingleRootNode extends Doctrine_Record {
public function setTableDefinition() {
$this->actAs('NestedSet');
$this->hasColumn('name', 'string', 50, array('notnull'));
}
}
<?php
class NotNullTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100, 'notnull');
$this->hasColumn('type', 'integer', 11);
}
}
<?php
class ORM_AccessControl extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('ORM_AccessGroup as accessGroups', 'ORM_AccessControlsGroups.accessGroupID');
}
}
<?php
class ORM_AccessControlsGroups extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('accessControlID', 'integer', 11, array('primary' => true));
$this->hasColumn('accessGroupID', 'integer', 11, array('primary' => true));
}
}
<?php
class ORM_AccessGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('ORM_AccessControl as accessControls', 'ORM_AccessControlsGroups.accessControlID');
}
}
<?php
class ORM_TestEntry extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('test_entries');
$this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
$this->hasColumn('name', 'string', 255);
$this->hasColumn('stamp', 'timestamp');
$this->hasColumn('amount', 'float');
$this->hasColumn('itemID', 'integer');
}
public function setUp() {
$this->hasOne('ORM_TestItem', 'ORM_TestEntry.itemID');
}
}
<?php
class ORM_TestItem extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('test_items');
$this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasOne('ORM_TestEntry', 'ORM_TestEntry.itemID');
}
}
<?php
class Package extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id');
}
}
<?php
class PackageVersion extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('package_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('Package', 'PackageVersion.package_id');
$this->hasMany('PackageVersionNotes as Note', 'PackageVersionNotes.package_version_id');
}
}
<?php
class PackageVersionNotes extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('package_version_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('PackageVersion', 'PackageVersionNotes.package_version_id');
}
}
<?php
class Phonenumber extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('phonenumber', 'string',20);
$this->hasColumn('entity_id', 'integer');
}
public function setUp()
{
$this->hasOne('Entity', array('local' => 'entity_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
}
}
<?php
class Photo extends Doctrine_Record {
public function setUp() {
$this->hasMany('Tag', 'Phototag.tag_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
}
}
<?php
class Phototag extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('photo_id', 'integer');
$this->hasColumn('tag_id', 'integer');
}
}
<?php
class Policy extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('policy_number', 'integer', 11, array('unique' => true));
}
public function setUp()
{
$this->hasMany('PolicyAsset as PolicyAssets', array('local' => 'policy_number',
'foreign' => 'policy_number'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
<?php
class PolicyAsset extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('policy_number', 'integer', 11);
$this->hasColumn('value', 'float', 10, array ('notblank' => true,));
}
public function setUp()
{
$this->hasOne('Policy', array('foreign' => 'policy_number',
'local' => 'policy_number'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
<?php
class PolicyCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('policy_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
<?php
class PolicyN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('policies');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('rate_id', 'integer', 4, array ( ));
$this->hasColumn('policy_number', 'integer', 4, array ( 'unique' => true, ));
}
public function setUp(){
$this->hasOne('RateN', array('local' => 'rate_id', 'foreign' => 'id' ));
}
}
<?php
class QueryTest_Board extends Doctrine_Record
{
/**
* Initializes the table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('categoryId as categoryId', 'integer', 4,
array('notnull'));
$this->hasColumn('name as name', 'string', 100,
array('notnull', 'unique'));
$this->hasColumn('lastEntryId as lastEntryId', 'integer', 4,
array('default' => 0, 'notnull'));
$this->hasColumn('position as position', 'integer', 4,
array('default' => 0, 'notnull'));
}
/**
* Initializes the relations.
*/
public function setUp()
{
$this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId');
$this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId');
}
}
<?php
class QueryTest_Category extends Doctrine_Record
{
/**
* The depth of the category inside the tree.
* Non-persistent field.
*
* @var integer
*/
public $depth;
/**
* Table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('rootCategoryId as rootCategoryId', 'integer', 4,
array('default' => 0));
$this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4,
array('notnull', 'default' => 0));
$this->hasColumn('name as name', 'string', 50,
array('notnull', 'unique'));
$this->hasColumn('position as position', 'integer', 4,
array('default' => 0, 'notnull'));
}
/**
* Relations definition.
*/
public function setUp()
{
$this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId');
$this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId');
$this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId');
}
}
<?php
class QueryTest_Entry extends Doctrine_Record
{
/**
* Table structure.
*/
public function setTableDefinition()
{
$this->hasColumn('authorId', 'integer', 4,
array('notnull'));
$this->hasColumn('date', 'integer', 4,
array('notnull'));
}
/**
* Runtime definition of the relationships to other entities.
*/
public function setUp()
{
$this->hasOne('QueryTest_User as author', 'QueryTest_Entry.authorId');
}
}
<?php
class QueryTest_Item extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('price', 'decimal');
$this->hasColumn('quantity', 'integer');
}
}
<?php
class QueryTest_Rank extends Doctrine_Record
{
/**
* Initializes the table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('title as title', 'string', 100,
array('notnull'));
$this->hasColumn('color as color', 'string', 20,
array('notnull', 'regexp' => '/^[a-zA-Z\-]{3,}|#[0-9a-fA-F]{6}$/D'));
$this->hasColumn('icon as icon', 'string', 50,
array('notnull', 'default' => ' ', 'regexp' => '/^[a-zA-Z0-9_\-]+\.(jpg|gif|png)$/D'));
}
public function setUp()
{
$this->hasMany('QueryTest_User as users', 'QueryTest_UserRank.userId');
}
}
<?php
class QueryTest_User extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('username as username', 'string', 50,
array('notnull'));
$this->hasColumn('visibleRankId', 'integer', 4);
}
/**
* Runtime definition of the relationships to other entities.
*/
public function setUp()
{
$this->hasOne('QueryTest_Rank as visibleRank', 'QueryTest_User.visibleRankId');
$this->hasMany('QueryTest_Rank as ranks', 'QueryTest_UserRank.rankId');
}
}
<?php
class QueryTest_UserRank extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('rankId', 'integer', 4, array('primary'));
$this->hasColumn('userId', 'integer', 4, array('primary'));
}
}
<?php
class RTC1 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC1', 'JC1.c2_id');
}
}
<?php
class RTC2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC2', 'JC1.c2_id');
}
}
<?php
class RTC3 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC3', 'JC2.c2_id');
$this->hasMany('M2MTest as RTC4', 'JC1.c2_id');
}
}
<?php
class RTC4 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary'));
$this->hasColumn('name', 'string', 20);
}
public function setUp() {
$this->hasMany('M2MTest2', 'JC3.c2_id');
}
}
<?php
class RateN extends Doctrine_Record{
public function setTableDefinition(){
$this->setTableName('rates');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('policy_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('coverage_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('liability_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('total_rate', 'float', null, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('policy_code_idx', array('fields' => 'policy_code'));
# $this->index('coverage_code_idx', array('fields' => 'coverage_code'));
# $this->index('liability_code_idx', array('fields' => 'liability_code'));
$this->hasOne('PolicyCodeN', array('local' => 'policy_code', 'foreign' => 'code' ));
$this->hasOne('CoverageCodeN', array('local' => 'coverage_code', 'foreign' => 'code' ));
$this->hasOne('LiabilityCodeN', array('local' => 'liability_code', 'foreign' => 'code' ));
}
}
<?php
class Rec1 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('first_name', 'string', 128, array ());
}
public function setUp()
{
$this->ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id'));
}
}
<?php
class Rec2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', 10, array ( 'unique' => true,));
$this->hasColumn('address', 'string', 150, array ());
}
public function setUp()
{
$this->ownsOne('Rec1 as User', 'Rec2.user_id');
}
}
<?php
class RecordFilterTest extends Doctrine_Record {
public function setTableDefinition() {
$this->setAttribute(Doctrine::ATTR_ACCESSORS, Doctrine::ACCESSOR_BOTH);
$this->hasColumn("name", "string", 200);
$this->hasColumn("password", "string", 32);
}
public function setPassword($password) {
return md5($password);
}
public function getName($name) {
return strtoupper($name);
}
}
<?php
class RecordHookTest extends Doctrine_Record
{
protected $_messages = array();
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, array('primary' => true));
}
public function preSave($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postSave($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preInsert($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postInsert($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preUpdate($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postUpdate($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preDelete($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postDelete($event)
{
$this->_messages[] = __FUNCTION__;
}
public function pop()
{
return array_pop($this->_messages);
}
}
<?php
class Record_Country extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('Record_City as City', 'City.country_id');
}
}
class Record_City extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
$this->hasColumn('country_id', 'integer');
$this->hasColumn('district_id', 'integer');
}
public function setUp() {
$this->hasOne('Record_Country as Country', 'Record_City.country_id');
$this->hasOne('Record_District as District', 'Record_City.district_id');
}
}
class Record_District extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
}
<?php
class Record_City extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
$this->hasColumn('country_id', 'integer');
$this->hasColumn('district_id', 'integer');
}
public function setUp() {
$this->hasOne('Record_Country as Country', 'Record_City.country_id');
$this->hasOne('Record_District as District', 'Record_City.district_id');
}
}
<?php
class Record_Country extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('Record_City as City', 'City.country_id');
}
}
<?php
class Record_District extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
}
<?php
class RelationTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
$this->hasColumn('child_id', 'integer');
}
}
<?php
class RelationTestChild extends RelationTest
{
public function setUp()
{
$this->hasOne('RelationTest as Parent', 'RelationTestChild.child_id');
$this->ownsMany('RelationTestChild as Children', 'RelationTestChild.child_id');
}
}
<?php
class ResourceReference extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('type_id', 'integer');
$this->hasColumn('resource_id', 'integer');
}
}
<?php
class Resource extends Doctrine_Record {
public function setUp() {
$this->hasMany('Task as TaskAlias', 'Assignment.task_id');
$this->hasMany('ResourceType as Type', 'ResourceReference.type_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
}
}
<?php
class ResourceType extends Doctrine_Record {
public function setUp() {
$this->hasMany('Resource as ResourceAlias', 'ResourceReference.resource_id');
}
public function setTableDefinition() {
$this->hasColumn('type', 'string',100);
}
}
<?php
class Role extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 20, array('unique' => true));
}
public function setUp()
{
$this->hasMany('Auth', array('local' => 'id', 'foreign' => 'roleid'));
}
}
<?php
class SelfRefTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 50);
$this->hasColumn('created_by', 'integer');
}
public function setUp()
{
$this->hasOne('SelfRefTest as createdBy', array('local' => 'created_by'));
}
}
<?php
class SequenceRecord extends Doctrine_Record {
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', null, array('primary', 'sequence'));
$this->hasColumn('name', 'string');
}
}
<?php
class SerializeTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('serialize_test');
$this->hasColumn('booltest', 'boolean');
$this->hasColumn('integertest', 'integer', 4, array('unsigned' => true));
$this->hasColumn('floattest', 'float');
$this->hasColumn('stringtest', 'string', 200, array('fixed' => true));
$this->hasColumn('arraytest', 'array', 10000);
$this->hasColumn('objecttest', 'object');
$this->hasColumn('blobtest', 'blob');
$this->hasColumn('clobtest', 'clob');
$this->hasColumn('timestamptest', 'timestamp');
$this->hasColumn('timetest', 'time');
$this->hasColumn('datetest', 'date');
$this->hasColumn('enumtest', 'enum', 4,
array(
'values' => array(
'php',
'java',
'python'
)
)
);
$this->hasColumn('gziptest', 'gzip');
}
}
<?php
class SoftDeleteTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, array('primary' => true));
$this->hasColumn('something', 'string', '25', array('notnull' => true, 'unique' => true));
$this->hasColumn('deleted', 'boolean', 1);
}
public function preDelete($event)
{
$event->skipOperation();
}
public function postDelete($event)
{
$this->deleted = true;
$this->save();
}
}
<?php
class Song extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('album_id', 'integer');
$this->hasColumn('genre', 'string',20);
$this->hasColumn('title', 'string',30);
}
}
<?php
class Tag extends Doctrine_Record {
public function setUp() {
$this->hasMany('Photo', 'Phototag.photo_id');
}
public function setTableDefinition() {
$this->hasColumn('tag', 'string', 100);
}
}
<?php
class Task extends Doctrine_Record {
public function setUp() {
$this->hasMany('Resource as ResourceAlias', 'Assignment.resource_id');
$this->hasMany('Task as Subtask', 'Subtask.parent_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
$this->hasColumn('parent_id', 'integer');
}
}
<?php
class TestMovie extends Doctrine_Record
{
public function setUp()
{
$this->hasOne('TestUser as User',
array('local' => 'user_id',
'foreign' => 'id'));
$this->hasMany('TestUser as MovieBookmarks',
array('local' => 'movie_id',
'foreign' => 'user_id',
'refClass' => 'TestMovieUserBookmark'));
$this->hasMany('TestUser as MovieVotes',
array('local' => 'movie_id',
'foreign' => 'user_id',
'refClass' => 'TestMovieUserVote'));
}
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null);
$this->hasColumn('name', 'string', 30);
}
}
<?php
class TestMovieUserBookmark extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('movie_id', 'integer', null, array('primary' => true));
}
}
<?php
class TestMovieUserVote extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('vote', 'string', 30);
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('movie_id', 'integer', null, array('primary' => true));
}
}
<?php
class TestRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('test');
}
}
<?php
class TestUser extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('TestMovie as UserBookmarks',
array('local' => 'user_id',
'foreign' => 'movie_id',
'refClass' => 'TestMovieUserBookmark'));
$this->hasMany('TestMovie as UserVotes',
array('local' => 'user_id',
'foreign' => 'movie_id',
'refClass' => 'TestMovieUserVote'));
}
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 30);
}
}
<?php
class TreeLeaf extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('parent_id', 'integer');
}
public function setUp()
{
$this->hasOne('TreeLeaf as Parent', 'TreeLeaf.parent_id');
$this->hasMany('TreeLeaf as Children', 'TreeLeaf.parent_id');
}
}
<?php
class UserTable extends Doctrine_Table { }
class User extends Entity
{
public function setUp()
{
parent::setUp();
$this->hasMany('Address', array('local' => 'user_id',
'foreign' => 'address_id',
'refClass' => 'EntityAddress'));
$this->ownsMany('Album', 'Album.user_id');
$this->ownsMany('Book', 'Book.user_id');
$this->hasMany('Group', 'Groupuser.group_id');
// $this->option('inheritanceMap', array('type' => 0));
}
/** Custom validation */
public function validate()
{
// Allow only one name!
if ($this->name !== 'The Saint') {
$this->errorStack()->add('name', 'notTheSaint');
}
}
public function validateOnInsert()
{
if ($this->password !== 'Top Secret') {
$this->errorStack()->add('password', 'pwNotTopSecret');
}
}
public function validateOnUpdate()
{
if ($this->loginname !== 'Nobody') {
$this->errorStack()->add('loginname', 'notNobody');
}
}
}
<?php
class ValidatorTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('mymixed', 'string', 100);
$this->hasColumn('mystring', 'string', 100, 'notnull|unique');
$this->hasColumn('myarray', 'array', 1000);
$this->hasColumn('myobject', 'object', 1000);
$this->hasColumn('myinteger', 'integer', 11);
$this->hasColumn('myrange', 'integer', 11, array('range' => array(4,123)));
$this->hasColumn('myregexp', 'string', 5, array('regexp' => '/^[0-9]+$/'));
$this->hasColumn('myemail', 'string', 100, 'email');
$this->hasColumn('myemail2', 'string', 100, 'email|notblank');
}
}
<?php
class ValidatorTest_AddressModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("id", "integer", 11, array('autoincrement' => true,
'primary' => true
));
$this->hasColumn('address1', 'string', 255, array('notnull' => true, 'notblank'));
$this->hasColumn('address2', 'string', 255, array('notnull' => true));
$this->hasColumn('city', 'string', 255, array('notnull' => true, 'notblank'));
$this->hasColumn('state', 'string', 10, array('notnull' => true, 'notblank', 'usstate'));
$this->hasColumn('zip', 'string', 15, array('notnull' => true, 'notblank', 'regexp' => '/^[0-9-]*$/'));
}
public function setUp() {
$this->hasMany('ValidatorTest_ClientModel', array('local' => 'address_id', 'foreign' => 'client_id', 'refClass' => 'ValidatorTest_ClientToAddressModel'));
}
}
<?php
class ValidatorTest_ClientModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('id', 'integer', 4, array('notnull' => true,
'primary' => true,
'autoincrement' => true,
'unsigned' => true));
$this->hasColumn('short_name', 'string', 32, array('notnull' => true, 'notblank', 'unique' => true));
}
public function setUp() {
$this->hasMany("ValidatorTest_AddressModel", array('local' => 'client_id', 'foreign' => 'address_id', 'refClass' => 'ValidatorTest_ClientToAddressModel'));
}
}
<?php
class ValidatorTest_ClientToAddressModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("client_id", "integer", 11, array('primary' => true));
$this->hasColumn("address_id", "integer", 11, array('primary' => true));
}
public function construct(){
}
public function setUp() {
}
}
<?php
class ValidatorTest_FootballPlayer extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('person_id', 'string', 255);
$this->hasColumn('team_name', 'string', 255);
$this->hasColumn('goals_count', 'integer', 4);
}
}
<?php
class ValidatorTest_Person extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('identifier', 'integer', 4, array('notblank', 'unique'));
$this->hasColumn('is_football_player', 'boolean');
}
public function setUp() {
$this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id');
}
}
<?php
class VersioningTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('version', 'integer');
}
public function setUp()
{
$this->actAs('Versionable');
}
}
<?php
class ZeroValueTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true,));
$this->hasColumn('username', 'string', 128, array('notnull' => true,));
$this->hasColumn('algorithm', 'string', 128, array('default' => 'sha1', 'notnull' => true,));
$this->hasColumn('salt', 'string', 128, array('notnull' => true,));
$this->hasColumn('password', 'string', 128, array('notnull' => true,));
$this->hasColumn('created_at', 'timestamp', null, array());
$this->hasColumn('last_login', 'timestamp', null, array());
$this->hasColumn('is_active', 'boolean', null, array('default' => true, 'notnull' => true,));
$this->hasColumn('is_super_admin', 'boolean', null, array('default' => false, 'notnull' => true,));
}
public function setUp()
{ }
}
<?php
class mmrGroupUser_B extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'string', 30, array('primary' => true));
$this->hasColumn('group_id', 'string', 30, array('primary' => true));
}
}
<?php
class mmrGroupUser_C extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'string', 30, array('primary' => true));
$this->hasColumn('group_id', 'string', 30, array('primary' => true));
}
}
<?php
class mmrGroup_B extends Doctrine_Record
{
public function setUp() {
$this->hasMany('mmrUser_B', array('local' => 'group_id',
'foreign' => 'user_id',
'refClass' => 'mmrGroupUser_B'));
}
public function setTableDefinition() {
// Works when
$this->hasColumn('id', 'string', 30, array ( 'primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
<?php
class mmrGroup_C extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('mmrUser_C', array('local' => 'group_id',
'foreign' => 'user_id',
'refClass' => 'mmrGroupUser_C'));
}
public function setTableDefinition()
{
$this->hasColumn('g_id as id', 'string', 30, array('primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
<?php
class mmrUser_B extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('mmrGroup_B as Group', array('local' => 'user_id',
'foreign' => 'group_id',
'refClass' => 'mmrGroupUser_B'));
}
public function setTableDefinition()
{
// Works when
$this->hasColumn('id', 'string', 30, array ( 'primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
......@@ -79,15 +79,3 @@ class Doctrine_AuditLog_TestCase extends Doctrine_UnitTestCase
}
}
}
class VersioningTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('version', 'integer');
}
public function setUp()
{
$this->actAs('Versionable');
}
}
......@@ -80,18 +80,3 @@ class Doctrine_ColumnAggregationInheritance_TestCase extends Doctrine_UnitTestCa
$this->assertEqual('type 1', $child->type);
}
}
class InheritanceTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('type', 'string');
$this->setSubclasses(array('InheritanceChildTest' => array('type' => 'type 1'),
'InheritanceChild2Test' => array('type' => 'type 2')));
}
}
class InheritanceChildTest extends InheritanceTest
{ }
class InheritanceChild2Test extends InheritanceTest
{ }
......@@ -104,14 +104,4 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll[0]->alias1, 'someone');
}
}
class ColumnAliasTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('column1 as alias1', 'string', 200);
$this->hasColumn('column2 as alias2', 'integer', 11);
}
public function setUp()
{
}
}
......@@ -47,24 +47,4 @@ class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase
}
}
class EventListenerChainTest extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
}
public function setUp() {
$chain = new Doctrine_EventListener_Chain();
$chain->add(new Doctrine_EventListener_TestA());
$chain->add(new Doctrine_EventListener_TestB());
}
}
class Doctrine_EventListener_TestA extends Doctrine_EventListener
{
}
class Doctrine_EventListener_TestB extends Doctrine_EventListener
{
}
......@@ -174,21 +174,7 @@ class Doctrine_EventListener_TestCase extends Doctrine_UnitTestCase {
}
*/
}
class EventListenerTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("name", "string", 100);
$this->hasColumn("password", "string", 8);
}
public function setUp() {
//$this->attribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker());
}
public function getName($name) {
return strtoupper($name);
}
public function setPassword($password) {
return md5($password);
}
}
class Doctrine_EventListener_TestLogger implements Doctrine_Overloadable, Countable {
private $messages = array();
......
......@@ -54,12 +54,3 @@ class Doctrine_Export_CheckConstraint_TestCase extends Doctrine_UnitTestCase
}
}
}
class CheckConstraintTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('price', 'decimal', 2, array('max' => 5000, 'min' => 100));
$this->hasColumn('discounted_price', 'decimal', 2);
$this->check('price > discounted_price');
}
}
......@@ -98,89 +98,3 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
}
}
class ForeignKeyTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasColumn('code', 'integer', 4);
$this->hasColumn('content', 'string', 4000);
$this->hasColumn('parent_id', 'integer');
$this->hasOne('ForeignKeyTest as Parent',
array('local' => 'parent_id',
'foreign' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'RESTRICT')
);
$this->hasMany('ForeignKeyTest as Children',
'ForeignKeyTest.parent_id');
$this->option('type', 'INNODB');
}
}
class MysqlGroupMember extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('group_id', 'integer', null, 'primary');
$this->hasColumn('user_id', 'integer', null, 'primary');
}
}
class MysqlUser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasMany('MysqlGroup', 'MysqlGroupMember.group_id');
}
}
class MysqlGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasMany('MysqlUser', 'MysqlGroupMember.user_id');
}
}
class ForeignKeyTest2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasColumn('foreignkey', 'integer');
$this->hasOne('ForeignKeyTest', 'ForeignKeyTest2.foreignkey');
}
}
class MysqlIndexTestRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null);
$this->hasColumn('code', 'integer', 4);
$this->hasColumn('content', 'string', 4000);
$this->index('content', array('fields' => 'content', 'type' => 'fulltext'));
$this->index('namecode', array('fields' => array('name', 'code'),
'type' => 'unique'));
$this->option('type', 'MYISAM');
}
}
class MysqlTestRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, 'primary');
$this->hasColumn('code', 'integer', null, 'primary');
$this->option('type', 'INNODB');
}
}
<?php
class BadLyNamed__Class extends Doctrine_Record {
public function setTableDefinition() {
}
public function setUp() { }
}
class Doctrine_Export_Reporter_TestCase extends Doctrine_UnitTestCase {
public function testExportChecksClassNaming() {
$reporter = $this->export->export('BadLyNamed__Class');
......
......@@ -70,11 +70,4 @@ class Doctrine_Expression_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($e->getSql(), "SUBSTR(CONCAT('some', 'one'), 0, 3)");
}
}
class ExpressionTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('amount', 'integer');
}
}
......@@ -69,50 +69,3 @@ class Doctrine_IntegrityAction_TestCase extends Doctrine_UnitTestCase
$c->delete();
}
}
class CascadeDeleteTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
public function setUp()
{
$this->hasMany('CascadeDeleteRelatedTest as Related',
array('local' => 'id',
'foreign' => 'cscd_id'));
}
}
class CascadeDeleteRelatedTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('cscd_id', 'integer');
}
public function setUp()
{
$this->hasOne('CascadeDeleteTest', array('local' => 'cscd_id',
'foreign' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'SET NULL'));
$this->hasMany('CascadeDeleteRelatedTest2 as Related',
array('local' => 'id',
'foreign' => 'cscd_id'));
}
}
class CascadeDeleteRelatedTest2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('cscd_id', 'integer');
}
public function setUp()
{
$this->hasOne('CascadeDeleteRelatedTest', array('local' => 'cscd_id',
'foreign' => 'id',
'onDelete' => 'SET NULL'));
}
}
......@@ -44,19 +44,3 @@ class Doctrine_OneTableOneClassInheritance_TestCase extends Doctrine_UnitTestCas
$this->assertEqual($sql[1], 'CREATE TABLE concrete_inheritance_test_child (id INTEGER PRIMARY KEY AUTOINCREMENT, age INTEGER, name VARCHAR(2147483647))');
}
}
class ConcreteInheritanceTestParent extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
}
class ConcreteInheritanceTestChild extends ConcreteInheritanceTestParent
{
public function setTableDefinition()
{
$this->hasColumn('age', 'integer');
parent::setTableDefinition();
}
}
......@@ -215,13 +215,5 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
}
}
class QueryTest_Item extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('price', 'decimal');
$this->hasColumn('quantity', 'integer');
}
}
?>
......@@ -111,31 +111,3 @@ class Doctrine_Query_Expression_TestCase extends Doctrine_UnitTestCase
$this->conn->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL);
}
}
class Location extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('lat', 'double', 10, array ());
$this->hasColumn('lon', 'double', 10, array ());
}
public function setUp()
{
$this->hasMany('LocationI18n as LocationI18n', array('local' => 'id', 'foreign' => 'id'));
}
}
class LocationI18n extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 50, array());
$this->hasColumn('id', 'integer', 10, array('primary' => true));
$this->hasColumn('culture', 'string', 2);
}
public function setUp()
{
$this->hasOne('Location as Location', array('local' => 'id'));
}
}
......@@ -100,71 +100,4 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
$this->fail();
}
}
}
class SoftDeleteTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, array('primary' => true));
$this->hasColumn('something', 'string', '25', array('notnull' => true, 'unique' => true));
$this->hasColumn('deleted', 'boolean', 1);
}
public function preDelete($event)
{
$event->skipOperation();
}
public function postDelete($event)
{
$this->deleted = true;
$this->save();
}
}
class RecordHookTest extends Doctrine_Record
{
protected $_messages = array();
public function setTableDefinition()
{
$this->hasColumn('name', 'string', null, array('primary' => true));
}
public function preSave($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postSave($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preInsert($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postInsert($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preUpdate($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postUpdate($event)
{
$this->_messages[] = __FUNCTION__;
}
public function preDelete($event)
{
$this->_messages[] = __FUNCTION__;
}
public function postDelete($event)
{
$this->_messages[] = __FUNCTION__;
}
public function pop()
{
return array_pop($this->_messages);
}
}
......@@ -21,31 +21,3 @@ class Doctrine_Record_Lock_TestCase extends Doctrine_UnitTestCase {
$this->pass();
}
}
class Rec1 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('first_name', 'string', 128, array ());
}
public function setUp()
{
$this->ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id'));
}
}
class Rec2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', 10, array ( 'unique' => true,));
$this->hasColumn('address', 'string', 150, array ());
}
public function setUp()
{
$this->ownsOne('Rec1 as User', 'Rec2.user_id');
}
}
......@@ -60,61 +60,3 @@ class Doctrine_Record_SaveBlankRecord_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(isset($user['id']));
}
}
class MyUserGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_user_group');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('group_id', 'integer', 4, array ());
$this->hasColumn('user_id', 'integer', 4, array ());
}
public function setUp()
{
$this->hasOne('MyGroup as MyGroup', 'MyUserGroup.group_id');
$this->hasOne('MyUser as MyUser', 'MyUserGroup.user_id');
}
}
class MyGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_group');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('name', 'string', 255, array ( 'notnull' => true,));
$this->hasColumn('description', 'string', 4000, array ());
}
public function setUp()
{
$this->hasMany('MyUser as users', array('refClass' => 'MyUserGroup', 'local' => 'group_id', 'foreign' => 'user_id'));
}
}
class MyUser2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('my_user');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('username', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('algorithm', 'string', 128, array ( 'default' => 'sha1', 'notnull' => true,));
$this->hasColumn('salt', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('password', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('last_login', 'timestamp', null, array ());
$this->hasColumn('is_active', 'boolean', null, array ( 'default' => 1, 'notnull' => true,));
$this->hasColumn('is_super_admin', 'boolean', null, array ( 'default' => 0, 'notnull' => true,));
}
public function setUp()
{
$this->hasMany('MyGroup as groups', array('refClass' => 'MyUserGroup', 'local' => 'user_id', 'foreign' => 'group_id'));
}
}
\ No newline at end of file
......@@ -102,37 +102,6 @@ class Doctrine_Record_SerializeUnserialize_TestCase extends Doctrine_UnitTestCas
}
class SerializeTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('serialize_test');
$this->hasColumn('booltest', 'boolean');
$this->hasColumn('integertest', 'integer', 4, array('unsigned' => true));
$this->hasColumn('floattest', 'float');
$this->hasColumn('stringtest', 'string', 200, array('fixed' => true));
$this->hasColumn('arraytest', 'array', 10000);
$this->hasColumn('objecttest', 'object');
$this->hasColumn('blobtest', 'blob');
$this->hasColumn('clobtest', 'clob');
$this->hasColumn('timestamptest', 'timestamp');
$this->hasColumn('timetest', 'time');
$this->hasColumn('datetest', 'date');
$this->hasColumn('enumtest', 'enum', 4,
array(
'values' => array(
'php',
'java',
'python'
)
)
);
$this->hasColumn('gziptest', 'gzip');
}
}
class TestObject
{
......@@ -145,10 +114,3 @@ class TestObject
}
class TestRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('test');
}
}
......@@ -77,22 +77,3 @@ class Doctrine_Record_ZeroValues_TestCase extends Doctrine_UnitTestCase
}
}
class ZeroValueTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true,));
$this->hasColumn('username', 'string', 128, array('notnull' => true,));
$this->hasColumn('algorithm', 'string', 128, array('default' => 'sha1', 'notnull' => true,));
$this->hasColumn('salt', 'string', 128, array('notnull' => true,));
$this->hasColumn('password', 'string', 128, array('notnull' => true,));
$this->hasColumn('created_at', 'timestamp', null, array());
$this->hasColumn('last_login', 'timestamp', null, array());
$this->hasColumn('is_active', 'boolean', null, array('default' => true, 'notnull' => true,));
$this->hasColumn('is_super_admin', 'boolean', null, array('default' => false, 'notnull' => true,));
}
public function setUp()
{ }
}
<?php
class RecordFilterTest extends Doctrine_Record {
public function setTableDefinition() {
$this->setAttribute(Doctrine::ATTR_ACCESSORS, Doctrine::ACCESSOR_BOTH);
$this->hasColumn("name", "string", 200);
$this->hasColumn("password", "string", 32);
}
public function setPassword($password) {
return md5($password);
}
public function getName($name) {
return strtoupper($name);
}
}
class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase {
public function prepareData() { }
public function prepareTables() { }
......
......@@ -132,69 +132,3 @@ class Doctrine_Relation_ManyToMany2_TestCase extends Doctrine_UnitTestCase
*/
}
}
class TestUser extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('TestMovie as UserBookmarks',
array('local' => 'user_id',
'foreign' => 'movie_id',
'refClass' => 'TestMovieUserBookmark'));
$this->hasMany('TestMovie as UserVotes',
array('local' => 'user_id',
'foreign' => 'movie_id',
'refClass' => 'TestMovieUserVote'));
}
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 30);
}
}
class TestMovie extends Doctrine_Record
{
public function setUp()
{
$this->hasOne('TestUser as User',
array('local' => 'user_id',
'foreign' => 'id'));
$this->hasMany('TestUser as MovieBookmarks',
array('local' => 'movie_id',
'foreign' => 'user_id',
'refClass' => 'TestMovieUserBookmark'));
$this->hasMany('TestUser as MovieVotes',
array('local' => 'movie_id',
'foreign' => 'user_id',
'refClass' => 'TestMovieUserVote'));
}
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null);
$this->hasColumn('name', 'string', 30);
}
}
class TestMovieUserBookmark extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('movie_id', 'integer', null, array('primary' => true));
}
}
class TestMovieUserVote extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('vote', 'string', 30);
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('movie_id', 'integer', null, array('primary' => true));
}
}
<?php
class M2MTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
$this->hasColumn('child_id', 'integer');
}
public function setUp() {
$this->hasMany('RTC1 as RTC1', 'JC1.c1_id');
$this->hasMany('RTC2 as RTC2', 'JC1.c1_id');
$this->hasMany('RTC3 as RTC3', 'JC2.c1_id');
$this->hasMany('RTC3 as RTC4', 'JC1.c1_id');
}
}
class M2MTest2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary'));
$this->hasColumn('name', 'string', 20);
}
public function setUp() {
$this->hasMany('RTC4 as RTC5', 'JC3.c1_id');
}
}
class JC3 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
class JC1 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
class JC2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('c1_id', 'integer');
$this->hasColumn('c2_id', 'integer');
}
}
class RTC1 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC1', 'JC1.c2_id');
}
}
class RTC2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC2', 'JC1.c2_id');
}
}
class RTC3 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 200);
}
public function setUp() {
$this->hasMany('M2MTest as RTC3', 'JC2.c2_id');
$this->hasMany('M2MTest as RTC4', 'JC1.c2_id');
}
}
class RTC4 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary'));
$this->hasColumn('name', 'string', 20);
}
public function setUp() {
$this->hasMany('M2MTest2', 'JC3.c2_id');
}
}
class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
public function prepareData() { }
......
......@@ -116,56 +116,3 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($auths[0]->Role->name, 'role1');
}
}
class Role extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 20, array('unique' => true));
}
public function setUp()
{
$this->hasMany('Auth', array('local' => 'id', 'foreign' => 'roleid'));
}
}
class Auth extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('roleid', 'integer', 10);
$this->hasColumn('name', 'string', 50);
}
public function setUp()
{
$this->hasOne('Role', array('local' => 'roleid', 'foreign' => 'id'));
}
}
class Policy extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('policy_number', 'integer', 11, array('unique' => true));
}
public function setUp()
{
$this->hasMany('PolicyAsset as PolicyAssets', array('local' => 'policy_number',
'foreign' => 'policy_number'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
class PolicyAsset extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('policy_number', 'integer', 11);
$this->hasColumn('value', 'float', 10, array ('notblank' => true,));
}
public function setUp()
{
$this->hasOne('Policy', array('foreign' => 'policy_number',
'local' => 'policy_number'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
......@@ -164,20 +164,3 @@ class Doctrine_Relation_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue($user->getTable()->getRelation('Phonenumber') instanceof Doctrine_Relation_ForeignKey);
}
}
class RelationTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 200);
$this->hasColumn('child_id', 'integer');
}
}
class RelationTestChild extends RelationTest
{
public function setUp()
{
$this->hasOne('RelationTest as Parent', 'RelationTestChild.child_id');
$this->ownsMany('RelationTestChild as Children', 'RelationTestChild.child_id');
}
}
......@@ -6,7 +6,7 @@
* @version $Id$
* @package Doctrine
*/
class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase
class Doctrine_Schema_TestCase extends Doctrine_UnitTestCase
{
public function testEverySchemaObjectIsThrowingExceptionOnNonPropertyAssignment()
......@@ -181,7 +181,7 @@ class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase
public function testSchemaIsTraversable()
{
/* @todo complete */
/* @todo complete
$schema = new Doctrine_Schema();
......@@ -197,5 +197,6 @@ class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase
}
}
}
*/
}
}
......@@ -65,17 +65,3 @@ class Doctrine_Sequence_TestCase extends Doctrine_UnitTestCase
*/
}
}
class CustomSequenceRecord extends Doctrine_Record {
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', null, array('primary', 'sequence' => 'custom_seq'));
$this->hasColumn('name', 'string');
}
}
class SequenceRecord extends Doctrine_Record {
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', null, array('primary', 'sequence'));
$this->hasColumn('name', 'string');
}
}
......@@ -70,34 +70,8 @@ class Doctrine_Template_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($user->Email[0] instanceof ConcreteEmail);
}
}
class ConcreteUser extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('UserTemplate');
}
}
class ConcreteGroup extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('GroupTemplate');
}
}
class ConcreteEmail extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('EmailTemplate');
}
}
class ConcreteGroupUser extends Doctrine_Record
{
public function setUp()
{
$this->loadTemplate('GroupUserTemplate');
}
}
// move these to ../templates?
class UserTemplate extends Doctrine_Template
{
public function setTableDefinition()
......
......@@ -95,43 +95,3 @@ class Doctrine_Ticket_424B_TestCase extends Doctrine_UnitTestCase
}
}
class mmrUser_B extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('mmrGroup_B as Group', array('local' => 'user_id',
'foreign' => 'group_id',
'refClass' => 'mmrGroupUser_B'));
}
public function setTableDefinition()
{
// Works when
$this->hasColumn('id', 'string', 30, array ( 'primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
class mmrGroup_B extends Doctrine_Record
{
public function setUp() {
$this->hasMany('mmrUser_B', array('local' => 'group_id',
'foreign' => 'user_id',
'refClass' => 'mmrGroupUser_B'));
}
public function setTableDefinition() {
// Works when
$this->hasColumn('id', 'string', 30, array ( 'primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
class mmrGroupUser_B extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'string', 30, array('primary' => true));
$this->hasColumn('group_id', 'string', 30, array('primary' => true));
}
}
......@@ -94,45 +94,3 @@ class Doctrine_Ticket_424C_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($userOfGroupAByName), 2);
}
}
class mmrUser_C extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('mmrGroup_C as Group', array('local' => 'user_id',
'foreign' => 'group_id',
'refClass' => 'mmrGroupUser_C'));
}
public function setTableDefinition()
{
// Works when
$this->hasColumn('u_id as id', 'string', 30, array('primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
class mmrGroup_C extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('mmrUser_C', array('local' => 'group_id',
'foreign' => 'user_id',
'refClass' => 'mmrGroupUser_C'));
}
public function setTableDefinition()
{
$this->hasColumn('g_id as id', 'string', 30, array('primary' => true));
$this->hasColumn('name', 'string', 30);
}
}
class mmrGroupUser_C extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'string', 30, array('primary' => true));
$this->hasColumn('group_id', 'string', 30, array('primary' => true));
}
}
<?php
/**
* Doctrine_Ticket330_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class stNode extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('node_node');
$this->hasColumn('title', 'string', 255, array ());
}
public function setUp()
{
$this->hasOne('stNodeDetail as detail', 'stNodeDetail.node_id' , array( 'onDelete'=>'cascade'));
}
}
class stNodeDetail extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('node_detail');
$this->hasColumn('node_id', 'integer', 10, array ( 'unique' => true,));
$this->hasColumn('null_column', 'string', 255, array ('default'=>null));
$this->hasColumn('is_bool', 'boolean', null, array ('default' => 0,));
$this->option('type', 'MyISAM');
}
public function setUp()
{
$this->hasOne('stNode as node', 'stNodeDetail.article_id', array('foreign' => 'id' , 'onDelete'=>'cascade'));
}
}
class Doctrine_Ticket330_TestCase extends Doctrine_UnitTestCase
{
public function prepareData()
{ }
public function prepareTables()
{
$this->tables[] = 'stNode';
$this->tables[] = 'stNodeDetail';
parent::prepareTables();
}
public function testUnnecessaryQueries()
{
$node1 = new stNode();
$node1->set('title', 'first node');
$node1->detail->set('is_bool', true);
$node1->save();
$node2 = new stNode();
$node2->set('title', 'second node');
$node2->detail->set('null_column', 'value');
$node2->detail->set('is_bool', false);
$node2->save();
$nodes = Doctrine_Query::create()
->select('n.title, d.*')
->from('stNode n, n.detail d')
->orderby('n.id')
->execute();
$prevCount = $this->dbh->count();
$this->assertEqual($nodes[0]->detail->get('is_bool'), true);
$this->assertEqual($nodes[0]->detail->get('null_column'), null);
// Unnecessary query is triggered on line before due to null value column.
$this->assertEqual($this->dbh->count(), $prevCount);
$prevCount = $this->dbh->count();
$this->assertEqual($nodes[1]->detail->get('null_column'), 'value');
$this->assertEqual($nodes[1]->detail->get('is_bool'), false);
// Unecessary query is triggered on line before due to false value column
$this->assertEqual($this->dbh->count(), $prevCount);
}
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Template_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Inheritance
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class ReportBase extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Report');
$this->hasColumn('id', 'integer',20, 'autoincrement|primary');
$this->hasColumn('description', 'string',50);
$this->hasColumn('type', 'integer', 11);
}
}
class Report extends ReportBase
{
public function setTableDefinition()
{
parent::setTableDefinition();
$this->option('subclasses', array('ReportA','ReportB'));
}
}
class ReportA extends ReportBase
{
public function setUp()
{
parent::setUp();
$this->option('inheritanceMap', array('type' => 1));
}
public function setTableDefinition()
{
parent::setTableDefinition();
$this->hasColumn('columnreporta', 'string',50);
}
}
class ReportB extends ReportBase
{
public function setUp()
{
parent::setUp();
$this->option('inheritanceMap', array('type' => 2));
}
public function setTableDefinition()
{
parent::setTableDefinition();
$this->hasColumn('columnreportb', 'string',50);
}
}
class Doctrine_Ticket337_TestCase extends Doctrine_UnitTestCase
{
public function testInit()
{
/*create table*/
$this->dbh->exec("CREATE Table Report (".
"id INTEGER PRIMARY KEY AUTOINCREMENT,".
"type INTEGER,".
"description varchar(50),".
"columnreporta varchar(50),".
"columnreportb varchar(50))");
}
public function testTicket337()
{
$reportA = new ReportA();
$reportA->set('description',"teste Report A");
$reportA->set('columnreporta',"somevalueA");
$reportA->save();
$reportB = new ReportB();
$reportB->set('description',"teste Report B");
$reportB->set('columnreportb',"somevalueB");
$reportB->save();
$this->assertTrue($reportA->get('columnreporta') == "somevalueA");
$this->assertTrue($reportB->get('columnreportb') == "somevalueB");
$q = new Doctrine_Query();
$reportAFromDB = $q->from('Report')->where('id=?')->execute(array($reportA->id))->getFirst();
$q = new Doctrine_Query();
$reportBFromDB = $q->from('Report')->where('id=?')->execute(array($reportB->id))->getFirst();
//same tests as Doctrine_ColumnAggregationInheritance_TestCase::testSubclassReturnedIfInheritanceMatches()
$this->assertTrue(($reportAFromDB instanceof ReportA));
$this->assertTrue(($reportBFromDB instanceof ReportB));
$this->assertEqual($reportAFromDB->get('description'),'teste Report A');
$this->assertEqual($reportBFromDB->get('description'),'teste Report B');
try{
$this->assertEqual($reportAFromDB->get('columnreporta'),'somevalueA');
}catch(Doctrine_Record_Exception $ex)
{
$this->fail($ex->__toString());
}
try{
$this->assertEqual($reportBFromDB->get('columnreportb'),'somevalueB');
}catch(Doctrine_Record_Exception $ex)
{
$this->fail($ex->__toString());
}
}
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Ticket343_TestCase
*
* @package Doctrine
* @author Lloyd Leung (lleung at carlton decimal ca)
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase
{
public function prepareData()
{ }
public function prepareTables()
{ }
public function testForeignPkNonId()
{
$member = new Member();
$subprogram = new SubProgram();
$newsblast = new NewsBlast();
$member->set('name','hello world!');
$member->set('pin', 'demo1100');
$subprogram->set('name', 'SoemthingNew');
$newsblast->set('member', $member);
$newsblast->set('subprogram', $subprogram);
$newsblast->set('title', 'Some title here');
$newsblast->save();
$test->assertEqual($newsblast['subprogram'], 'SomethingNew');
$test->assertEqual($newsblast['member']['pin'], 'demo1100');
$test->assertEqual($newsblast['member']['name'], 'hello world!');
}
}
class Member extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('members');
$this->hasColumn('pin', 'string', 8, array('primary' => true));
$this->hasColumn('name', 'string', 254, array('notblank' => true));
}
public function setUp()
{
$this->hasMany('NewsBlast as news_blasts', 'NewsBlast.pin');
}
}
class NewsBlast extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('p2m_newsblast');
$this->hasColumn('pin', 'string', 8, array('primary' => true));
$this->hasColumn('subprogram_id', 'integer', 10, array());
$this->hasColumn('title', 'string', 254, array());
}
public function setUp()
{
$this->hasOne('SubProgram as subprogram', 'NewsBlast.subprogram_id');
$this->hasOne('Member as member', 'NewsBlast.pin');
}
}
class SubProgram extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('p2m_subprogram');
$this->hasColumn('name', 'string', 50, array());
}
public function setUp()
{
$this->hasMany('Member as members', 'Member.subprogram_id');
}
}
<?php
/**
* Doctrine_TicketNjero_TestCase
*
* @package Doctrine
* @author Jeff Rafter <lists@jeffrafter.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class CoverageCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('coverage_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
<?php
/**
* Doctrine_TicketNjero_TestCase
*
* @package Doctrine
* @author Jeff Rafter <lists@jeffrafter.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class PolicyCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('policy_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
class LiabilityCodeN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('liability_codes');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('code', array('fields' => 'code'));
}
}
class PolicyN extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('policies');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('rate_id', 'integer', 4, array ( ));
$this->hasColumn('policy_number', 'integer', 4, array ( 'unique' => true, ));
}
public function setUp(){
$this->hasOne('RateN', array('local' => 'rate_id', 'foreign' => 'id' ));
}
}
class RateN extends Doctrine_Record{
public function setTableDefinition(){
$this->setTableName('rates');
$this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true));
$this->hasColumn('policy_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('coverage_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('liability_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,));
$this->hasColumn('total_rate', 'float', null, array ( 'notnull' => true, 'notblank' => true,));
}
public function setUp(){
# $this->index('policy_code_idx', array('fields' => 'policy_code'));
# $this->index('coverage_code_idx', array('fields' => 'coverage_code'));
# $this->index('liability_code_idx', array('fields' => 'liability_code'));
$this->hasOne('PolicyCodeN', array('local' => 'policy_code', 'foreign' => 'code' ));
$this->hasOne('CoverageCodeN', array('local' => 'coverage_code', 'foreign' => 'code' ));
$this->hasOne('LiabilityCodeN', array('local' => 'liability_code', 'foreign' => 'code' ));
}
}
class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase
{
public function prepareData() { }
public function prepareTables()
class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase
{
public function prepareData() { }
public function prepareTables()
{
$this->tables[] = 'CoverageCodeN';
$this->tables[] = 'PolicyCodeN';
$this->tables[] = 'LiabilityCodeN';
$this->tables[] = 'PolicyN';
$this->tables[] = 'RateN';
$this->tables[] = 'CoverageCodeN';
$this->tables[] = 'PolicyCodeN';
$this->tables[] = 'LiabilityCodeN';
$this->tables[] = 'PolicyN';
$this->tables[] = 'RateN';
parent::prepareTables();
}
public function testHasOneMultiLevelRelations()
{
}
public function testHasOneMultiLevelRelations()
{
$policy_code = new PolicyCodeN();
$policy_code->code = 1;
$policy_code->description = "Special Policy";
$policy_code->save();
$coverage_code = new CoverageCodeN();
$coverage_code->code = 1;
$coverage_code->description = "Full Coverage";
$coverage_code->save();
$coverage_code = new CoverageCodeN();
$coverage_code->code = 3; # note we skip 2
$coverage_code->description = "Partial Coverage";
......@@ -148,19 +69,19 @@ class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase
->execute()
->getFirst();
$this->assertEqual($p->rate_id, 1);
$this->assertEqual($p->RateN->id, 1);
$this->assertEqual($p->RateN->policy_code, 1);
$this->assertEqual($p->RateN->coverage_code, 3); # fail
$this->assertEqual($p->rate_id, 1);
$this->assertEqual($p->RateN->id, 1);
$this->assertEqual($p->RateN->policy_code, 1);
$this->assertEqual($p->RateN->coverage_code, 3); # fail
$this->assertEqual($p->RateN->liability_code, 1);
$c = $p->RateN->coverage_code;
$c2 = $p->RateN->CoverageCodeN->code;
$c3 = $p->RateN->coverage_code;
$this->assertEqual($c, $c2); # fail
$c = $p->RateN->coverage_code;
$c2 = $p->RateN->CoverageCodeN->code;
$c3 = $p->RateN->coverage_code;
$this->assertEqual($c, $c2); # fail
$this->assertEqual($c, $c3); # in my app this fails as well, but I can't reproduce this
#echo "Values " . serialize(array($c, $c2, $c3));
#echo "Values " . serialize(array($c, $c2, $c3));
}
}?>
}
}?>
......@@ -126,16 +126,4 @@ class Doctrine_TreeStructure_TestCase extends Doctrine_UnitTestCase
}
}
class TreeLeaf extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
$this->hasColumn('parent_id', 'integer');
}
public function setUp()
{
$this->hasOne('TreeLeaf as Parent', 'TreeLeaf.parent_id');
$this->hasMany('TreeLeaf as Children', 'TreeLeaf.parent_id');
}
}
<?php
class Entity extends Doctrine_Record
{
public function setUp()
{
$this->ownsOne('Email', array('local' => 'email_id'));
$this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id'));
$this->ownsOne('Account', array('foreign' => 'entity_id'));
$this->hasMany('Entity', array('local' => 'entity1',
'refClass' => 'EntityReference',
'foreign' => 'entity2',
'equal' => true));
}
public function setTableDefinition()
{
$this->hasColumn('id', 'integer',20, 'autoincrement|primary');
$this->hasColumn('name', 'string',50);
$this->hasColumn('loginname', 'string',20, array('unique'));
$this->hasColumn('password', 'string',16);
$this->hasColumn('type', 'integer',1);
$this->hasColumn('created', 'integer',11);
$this->hasColumn('updated', 'integer',11);
$this->hasColumn('email_id', 'integer');
// $this->option('subclasses', array('User','Group'));
$this->setSubclasses(array("User" => array("type" => 0), "Group" => array("type" => 1)));
}
}
class FieldNameTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('someColumn', 'string', 200, array('default' => 'some string'));
$this->hasColumn('someEnum', 'enum', 4, array('default' => 'php', 'values' => array('php', 'java', 'python')));
$this->hasColumn('someArray', 'array', 100, array('default' => array()));
$this->hasColumn('someObject', 'object', 200, array('default' => new stdClass));
$this->hasColumn('someInt', 'integer', 20, array('default' => 11));
}
}
class EntityReference extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('entity1', 'integer', null, 'primary');
$this->hasColumn('entity2', 'integer', null, 'primary');
//$this->setPrimaryKey(array('entity1', 'entity2'));
}
}
class Account extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('entity_id', 'integer');
$this->hasColumn('amount', 'integer');
}
}
class EntityAddress extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('user_id', 'integer', null, array('primary' => true));
$this->hasColumn('address_id', 'integer', null, array('primary' => true));
}
}
class Address extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('User', array('local' => 'address_id',
'foreign' => 'user_id',
'refClass' => 'EntityAddress'));
}
public function setTableDefinition() {
$this->hasColumn('address', 'string', 200);
}
}
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection
// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called
class GroupTable { }
class Group extends Entity {
public function setUp() {
parent::setUp();
$this->hasMany('User', 'Groupuser.user_id');
// $this->option('inheritanceMap', array('type' => 1));
}
}
class Error extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Description', 'Description.file_md5', 'file_md5');
}
public function setTableDefinition() {
$this->hasColumn('message', 'string',200);
$this->hasColumn('code', 'integer',11);
$this->hasColumn('file_md5', 'string',32, 'primary');
}
}
class Description extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('description', 'string',3000);
$this->hasColumn('file_md5', 'string',32);
}
}
class UserTable extends Doctrine_Table { }
class User extends Entity
{
public function setUp()
{
parent::setUp();
$this->hasMany('Address', array('local' => 'user_id',
'foreign' => 'address_id',
'refClass' => 'EntityAddress'));
$this->ownsMany('Album', 'Album.user_id');
$this->ownsMany('Book', 'Book.user_id');
$this->hasMany('Group', 'Groupuser.group_id');
// $this->option('inheritanceMap', array('type' => 0));
}
/** Custom validation */
public function validate()
{
// Allow only one name!
if ($this->name !== 'The Saint') {
$this->errorStack()->add('name', 'notTheSaint');
}
}
public function validateOnInsert()
{
if ($this->password !== 'Top Secret') {
$this->errorStack()->add('password', 'pwNotTopSecret');
}
}
public function validateOnUpdate()
{
if ($this->loginname !== 'Nobody') {
$this->errorStack()->add('loginname', 'notNobody');
}
}
}
class SelfRefTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 50);
$this->hasColumn('created_by', 'integer');
}
public function setUp()
{
$this->hasOne('SelfRefTest as createdBy', array('local' => 'created_by'));
}
}
class Groupuser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('added', 'integer');
$this->hasColumn('group_id', 'integer');
$this->hasColumn('user_id', 'integer');
}
}
class Phonenumber extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('phonenumber', 'string',20);
$this->hasColumn('entity_id', 'integer');
}
public function setUp()
{
$this->hasOne('Entity', array('local' => 'entity_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
}
}
class Element extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
$this->hasColumn('parent_id', 'integer');
}
public function setUp() {
$this->hasMany('Element as Child', 'Child.parent_id');
$this->hasOne('Element as Parent', 'Element.parent_id');
}
}
class Email extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('address', 'string', 150, 'email|unique');
}
}
class Book extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Author', 'Author.book_id');
}
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
class Author extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('book_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
class Album extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Song', 'Song.album_id');
}
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('name', 'string',20);
}
}
class Song extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('album_id', 'integer');
$this->hasColumn('genre', 'string',20);
$this->hasColumn('title', 'string',30);
}
}
class Task extends Doctrine_Record {
public function setUp() {
$this->hasMany('Resource as ResourceAlias', 'Assignment.resource_id');
$this->hasMany('Task as Subtask', 'Subtask.parent_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
$this->hasColumn('parent_id', 'integer');
}
}
class Resource extends Doctrine_Record {
public function setUp() {
$this->hasMany('Task as TaskAlias', 'Assignment.task_id');
$this->hasMany('ResourceType as Type', 'ResourceReference.type_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
}
}
class ResourceReference extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('type_id', 'integer');
$this->hasColumn('resource_id', 'integer');
}
}
class ResourceType extends Doctrine_Record {
public function setUp() {
$this->hasMany('Resource as ResourceAlias', 'ResourceReference.resource_id');
}
public function setTableDefinition() {
$this->hasColumn('type', 'string',100);
}
}
class Assignment extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('task_id', 'integer');
$this->hasColumn('resource_id', 'integer');
}
}
class Forum_Category extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('root_category_id', 'integer', 10);
$this->hasColumn('parent_category_id', 'integer', 10);
$this->hasColumn('name', 'string', 50);
$this->hasColumn('description', 'string', 99999);
}
public function setUp() {
$this->hasMany('Forum_Category as Subcategory', 'Subcategory.parent_category_id');
$this->hasOne('Forum_Category as Parent', 'Forum_Category.parent_category_id');
$this->hasOne('Forum_Category as Rootcategory', 'Forum_Category.root_category_id');
}
}
class Forum_Board extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('category_id', 'integer', 10);
$this->hasColumn('name', 'string', 100);
$this->hasColumn('description', 'string', 5000);
}
public function setUp() {
$this->hasOne('Forum_Category as Category', 'Forum_Board.category_id');
$this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id');
}
}
class Forum_Entry extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('author', 'string', 50);
$this->hasColumn('topic', 'string', 100);
$this->hasColumn('message', 'string', 99999);
$this->hasColumn('parent_entry_id', 'integer', 10);
$this->hasColumn('thread_id', 'integer', 10);
$this->hasColumn('date', 'integer', 10);
}
public function setUp() {
$this->hasOne('Forum_Entry as Parent', 'Forum_Entry.parent_entry_id');
$this->hasOne('Forum_Thread as Thread', 'Forum_Entry.thread_id');
}
}
class Forum_Thread extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('board_id', 'integer', 10);
$this->hasColumn('updated', 'integer', 10);
$this->hasColumn('closed', 'integer', 1);
}
public function setUp() {
$this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id');
$this->ownsMany('Forum_Entry as Entries', 'Forum_Entry.thread_id');
}
}
class App extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 32);
$this->hasColumn('user_id', 'integer', 11);
$this->hasColumn('app_category_id', 'integer', 11);
}
public function setUp() {
$this->hasOne('User', 'User.id');
$this->hasMany('App_Category as Category', 'App_Category.id');
}
}
class App_User extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('first_name', 'string', 32);
$this->hasColumn('last_name', 'string', 32);
$this->hasColumn('email', 'string', 128, 'email');
$this->hasColumn('username', 'string', 16, 'unique, nospace');
$this->hasColumn('password', 'string', 128, 'notblank');
$this->hasColumn('country', 'string', 2, 'country');
$this->hasColumn('zipcode', 'string', 9, 'nospace');
}
public function setUp() {
$this->hasMany('App', 'App.user_id');
}
}
class App_Category extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 32);
$this->hasColumn('parent_id', 'integer');
}
public function setUp() {
$this->hasMany('App', 'App.app_category_id');
$this->hasMany('App_Category as Parent', 'App_Category.parent_id');
}
}
class ORM_TestEntry extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('test_entries');
$this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
$this->hasColumn('name', 'string', 255);
$this->hasColumn('stamp', 'timestamp');
$this->hasColumn('amount', 'float');
$this->hasColumn('itemID', 'integer');
}
public function setUp() {
$this->hasOne('ORM_TestItem', 'ORM_TestEntry.itemID');
}
}
class ORM_TestItem extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('test_items');
$this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasOne('ORM_TestEntry', 'ORM_TestEntry.itemID');
}
}
class ORM_AccessControl extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('ORM_AccessGroup as accessGroups', 'ORM_AccessControlsGroups.accessGroupID');
}
}
class ORM_AccessGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('ORM_AccessControl as accessControls', 'ORM_AccessControlsGroups.accessControlID');
}
}
class ORM_AccessControlsGroups extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('accessControlID', 'integer', 11, array('primary' => true));
$this->hasColumn('accessGroupID', 'integer', 11, array('primary' => true));
}
}
class EnumTest extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
$this->hasColumn('text', 'string');
}
public function setUp() {
$this->hasMany('EnumTest2 as Enum2', array('local' => 'id', 'foreign' => 'enum_test_id'));
$this->hasMany('EnumTest3 as Enum3', array('local' => 'text', 'foreign' => 'text'));
}
}
class EnumTest2 extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
$this->hasColumn('enum_test_id', 'integer');
}
}
class EnumTest3 extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('text', 'string', 10, array('primary' => true));
}
}
class FilterTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
}
public function setUp() {
$this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id');
}
}
class FilterTest2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string',100);
$this->hasColumn('test1_id', 'integer');
}
}
class CustomPK extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('uid', 'integer',11, 'autoincrement|primary');
$this->hasColumn('name', 'string',255);
}
}
class Log_Entry extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('stamp', 'timestamp');
$this->hasColumn('status_id', 'integer');
}
public function setUp() {
$this->hasOne('Log_Status', 'Log_Entry.status_id');
}
}
class CPK_Test extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasMany('CPK_Test2 as Test', 'CPK_Association.test2_id');
}
}
class CPK_Test2 extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasMany('CPK_Test as Test', 'CPK_Association.test1_id');
}
}
class CPK_Association extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('test1_id', 'integer', 11, 'primary');
$this->hasColumn('test2_id', 'integer', 11, 'primary');
}
}
class Log_Status extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
}
class ValidatorTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('mymixed', 'string', 100);
$this->hasColumn('mystring', 'string', 100, 'notnull|unique');
$this->hasColumn('myarray', 'array', 1000);
$this->hasColumn('myobject', 'object', 1000);
$this->hasColumn('myinteger', 'integer', 11);
$this->hasColumn('myrange', 'integer', 11, array('range' => array(4,123)));
$this->hasColumn('myregexp', 'string', 5, array('regexp' => '/^[0-9]+$/'));
$this->hasColumn('myemail', 'string', 100, 'email');
$this->hasColumn('myemail2', 'string', 100, 'email|notblank');
}
}
class DateTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('date', 'date', 20);
}
}
class GzipTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('gzip', 'gzip', 100000);
}
}
class Tag extends Doctrine_Record {
public function setUp() {
$this->hasMany('Photo', 'Phototag.photo_id');
}
public function setTableDefinition() {
$this->hasColumn('tag', 'string', 100);
}
}
class Photo extends Doctrine_Record {
public function setUp() {
$this->hasMany('Tag', 'Phototag.tag_id');
}
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100);
}
}
class Phototag extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('photo_id', 'integer');
$this->hasColumn('tag_id', 'integer');
}
}
class BooleanTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('is_working', 'boolean');
$this->hasColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true));
}
}
class Data_File extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('filename', 'string');
$this->hasColumn('file_owner_id', 'integer');
}
public function setUp() {
$this->hasOne('File_Owner', 'Data_File.file_owner_id');
}
}
class NotNullTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 100, 'notnull');
$this->hasColumn('type', 'integer', 11);
}
}
class File_Owner extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->hasOne('Data_File', 'Data_File.file_owner_id');
}
}
class MyUser extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
}
public function setUp() {
$this->hasMany('MyOneThing', 'MyOneThing.user_id');
$this->hasMany('MyOtherThing', 'MyOtherThing.user_id');
}
}
class MyOneThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
$this->hasColumn('user_id', 'integer');
}
public function setUp() {
$this->hasMany('MyUserOneThing', 'MyUserOneThing.one_thing_id');
}
}
class MyOtherThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('name', 'string');
$this->hasColumn('user_id', 'integer');
}
public function setUp() {
$this->hasMany('MyUserOtherThing', 'MyUserOtherThing.other_thing_id');
}
}
class MyUserOneThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('one_thing_id', 'integer');
}
}
class MyUserOtherThing extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('user_id', 'integer');
$this->hasColumn('other_thing_id', 'integer');
}
}
class CategoryWithPosition extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('position', 'integer');
$this->hasColumn('name', 'string', 255);
}
public function setUp() {
$this->ownsMany('BoardWithPosition as Boards', 'BoardWithPosition.category_id');
}
}
class BoardWithPosition extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('position', 'integer');
$this->hasColumn('category_id', 'integer');
}
public function setUp() {
$this->hasOne('CategoryWithPosition as Category', 'BoardWithPosition.category_id');
}
}
class Package extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id');
}
}
class PackageVersion extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('package_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('Package', 'PackageVersion.package_id');
$this->hasMany('PackageVersionNotes as Note', 'PackageVersionNotes.package_version_id');
}
}
class PackageVersionNotes extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('package_version_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('PackageVersion', 'PackageVersionNotes.package_version_id');
}
}
class NestTest extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('name', 'string');
}
public function setUp()
{
$this->hasMany('NestTest as Parents', array('local' => 'child_id',
'refClass' => 'NestReference',
'foreign' => 'parent_id'));
$this->hasMany('NestTest as Children', array('local' => 'parent_id',
'refClass' => 'NestReference',
'foreign' => 'child_id'));
$this->hasMany('NestTest as Relatives', array('local' => 'child_id',
'refClass' => 'NestReference',
'foreign' => 'parent_id',
'equal' => true));
}
}
class NestReference extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('parent_id', 'integer', 4, 'primary');
$this->hasColumn('child_id', 'integer', 4, 'primary');
}
}
class ValidatorTest_Person extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('identifier', 'integer', 4, array('notblank', 'unique'));
$this->hasColumn('is_football_player', 'boolean');
}
public function setUp() {
$this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id');
}
}
class ValidatorTest_FootballPlayer extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('person_id', 'string', 255);
$this->hasColumn('team_name', 'string', 255);
$this->hasColumn('goals_count', 'integer', 4);
}
}
class QueryTest_Category extends Doctrine_Record
{
/**
* The depth of the category inside the tree.
* Non-persistent field.
*
* @var integer
*/
public $depth;
/**
* Table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('rootCategoryId as rootCategoryId', 'integer', 4,
array('default' => 0));
$this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4,
array('notnull', 'default' => 0));
$this->hasColumn('name as name', 'string', 50,
array('notnull', 'unique'));
$this->hasColumn('position as position', 'integer', 4,
array('default' => 0, 'notnull'));
}
/**
* Relations definition.
*/
public function setUp()
{
$this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId');
$this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId');
$this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId');
}
}
class QueryTest_Board extends Doctrine_Record
{
/**
* Initializes the table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('categoryId as categoryId', 'integer', 4,
array('notnull'));
$this->hasColumn('name as name', 'string', 100,
array('notnull', 'unique'));
$this->hasColumn('lastEntryId as lastEntryId', 'integer', 4,
array('default' => 0, 'notnull'));
$this->hasColumn('position as position', 'integer', 4,
array('default' => 0, 'notnull'));
}
/**
* Initializes the relations.
*/
public function setUp()
{
$this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId');
$this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId');
}
}
class QueryTest_Entry extends Doctrine_Record
{
/**
* Table structure.
*/
public function setTableDefinition()
{
$this->hasColumn('authorId', 'integer', 4,
array('notnull'));
$this->hasColumn('date', 'integer', 4,
array('notnull'));
}
/**
* Runtime definition of the relationships to other entities.
*/
public function setUp()
{
$this->hasOne('QueryTest_User as author', 'QueryTest_Entry.authorId');
}
}
class QueryTest_User extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('username as username', 'string', 50,
array('notnull'));
$this->hasColumn('visibleRankId', 'integer', 4);
}
/**
* Runtime definition of the relationships to other entities.
*/
public function setUp()
{
$this->hasOne('QueryTest_Rank as visibleRank', 'QueryTest_User.visibleRankId');
$this->hasMany('QueryTest_Rank as ranks', 'QueryTest_UserRank.rankId');
}
}
class QueryTest_UserRank extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('rankId', 'integer', 4, array('primary'));
$this->hasColumn('userId', 'integer', 4, array('primary'));
}
}
class QueryTest_Rank extends Doctrine_Record
{
/**
* Initializes the table definition.
*/
public function setTableDefinition()
{
$this->hasColumn('title as title', 'string', 100,
array('notnull'));
$this->hasColumn('color as color', 'string', 20,
array('notnull', 'regexp' => '/^[a-zA-Z\-]{3,}|#[0-9a-fA-F]{6}$/D'));
$this->hasColumn('icon as icon', 'string', 50,
array('notnull', 'default' => ' ', 'regexp' => '/^[a-zA-Z0-9_\-]+\.(jpg|gif|png)$/D'));
}
public function setUp()
{
$this->hasMany('QueryTest_User as users', 'QueryTest_UserRank.userId');
}
}
class ValidatorTest_ClientModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('id', 'integer', 4, array('notnull' => true,
'primary' => true,
'autoincrement' => true,
'unsigned' => true));
$this->hasColumn('short_name', 'string', 32, array('notnull' => true, 'notblank', 'unique' => true));
}
public function setUp() {
$this->hasMany("ValidatorTest_AddressModel", array('local' => 'client_id', 'foreign' => 'address_id', 'refClass' => 'ValidatorTest_ClientToAddressModel'));
}
}
class ValidatorTest_ClientToAddressModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("client_id", "integer", 11, array('primary' => true));
$this->hasColumn("address_id", "integer", 11, array('primary' => true));
}
public function construct(){
}
public function setUp() {
}
}
class ValidatorTest_AddressModel extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("id", "integer", 11, array('autoincrement' => true,
'primary' => true
));
$this->hasColumn('address1', 'string', 255, array('notnull' => true, 'notblank'));
$this->hasColumn('address2', 'string', 255, array('notnull' => true));
$this->hasColumn('city', 'string', 255, array('notnull' => true, 'notblank'));
$this->hasColumn('state', 'string', 10, array('notnull' => true, 'notblank', 'usstate'));
$this->hasColumn('zip', 'string', 15, array('notnull' => true, 'notblank', 'regexp' => '/^[0-9-]*$/'));
}
public function setUp() {
$this->hasMany('ValidatorTest_ClientModel', array('local' => 'address_id', 'foreign' => 'client_id', 'refClass' => 'ValidatorTest_ClientToAddressModel'));
}
}
class NestedSetTest_SingleRootNode extends Doctrine_Record {
public function setTableDefinition() {
$this->actAs('NestedSet');
$this->hasColumn('name', 'string', 50, array('notnull'));
}
}
?>
......@@ -29,6 +29,7 @@ function autoload($class) {
// create a test case file if it doesn't exist
if ( ! file_exists($file)) {
echo "file $file does not exist \n";
$contents = file_get_contents('template.tpl');
$contents = sprintf($contents, $class, $class);
......@@ -50,9 +51,16 @@ spl_autoload_register(array('Doctrine', 'autoload'));
// register the autoloader function above
spl_autoload_register('autoload');
require_once dirname(__FILE__) . '/../models/location.php';
require_once dirname(__FILE__) . '/../models/Blog.php';
require_once dirname(__FILE__) . '/classes.php';
// include the models
$models = new DirectoryIterator(dirname(__FILE__) . '/../models/');
foreach($models as $key => $file) {
if ($file->isFile() && ! $file->isDot()) {
require_once $file->getPathname();
}
}
//require_once dirname(__FILE__) . '/../models/location.php';
//require_once dirname(__FILE__) . '/../models/Blog.php';
//require_once dirname(__FILE__) . '/classes.php';
require_once dirname(__FILE__) . '/Test.php';
require_once dirname(__FILE__) . '/UnitTestCase.php';
......@@ -65,13 +73,6 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
// DATABASE ABSTRACTION tests
// Temp tests
/**
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
/** */
$test->addTestCase(new Doctrine_TicketNjero_TestCase());
// Connection drivers (not yet fully tested)
......@@ -216,7 +217,7 @@ $test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
$test->addTestCase(new Doctrine_Record_Filter_TestCase());
$test->addTestCase(new Doctrine_SchemaTestCase());
$test->addTestCase(new Doctrine_Schema_TestCase());
$test->addTestCase(new Doctrine_Query_Condition_TestCase());
......@@ -281,10 +282,7 @@ $test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
$test->addTestCase(new Doctrine_NewCore_TestCase());
//$test->addTestCase(new Doctrine_Ticket337_TestCase());
// Record
$test->addTestCase(new Doctrine_Record_State_TestCase());
$test->addTestCase(new Doctrine_Record_SerializeUnserialize_TestCase());
......@@ -310,8 +308,6 @@ $test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
$test->addTestCase(new Doctrine_Query_TestCase());
$test->addTestCase(new Doctrine_Ticket364_TestCase());
$test->addTestCase(new Doctrine_Query_MysqlSubquery_TestCase());
$test->addTestCase(new Doctrine_Query_PgsqlSubquery_TestCase());
......@@ -421,21 +417,21 @@ class MyReporter extends HtmlReporter {
?>
<?php
if(PHP_SAPI === "cli"){
if (PHP_SAPI === "cli") {
$reporter = new CliReporter();
}else{
} else {
$reporter = new MyReporter();
}
$argv = $_SERVER["argv"];
if(isset($argv[1]) && $argv[1] == "coverage"){
if (isset($argv[1]) && $argv[1] == "coverage") {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$test->run($reporter);
$result["path"] = Doctrine::getPath() . DIRECTORY_SEPARATOR;
$result["coverage"] = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
file_put_contents("coverage.txt", serialize($result));
}else{
} else {
$test->run($reporter);
}
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