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_1192_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_1192_TestCase extends Doctrine_UnitTestCase 34{ 35 public function prepareTables() 36 { 37 $this->tables[] = 'Ticket_1192_CPK'; 38 parent::prepareTables(); 39 } 40 41 public function prepareData() 42 { 43 $test1 = new Ticket_1192_CPK(); 44 $test1->user_id = 1; 45 $test1->name = 'Test 1'; 46 $test1->save(); 47 48 $test2 = new Ticket_1192_CPK(); 49 $test2->user_id = 2; 50 $test2->name = 'Test 2'; 51 $test2->save(); 52 53 $test3 = new Ticket_1192_CPK(); 54 $test3->user_id = 2; 55 $test3->name = 'Test 3'; 56 $test3->save(); 57 } 58 59 public function testTest() 60 { 61 $q = Doctrine_Query::create() 62 ->from('Ticket_1192_CPK t') 63 ->groupBy('t.user_id'); 64 65 $this->assertEqual($q->getCountSqlQuery(), 'SELECT COUNT(*) AS num_results FROM ticket_1192__c_p_k t GROUP BY t.user_id'); 66 $count = $q->count(); 67 $this->assertEqual($count, 2); 68 $this->assertEqual($count, $q->execute()->count()); 69 } 70} 71 72class Ticket_1192_CPK extends Doctrine_Record 73{ 74 public function setTableDefinition() 75 { 76 $this->hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); 77 $this->hasColumn('user_id', 'integer', 4, array('primary' => true)); 78 $this->hasColumn('name', 'string', 255); 79 } 80}