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_DC28_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_DC28_TestCase extends Doctrine_UnitTestCase 34{ 35 public function prepareTables() 36 { 37 $this->tables[] = 'Ticket_DC28_Tree'; 38 parent::prepareTables(); 39 } 40 41 public function testQuery() 42 { 43 try { 44 $q = Doctrine_Query::create() 45 ->select('a.id, t.lang') 46 ->from('Ticket_DC28_Tree a') 47 ->innerJoin('a.Translation t WITH t.name != ?', 'test') 48 ; 49 $q->execute(); 50 //echo $q->getSqlQuery().PHP_EOL; 51 52 $this->assertEqual( 53 $q->getSqlQuery(), 54 'SELECT t.id AS t__id, t2.id AS t2__id, t2.lang AS t2__lang '. 55 'FROM ticket__d_c28__tree t '. 56 'INNER JOIN ticket__d_c28__tree_translation t2 '. 57 'ON t.id = t2.id AND (t2.name != ?)' 58 ); 59 60 //echo $q->getSqlQuery().PHP_EOL; 61 $tree_table = Doctrine_Core::getTable('Ticket_DC28_Tree'); 62 $tree = $tree_table->getTree(); 63 $tree->setBaseQuery($q); 64 //echo $q->getSqlQuery().PHP_EOL; 65 66 $this->assertEqual( 67 $q->getSqlQuery(), 68 'SELECT t.id AS t__id, t.lft AS t__lft, t.rgt AS t__rgt, t.level AS t__level, t2.id AS t2__id, t2.lang AS t2__lang '. 69 'FROM ticket__d_c28__tree t '. 70 'INNER JOIN ticket__d_c28__tree_translation t2 '. 71 'ON t.id = t2.id AND (t2.name != ?)' 72 ); 73 74 //$this->pass(); 75 } catch (Exception $e) { 76 $this->fail($e->getMessage()); 77 } 78 } 79} 80 81class Ticket_DC28_Tree extends Doctrine_Record 82{ 83 public function setTableDefinition() 84 { 85 $this->hasColumn('name', 'string', 255); 86 } 87 88 public function setUp() 89 { 90 $i18n = new Doctrine_Template_I18n(array('fields' => array(0 => 'name'))); 91 $this->actAs($i18n); 92 $this->actAs('NestedSet'); 93 } 94}