SqliteTestCase.php 6.12 KB
Newer Older
1
<?php
zYne's avatar
zYne committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *  $Id$
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
19
 * <http://www.phpdoctrine.org>.
zYne's avatar
zYne committed
20 21 22 23 24 25 26 27 28
 */

/**
 * Doctrine_DataDict_Sqlite_TestCase
 *
 * @package     Doctrine
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @category    Object Relational Mapping
29
 * @link        www.phpdoctrine.org
zYne's avatar
zYne committed
30 31 32 33 34
 * @since       1.0
 * @version     $Revision$
 */
class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase 
{
35 36
    public function testBooleanMapsToBooleanType() 
    {
zYne's avatar
zYne committed
37 38
        $this->assertDeclarationType('boolean', 'boolean');
    }
39 40
    public function testIntegersMapToIntegerType() 
    {
zYne's avatar
zYne committed
41 42 43 44 45 46 47 48 49
        $this->assertDeclarationType('tinyint', array('integer', 'boolean'));
        $this->assertDeclarationType('smallint', 'integer');
        $this->assertDeclarationType('mediumint', 'integer');
        $this->assertDeclarationType('int', 'integer');
        $this->assertDeclarationType('integer', 'integer');
        $this->assertDeclarationType('serial', 'integer');
        $this->assertDeclarationType('bigint', 'integer');
        $this->assertDeclarationType('bigserial', 'integer');
    }
50 51
    public function testBlobsMapToBlobType() 
    {
zYne's avatar
zYne committed
52 53 54 55 56
        $this->assertDeclarationType('tinyblob', 'blob');
        $this->assertDeclarationType('mediumblob', 'blob');
        $this->assertDeclarationType('longblob', 'blob');
        $this->assertDeclarationType('blob', 'blob');
    }
57 58
    public function testDecimalMapsToDecimal() 
    {
zYne's avatar
zYne committed
59 60 61
        $this->assertDeclarationType('decimal', 'decimal');
        $this->assertDeclarationType('numeric', 'decimal');
    }
62 63
    public function testFloatRealAndDoubleMapToFloat() 
    {
zYne's avatar
zYne committed
64 65 66 67
        $this->assertDeclarationType('float', 'float');
        $this->assertDeclarationType('double', 'float');
        $this->assertDeclarationType('real', 'float');
    }
68 69
    public function testYearMapsToIntegerAndDate() 
    {
zYne's avatar
zYne committed
70
        $this->assertDeclarationType('year', array('integer','date'));
zYne's avatar
zYne committed
71
    }
72 73
    public function testGetNativeDefinitionSupportsIntegerType() 
    {
zYne's avatar
zYne committed
74 75
        $a = array('type' => 'integer', 'length' => 20, 'fixed' => false);

76
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INTEGER');
zYne's avatar
zYne committed
77 78 79 80 81 82 83

        $a['length'] = 4;

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INTEGER');

        $a['length'] = 2;

84
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INTEGER');
zYne's avatar
zYne committed
85 86
    }

87 88
    public function testGetNativeDefinitionSupportsFloatType() 
    {
zYne's avatar
zYne committed
89 90 91 92
        $a = array('type' => 'float', 'length' => 20, 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DOUBLE');
    }
93 94
    public function testGetNativeDefinitionSupportsBooleanType() 
    {
zYne's avatar
zYne committed
95 96
        $a = array('type' => 'boolean', 'fixed' => false);

97
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INTEGER');
zYne's avatar
zYne committed
98
    }
99 100
    public function testGetNativeDefinitionSupportsDateType() 
    {
zYne's avatar
zYne committed
101 102 103 104
        $a = array('type' => 'date', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DATE');
    }
105 106
    public function testGetNativeDefinitionSupportsTimestampType() 
    {
zYne's avatar
zYne committed
107 108 109 110
        $a = array('type' => 'timestamp', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DATETIME');
    }
111 112
    public function testGetNativeDefinitionSupportsTimeType() 
    {
zYne's avatar
zYne committed
113 114 115 116
        $a = array('type' => 'time', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIME');
    }
117 118
    public function testGetNativeDefinitionSupportsClobType() 
    {
zYne's avatar
zYne committed
119 120 121 122
        $a = array('type' => 'clob');

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'LONGTEXT');
    }
123 124
    public function testGetNativeDefinitionSupportsBlobType() 
    {
zYne's avatar
zYne committed
125 126 127 128
        $a = array('type' => 'blob');

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'LONGBLOB');
    }
129 130
    public function testGetNativeDefinitionSupportsCharType() 
    {
zYne's avatar
zYne committed
131 132 133 134
        $a = array('type' => 'char', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CHAR(10)');
    }
135 136
    public function testGetNativeDefinitionSupportsVarcharType() 
    {
zYne's avatar
zYne committed
137 138 139 140
        $a = array('type' => 'varchar', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(10)');
    }
141 142
    public function testGetNativeDefinitionSupportsArrayType() 
    {
zYne's avatar
zYne committed
143 144 145 146
        $a = array('type' => 'array', 'length' => 40);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(40)');
    }
147 148
    public function testGetNativeDefinitionSupportsStringType() 
    {
zYne's avatar
zYne committed
149 150 151 152
        $a = array('type' => 'string');

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
    }
153 154
    public function testGetNativeDefinitionSupportsArrayType2() 
    {
zYne's avatar
zYne committed
155 156 157 158
        $a = array('type' => 'array');

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
    }
159 160
    public function testGetNativeDefinitionSupportsObjectType() 
    {
zYne's avatar
zYne committed
161 162 163 164
        $a = array('type' => 'object');

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
    }
165
}