1<?php 2/* 3 * $Id: 2229TestCase.php 5871 2009-06-10 08:46:00Z Garfield-fr $ 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_2251_TestCase 24 * 25 * @package Doctrine 26 * @author Daniel Cousineau <dcousineau@gmail.com> 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_2251_TestCase extends Doctrine_UnitTestCase 34{ 35 public function prepareTables() 36 { 37 $this->tables[] = 'Ticket_2251_TestStringLength'; 38 parent::prepareTables(); 39 } 40 41 public function testEmptyStringLengthSQLExport() 42 { 43 $drivers = array( 44 'mysql', 45 'sqlite', 46 'pgsql', 47 'oracle', 48 'mssql' 49 ); 50 51 $expected = array( 52 'mysql' => 'CREATE TABLE test_string_length (id BIGINT AUTO_INCREMENT, test_string TEXT, PRIMARY KEY(id)) ENGINE = INNODB', 53 'sqlite' => 'CREATE TABLE test_string_length (id INTEGER PRIMARY KEY AUTOINCREMENT, test_string TEXT)', 54 'pgsql' => 'CREATE TABLE test_string_length (id BIGSERIAL, test_string TEXT, PRIMARY KEY(id))', 55 'oracle' => 'CREATE TABLE test_string_length (id NUMBER(20), test_string CLOB, PRIMARY KEY(id))', 56 'mssql' => 'CREATE TABLE test_string_length (id INT NOT NULL identity, test_string TEXT NULL, PRIMARY KEY([id]))' 57 ); 58 59 foreach ($drivers as $driver) 60 { 61 $dbh = new Doctrine_Adapter_Mock($driver); 62 63 $conn = Doctrine_Manager::getInstance()->connection($dbh, $driver); 64 65 list($sql) = $conn->export->exportSortedClassesSql(array('Ticket_2251_TestStringLength'), false); 66 67 $this->assertEqual($sql, $expected[$driver]); 68 69 unset($conn); 70 unset($dbh); 71 } 72 } 73} 74 75class Ticket_2251_TestStringLength extends Doctrine_Record 76{ 77 public function setTableDefinition() 78 { 79 $this->setTableName('test_string_length'); 80 $this->hasColumn('test_string', 'string'); 81 } 82 83 public function setUp() 84 { 85 parent::setUp(); 86 } 87}