1<?php 2/* 3 * $Id$ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information, see 19 * <http://www.doctrine-project.org>. 20 */ 21 22/** 23 * Doctrine_Ticket_1513_TestCase 24 * 25 * @package Doctrine 26 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> 27 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL 28 * @category Object Relational Mapping 29 * @link www.doctrine-project.org 30 * @since 1.0 31 * @version $Revision$ 32 */ 33class Doctrine_Ticket_1513_TestCase extends Doctrine_UnitTestCase 34{ 35 public function testTest() 36 { 37 $q = Doctrine_Query::create() 38 ->from('T1513_Class2 c2') 39 ->leftJoin('c2.Classes1 c1 WITH (c1.max - c1.min) > 50'); 40 $this->assertEqual($q->getSqlQuery(), 'SELECT t.id AS t__id, t.value AS t__value, t2.id AS t2__id, t2.min AS t2__min, t2.max AS t2__max FROM t1513__class2 t LEFT JOIN t1513__relation t3 ON (t.id = t3.c2_id) LEFT JOIN t1513__class1 t2 ON t2.id = t3.c1_id AND ((t2.max - t2.min) > 50)'); 41 } 42} 43 44class T1513_Class1 extends Doctrine_Record 45{ 46 public function setTableDefinition() 47 { 48 $this->hasColumn('min', 'integer'); 49 $this->hasColumn('max', 'integer'); 50 } 51 52 public function setUp() 53 { 54 $this->hasMany('T1513_Class2 as Classes2', array('local' => 'c1_id', 55 'foreign' => 'c2_id', 56 'refClass' => 'T1513_Relation')); 57 } 58} 59 60class T1513_Class2 extends Doctrine_Record 61{ 62 public function setTableDefinition() 63 { 64 $this->hasColumn('value', 'string', 255); 65 } 66 67 public function setUp() 68 { 69 $this->hasMany('T1513_Class1 as Classes1', array('local' => 'c2_id', 70 'foreign' => 'c1_id', 71 'refClass' => 'T1513_Relation')); 72 } 73} 74 75 76class T1513_Relation extends Doctrine_Record 77{ 78 public function setTableDefinition() 79 { 80 $this->hasColumn('c1_id', 'integer'); 81 $this->hasColumn('c2_id', 'integer'); 82 } 83}