. */ /** * Doctrine_Query_Delete_TestCase * This test case is used for testing DQL UPDATE queries * * @package Doctrine * @author Konsta Vesterinen * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ */ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase { public function testUpdateAllWithColumnAggregationInheritance() { $q = new Doctrine_Query(); $q->parseQuery("UPDATE User u SET u.name = 'someone'"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone' WHERE (type = 0)"); $q = new Doctrine_Query(); $q->update('User u')->set('u.name', "'someone'"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone' WHERE (type = 0)"); } public function testUpdateWorksWithMultipleColumns() { $q = new Doctrine_Query(); $q->parseQuery("UPDATE User u SET u.name = 'someone', u.email_id = 5"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone', email_id = 5 WHERE (type = 0)"); $q = new Doctrine_Query(); $q->update('User u')->set('u.name', "'someone'")->set('u.email_id', 5); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone', email_id = 5 WHERE (type = 0)"); } public function testUpdateSupportsConditions() { $q = new Doctrine_Query(); $q->parseQuery("UPDATE User u SET u.name = 'someone' WHERE u.id = 5"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone' WHERE id = 5 AND (type = 0)"); } public function testUpdateSupportsColumnReferencing() { $q = new Doctrine_Query(); $q->update('User u')->set('u.id', 'u.id + 1'); $this->assertEqual($q->getQuery(), "UPDATE entity SET id = id + 1 WHERE (type = 0)"); } }