FirebirdTestCase.php 9.09 KB
Newer Older
zYne's avatar
zYne committed
1
<?php
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 *  $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
 * <http://www.phpdoctrine.com>.
 */

/**
zYne's avatar
zYne committed
23
 * Doctrine_DataDict_Firebird_TestCase
24 25 26 27 28 29 30 31 32
 *
 * @package     Doctrine
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @category    Object Relational Mapping
 * @link        www.phpdoctrine.com
 * @since       1.0
 * @version     $Revision$
 */
33 34 35 36
class Doctrine_DataDict_Firebird_TestCase extends Doctrine_UnitTestCase 
{
    public function testGetCharsetFieldDeclarationReturnsValidSql() 
    {
37 38
        $this->assertEqual($this->dataDict->getCharsetFieldDeclaration('UTF-8'), 'CHARACTER SET UTF-8');
    }
39 40
    public function testGetCollationFieldDeclarationReturnsValidSql() 
    {
41 42
        $this->assertEqual($this->dataDict->getCollationFieldDeclaration('xx'), 'COLLATE xx');
    }
43 44
    public function testGetPortableDeclarationForUnknownDbTypeThrowsException() 
    {
45 46 47 48 49 50 51
        try {
            $this->dataDict->getPortableDeclaration(array('type' => 'unknown'));
            $this->fail();
        } catch(Doctrine_DataDict_Firebird_Exception $e) {
            $this->pass();
        }
    }
52 53
    public function testGetPortableDeclarationSupportsNativeDateType() 
    {
54 55 56 57
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'date'));
        
        $this->assertEqual($type, array(array('date'), null, null, null));
    }
58 59
    public function testGetPortableDeclarationSupportsNativeTimestampType() 
    {
60 61 62 63
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'timestamp'));
        
        $this->assertEqual($type, array(array('timestamp'), null, null, null));
    }
64 65
    public function testGetPortableDeclarationSupportsNativeTimeType() 
    {
66 67 68 69
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'time'));
        
        $this->assertEqual($type, array(array('time'), null, null, null));
    }
70 71
    public function testGetPortableDeclarationSupportsNativeFloatType() 
    {
72 73 74 75
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'float'));

        $this->assertEqual($type, array(array('float'), null, null, null));
    }
76 77
    public function testGetPortableDeclarationSupportsNativeDoubleType() 
    {
78 79 80 81
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'double'));

        $this->assertEqual($type, array(array('float'), null, null, null));
    }
zYne's avatar
zYne committed
82
    public function testGetPortableDeclarationSupportsNativeDoublePrecisionType() {
83 84 85 86
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'double precision'));

        $this->assertEqual($type, array(array('float'), null, null, null));
    }
87 88
    public function testGetPortableDeclarationSupportsNativeDfloatType() 
    {
89 90 91 92
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'd_float'));
        
        $this->assertEqual($type, array(array('float'), null, null, null));
    }
93 94
    public function testGetPortableDeclarationSupportsNativeDecimalType() 
    {
95 96 97 98
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'decimal'));
        
        $this->assertEqual($type, array(array('decimal'), null, null, null));
    }
99 100
    public function testGetPortableDeclarationSupportsNativeNumericType() 
    {
101 102 103 104
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric'));

        $this->assertEqual($type, array(array('decimal'), null, null, null));
    }
105 106
    public function testGetPortableDeclarationSupportsNativeBlobType() 
    {
107 108 109 110
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'blob'));

        $this->assertEqual($type, array(array('blob'), null, null, null));
    }
111 112
    public function testGetPortableDeclarationSupportsNativeVarcharType() 
    {
113 114 115 116
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar'));

        $this->assertEqual($type, array(array('string'), null, null, false));
    }
117 118
    public function testGetPortableDeclarationSupportsNativeCharType() 
    {
119 120 121 122
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'char'));

        $this->assertEqual($type, array(array('string'), null, null, true));
    }
123 124
    public function testGetPortableDeclarationSupportsNativeCstringType() 
    {
125 126 127 128
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'cstring'));

        $this->assertEqual($type, array(array('string'), null, null, true));
    }
129 130
    public function testGetPortableDeclarationSupportsNativeBigintType() 
    {
131 132 133 134
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'bigint'));

        $this->assertEqual($type, array(array('integer'), null, null, null));
    }
135 136
    public function testGetPortableDeclarationSupportsNativeQuadType() 
    {
137 138 139
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'quad'));

        $this->assertEqual($type, array(array('integer'), null, null, null));
zYne's avatar
zYne committed
140
    }
141 142
    public function testGetNativeDefinitionSupportsIntegerType() 
    {
zYne's avatar
zYne committed
143 144
        $a = array('type' => 'integer', 'length' => 20, 'fixed' => false);

145
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INT');
146

zYne's avatar
zYne committed
147 148 149 150 151 152
        $a['length'] = 4;

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

        $a['length'] = 2;

153
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INT');
zYne's avatar
zYne committed
154 155
    }

156 157
    public function testGetNativeDefinitionSupportsFloatType() 
    {
zYne's avatar
zYne committed
158 159
        $a = array('type' => 'float', 'length' => 20, 'fixed' => false);

160
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DOUBLE PRECISION');
zYne's avatar
zYne committed
161
    }
162 163
    public function testGetNativeDefinitionSupportsBooleanType() 
    {
zYne's avatar
zYne committed
164 165
        $a = array('type' => 'boolean', 'fixed' => false);

166
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'SMALLINT');
zYne's avatar
zYne committed
167
    }
168 169
    public function testGetNativeDefinitionSupportsDateType() 
    {
zYne's avatar
zYne committed
170 171 172 173
        $a = array('type' => 'date', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DATE');
    }
174 175
    public function testGetNativeDefinitionSupportsTimestampType() 
    {
zYne's avatar
zYne committed
176 177
        $a = array('type' => 'timestamp', 'fixed' => false);

178
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIMESTAMP');
zYne's avatar
zYne committed
179
    }
180 181
    public function testGetNativeDefinitionSupportsTimeType() 
    {
zYne's avatar
zYne committed
182 183 184 185
        $a = array('type' => 'time', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIME');
    }
186 187
    public function testGetNativeDefinitionSupportsClobType() 
    {
zYne's avatar
zYne committed
188 189
        $a = array('type' => 'clob');

190
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BLOB SUB_TYPE 1');
zYne's avatar
zYne committed
191
    }
192 193
    public function testGetNativeDefinitionSupportsBlobType() 
    {
zYne's avatar
zYne committed
194 195
        $a = array('type' => 'blob');

196
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BLOB SUB_TYPE 0');
zYne's avatar
zYne committed
197
    }
198 199
    public function testGetNativeDefinitionSupportsCharType() 
    {
zYne's avatar
zYne committed
200 201 202 203
        $a = array('type' => 'char', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CHAR(10)');
    }
204 205
    public function testGetNativeDefinitionSupportsVarcharType() 
    {
zYne's avatar
zYne committed
206 207 208 209
        $a = array('type' => 'varchar', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(10)');
    }
210 211
    public function testGetNativeDefinitionSupportsArrayType() 
    {
zYne's avatar
zYne committed
212 213 214 215
        $a = array('type' => 'array', 'length' => 40);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(40)');
    }
216 217
    public function testGetNativeDefinitionSupportsStringType() 
    {
zYne's avatar
zYne committed
218 219
        $a = array('type' => 'string');

220
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
221
    }
222 223
    public function testGetNativeDefinitionSupportsArrayType2() 
    {
zYne's avatar
zYne committed
224 225
        $a = array('type' => 'array');

226
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
227
    }
228 229
    public function testGetNativeDefinitionSupportsObjectType() 
    {
zYne's avatar
zYne committed
230 231
        $a = array('type' => 'object');

232
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
233 234
    }
}