From b309933a4f60c60195ee4abd6fc570ceab20eda5 Mon Sep 17 00:00:00 2001 From: tamcy Date: Wed, 12 Dec 2007 15:01:38 +0000 Subject: [PATCH] commit test case for #673 --- tests/Ticket/673TestCase.php | 71 ++++++++++++++++++++++++++++++++++++ tests/run.php | 1 + 2 files changed, 72 insertions(+) create mode 100644 tests/Ticket/673TestCase.php diff --git a/tests/Ticket/673TestCase.php b/tests/Ticket/673TestCase.php new file mode 100644 index 000000000..ac7cc996b --- /dev/null +++ b/tests/Ticket/673TestCase.php @@ -0,0 +1,71 @@ + + * @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_Ticket_673_TestCase extends Doctrine_UnitTestCase +{ + public function prepareData() + { } + + public function prepareTables() + { + $this->tables = array('T673_Student'); + parent::prepareTables(); + } + + public function testTicket() + { + $q = Doctrine_Query::create() + ->update('T673_Student s') + ->set('s.foo', 's.foo + 1') + ->where('s.id = 2'); + + $this->assertTrue(preg_match_all('/(s_foo)/', $q->getSql(), $m) === 2); + $this->assertTrue(preg_match_all('/(s_id)/', $q->getSql(), $m) === 1); + + try { + $q->execute(); + $this->pass(); + } catch (Exception $e) { + $this->fail($e->__toString()); + } + + $q = Doctrine_Query::create() + ->delete() + ->from('T673_Student s') + ->where('s.name = ? AND s.foo < ?', 'foo', 3); + var_dump($q->getSql()); + $this->assertTrue(preg_match_all('/(s_name)/', $q->getSql(), $m) === 1); + $this->assertTrue(preg_match_all('/(s_foo)/', $q->getSql(), $m) === 1); + + try { + $q->execute(); + $this->pass(); + } catch (Exception $e) { + $this->fail($e->__toString()); + } + } +} + + +class T673_Student extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->setTableName('T673_Student_record'); + + $this->hasColumn('s_id as id', 'varchar', 30, array ( 'primary' => true,)); + $this->hasColumn('s_foo as foo', 'integer', 4, array ('notnull'=>true)); + $this->hasColumn('s_name as name', 'varchar', 50, array ()); + } +} diff --git a/tests/run.php b/tests/run.php index c55d98423..f6b80fce3 100644 --- a/tests/run.php +++ b/tests/run.php @@ -23,6 +23,7 @@ $tickets->addTestCase(new Doctrine_Ticket_642_TestCase()); //If you write a ticket testcase add it here like shown above! $tickets->addTestCase(new Doctrine_Ticket_438_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_638_TestCase()); +$tickets->addTestCase(new Doctrine_Ticket_673_TestCase()); $test->addTestCase($tickets); // Connection drivers (not yet fully tested)