1<?php
2
3class Doctrine_Ticket_1935_TestCase extends Doctrine_UnitTestCase
4{
5    public function init()
6    {
7        Doctrine_Manager::connection('mysql://root:password@localhost/doctrine', 'Mysql');
8        $this->driverName = 'Mysql';
9        parent::init();
10        Doctrine_Manager::connection('mysql://root:password@localhost/doctrine', 'Mysql');
11        $this->prepareTables();
12        $this->prepareData();
13    }
14
15    public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
16    {
17        parent::run($reporter, $filter);
18        $this->manager->closeConnection($this->connection);
19    }
20
21    public function prepareData()
22    {
23    }
24
25    public function prepareTables()
26    {
27        $this->tables = array('Ticket_1935_Article');
28        parent::prepareTables();
29    }
30
31    public function testDuplicatedParamsInSubQuery()
32    {
33        $this->connection->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
34
35        try
36        {
37            $q = Doctrine_Query::create()->select('COUNT(a.id) as num_records')
38                ->from('Ticket_1935_Article a')
39                ->having('num_records > 1')
40                ;
41            //$results = $q->execute();
42            $this->assertEqual($q->getSqlQuery(), 'SELECT COUNT(`t`.`id`) AS `t__0` FROM `ticket_1935_article` `t` HAVING `t__0` > 1');
43        }
44        catch(Exception $e)
45        {
46            $this->fail($e->getMessage());
47        }
48
49        $this->connection->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false);
50    }
51}
52
53class Ticket_1935_Article extends Doctrine_Record
54{
55    public function setTableDefinition()
56    {
57        $this->setTableName('ticket_1935_article');
58        $this->hasColumn('title', 'string', 255, array('type' => 'string', 'length' => '255'));
59    }
60}
61