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_DC238_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_DC238_TestCase extends Doctrine_UnitTestCase 34{ 35 public function testTest() 36 { 37 $conn = Doctrine_Manager::connection('sqlite::memory:', 'test', false); 38 $conn->export->exportClasses(array('Ticket_DC238_User')); 39 40 $user = new Ticket_DC238_User(); 41 $user->username = 'jwage'; 42 $user->password = 'changeme'; 43 $user->save(); 44 45 $profiler = new Doctrine_Connection_Profiler(); 46 $conn->addListener($profiler); 47 48 $cacheDriver = new Doctrine_Cache_Array(); 49 $q = Doctrine_Core::getTable('Ticket_DC238_User') 50 ->createQuery('u') 51 ->useResultCache($cacheDriver, 3600, 'user_query'); 52 53 $this->assertEqual(0, $profiler->count()); 54 55 $this->assertEqual(1, $q->count()); 56 57 $this->assertEqual(1, $profiler->count()); 58 59 $this->assertEqual(1, $q->count()); 60 61 $this->assertEqual(1, $profiler->count()); 62 63 $this->assertTrue($cacheDriver->contains('user_query_count')); 64 } 65} 66 67class Ticket_DC238_User extends Doctrine_Record 68{ 69 public function setTableDefinition() 70 { 71 $this->hasColumn('username', 'string', 255); 72 $this->hasColumn('password', 'string', 255); 73 } 74}