Commit 2ddfc072 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 8007b32c
<?php
/*
* $Id$
* %s
*
* @package Doctrine
* @author Lloyd Leung (lleung at carlton decimal ca)
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Member extends Doctrine_Record
{
const DATABASE_NAME = 'doctrine';
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
{
const DATABASE_NAME = 'doctrine';
public function setTableDefinition()
{
$this->setTableName('p2m_newsblast');
$this->hasColumn('subprogram_id', 'integer', 10, array());
$this->hasColumn('title', 'string', 254, array());
}
public function setUp()
{
$this->hasOne('SubProgram as subprogram', 'NewsBlast.subprogram_id', 'id');
$this->hasOne('Member as member', 'NewsBlast.pin', 'pin');
}
}
class SubProgram extends Doctrine_Record
{
const DATABASE_NAME = 'doctrine';
public function setTableDefinition()
{
$this->setTableName('p2m_subprogram');
$this->hasColumn('name', 'string', 50, array());
}
public function setUp()
{
$this->hasMany('Member as members', 'Member.subprogram_id');
}
}
class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase
{
public function prepareData()
{ }
public function prepareTables()
{ }
public function testForeignPkNonId()
{
die('happy!');
$member = new Member();
$subprogram = new SubProgram();
$newsblast = new NewsBlast();
$member->set('name','hello world!');
$member->set('pin', 'demo1100');
$subprogram->set('name', 'SoemthingNew');
$newsblast->set('pin', $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!');
$test->assertEqual(0,1);
}
}
...@@ -37,7 +37,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase { ...@@ -37,7 +37,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase {
public function prepareTables() { } public function prepareTables() { }
public function prepareData() { } public function prepareData() { }
public function testQuerySupportsIdentifierQuoting() { public function testQuerySupportsIdentifierQuoting() {
$this->connection->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true); $this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -61,6 +61,6 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase { ...@@ -61,6 +61,6 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM "entity" e INNER JOIN "phonenumber" p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM "entity" e2 INNER JOIN "phonenumber" p2 ON e2.id = p2.entity_id WHERE (e2.type = 0) LIMIT 5) AND (e.type = 0)'); $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM "entity" e INNER JOIN "phonenumber" p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM "entity" e2 INNER JOIN "phonenumber" p2 ON e2.id = p2.entity_id WHERE (e2.type = 0) LIMIT 5) AND (e.type = 0)');
$this->connection->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false); $this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
} }
} }
...@@ -48,7 +48,7 @@ class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase ...@@ -48,7 +48,7 @@ class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase
$subprogram->set('name', 'SoemthingNew'); $subprogram->set('name', 'SoemthingNew');
$newsblast->set('pin', $member); $newsblast->set('member', $member);
$newsblast->set('subprogram', $subprogram); $newsblast->set('subprogram', $subprogram);
$newsblast->set('title', 'Some title here'); $newsblast->set('title', 'Some title here');
...@@ -57,22 +57,18 @@ class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase ...@@ -57,22 +57,18 @@ class Doctrine_Ticket343_TestCase extends Doctrine_UnitTestCase
$test->assertEqual($newsblast['subprogram'], 'SomethingNew'); $test->assertEqual($newsblast['subprogram'], 'SomethingNew');
$test->assertEqual($newsblast['member']['pin'], 'demo1100'); $test->assertEqual($newsblast['member']['pin'], 'demo1100');
$test->assertEqual($newsblast['member']['name'], 'hello world!'); $test->assertEqual($newsblast['member']['name'], 'hello world!');
$test->assertEqual(0,1);
} }
} }
class Member extends Doctrine_Record class Member extends Doctrine_Record
{ {
const DATABASE_NAME = 'doctrine';
public function setTableDefinition() public function setTableDefinition()
{ {
$this->setTableName('members'); $this->setTableName('members');
$this->hasColumn('pin', 'string', 8, array('primary'=>true, )); $this->hasColumn('pin', 'string', 8, array('primary' => true));
$this->hasColumn('name', 'string', 254, array('notblank'=>true, )); $this->hasColumn('name', 'string', 254, array('notblank' => true));
} }
public function setUp() public function setUp()
...@@ -84,25 +80,22 @@ class Member extends Doctrine_Record ...@@ -84,25 +80,22 @@ class Member extends Doctrine_Record
class NewsBlast extends Doctrine_Record class NewsBlast extends Doctrine_Record
{ {
const DATABASE_NAME = 'doctrine';
public function setTableDefinition() public function setTableDefinition()
{ {
$this->setTableName('p2m_newsblast'); $this->setTableName('p2m_newsblast');
$this->hasColumn('pin', 'string', 8, array('primary' => true));
$this->hasColumn('subprogram_id', 'integer', 10, array()); $this->hasColumn('subprogram_id', 'integer', 10, array());
$this->hasColumn('title', 'string', 254, array()); $this->hasColumn('title', 'string', 254, array());
} }
public function setUp() public function setUp()
{ {
$this->hasOne('SubProgram as subprogram', 'NewsBlast.subprogram_id', 'id'); $this->hasOne('SubProgram as subprogram', 'NewsBlast.subprogram_id');
$this->hasOne('Member as member', 'NewsBlast.pin', 'pin'); $this->hasOne('Member as member', 'NewsBlast.pin');
} }
} }
class SubProgram extends Doctrine_Record class SubProgram extends Doctrine_Record
{ {
const DATABASE_NAME = 'doctrine';
public function setTableDefinition() public function setTableDefinition()
{ {
$this->setTableName('p2m_subprogram'); $this->setTableName('p2m_subprogram');
......
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