FirebirdTestCase.php 11.6 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
        try {
            $this->dataDict->getPortableDeclaration(array('type' => 'unknown'));
            $this->fail();
zYne's avatar
zYne committed
48
        } catch(Doctrine_DataDict_Exception $e) {
49 50 51
            $this->pass();
        }
    }
52 53
    public function testGetPortableDeclarationSupportsNativeDateType() 
    {
54 55
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'date'));
        
zYne's avatar
zYne committed
56 57 58 59
        $this->assertEqual($type, array('type' => array('date'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
60
    }
61 62
    public function testGetPortableDeclarationSupportsNativeTimestampType() 
    {
63 64
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'timestamp'));
        
zYne's avatar
zYne committed
65 66 67 68
        $this->assertEqual($type, array('type' => array('timestamp'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
69
    }
70 71
    public function testGetPortableDeclarationSupportsNativeTimeType() 
    {
72 73
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'time'));
        
zYne's avatar
zYne committed
74 75 76 77
        $this->assertEqual($type, array('type' => array('time'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));    
78
    }
79 80
    public function testGetPortableDeclarationSupportsNativeFloatType() 
    {
81 82
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'float'));

zYne's avatar
zYne committed
83 84 85 86
        $this->assertEqual($type, array('type' => array('float'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
87
    }
88 89
    public function testGetPortableDeclarationSupportsNativeDoubleType() 
    {
90 91
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'double'));

zYne's avatar
zYne committed
92 93 94 95
        $this->assertEqual($type, array('type' => array('float'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
96
    }
zYne's avatar
zYne committed
97
    public function testGetPortableDeclarationSupportsNativeDoublePrecisionType() {
98 99
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'double precision'));

zYne's avatar
zYne committed
100 101 102 103
        $this->assertEqual($type, array('type' => array('float'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
104
    }
105 106
    public function testGetPortableDeclarationSupportsNativeDfloatType() 
    {
107 108
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'd_float'));
        
zYne's avatar
zYne committed
109 110 111 112
        $this->assertEqual($type, array('type' => array('float'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
113
    }
114 115
    public function testGetPortableDeclarationSupportsNativeDecimalType() 
    {
116 117
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'decimal'));
        
zYne's avatar
zYne committed
118 119 120 121
        $this->assertEqual($type, array('type' => array('decimal'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
122
    }
123 124
    public function testGetPortableDeclarationSupportsNativeNumericType() 
    {
125 126
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric'));

zYne's avatar
zYne committed
127 128 129 130
        $this->assertEqual($type, array('type' => array('decimal'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
131
    }
132 133
    public function testGetPortableDeclarationSupportsNativeBlobType() 
    {
134 135
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'blob'));

zYne's avatar
zYne committed
136 137 138 139
        $this->assertEqual($type, array('type' => array('blob'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
140
    }
141 142
    public function testGetPortableDeclarationSupportsNativeVarcharType() 
    {
143 144
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar'));

zYne's avatar
zYne committed
145 146 147 148
        $this->assertEqual($type, array('type' => array('string'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
149
    }
150 151
    public function testGetPortableDeclarationSupportsNativeCharType() 
    {
152 153
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'char'));

zYne's avatar
zYne committed
154 155 156 157
        $this->assertEqual($type, array('type' => array('string'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => true));
158
    }
159 160
    public function testGetPortableDeclarationSupportsNativeCstringType() 
    {
161 162
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'cstring'));

zYne's avatar
zYne committed
163 164 165 166
        $this->assertEqual($type, array('type' => array('string'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => true));
167
    }
zYne's avatar
zYne committed
168
    public function testGetPortableDeclarationSupportsNativeBigintType()
169
    {
170 171
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'bigint'));

zYne's avatar
zYne committed
172 173 174 175
        $this->assertEqual($type, array('type' => array('integer'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
176
    }
177 178
    public function testGetPortableDeclarationSupportsNativeQuadType() 
    {
179 180
        $type = $this->dataDict->getPortableDeclaration(array('type' => 'quad'));

zYne's avatar
zYne committed
181 182 183 184
        $this->assertEqual($type, array('type' => array('integer'),
                                        'length' => null,
                                        'unsigned' => null,
                                        'fixed' => null));
zYne's avatar
zYne committed
185
    }
186 187
    public function testGetNativeDefinitionSupportsIntegerType() 
    {
zYne's avatar
zYne committed
188 189
        $a = array('type' => 'integer', 'length' => 20, 'fixed' => false);

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

zYne's avatar
zYne committed
192 193 194 195 196 197
        $a['length'] = 4;

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

        $a['length'] = 2;

198
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INT');
zYne's avatar
zYne committed
199 200
    }

201 202
    public function testGetNativeDefinitionSupportsFloatType() 
    {
zYne's avatar
zYne committed
203 204
        $a = array('type' => 'float', 'length' => 20, 'fixed' => false);

205
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DOUBLE PRECISION');
zYne's avatar
zYne committed
206
    }
207 208
    public function testGetNativeDefinitionSupportsBooleanType() 
    {
zYne's avatar
zYne committed
209 210
        $a = array('type' => 'boolean', 'fixed' => false);

211
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'SMALLINT');
zYne's avatar
zYne committed
212
    }
213 214
    public function testGetNativeDefinitionSupportsDateType() 
    {
zYne's avatar
zYne committed
215 216 217 218
        $a = array('type' => 'date', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DATE');
    }
219 220
    public function testGetNativeDefinitionSupportsTimestampType() 
    {
zYne's avatar
zYne committed
221 222
        $a = array('type' => 'timestamp', 'fixed' => false);

223
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIMESTAMP');
zYne's avatar
zYne committed
224
    }
225 226
    public function testGetNativeDefinitionSupportsTimeType() 
    {
zYne's avatar
zYne committed
227 228 229 230
        $a = array('type' => 'time', 'fixed' => false);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIME');
    }
231 232
    public function testGetNativeDefinitionSupportsClobType() 
    {
zYne's avatar
zYne committed
233 234
        $a = array('type' => 'clob');

235
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BLOB SUB_TYPE 1');
zYne's avatar
zYne committed
236
    }
237 238
    public function testGetNativeDefinitionSupportsBlobType() 
    {
zYne's avatar
zYne committed
239 240
        $a = array('type' => 'blob');

241
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BLOB SUB_TYPE 0');
zYne's avatar
zYne committed
242
    }
243 244
    public function testGetNativeDefinitionSupportsCharType() 
    {
zYne's avatar
zYne committed
245 246 247 248
        $a = array('type' => 'char', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CHAR(10)');
    }
249 250
    public function testGetNativeDefinitionSupportsVarcharType() 
    {
zYne's avatar
zYne committed
251 252 253 254
        $a = array('type' => 'varchar', 'length' => 10);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(10)');
    }
255 256
    public function testGetNativeDefinitionSupportsArrayType() 
    {
zYne's avatar
zYne committed
257 258 259 260
        $a = array('type' => 'array', 'length' => 40);

        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(40)');
    }
261 262
    public function testGetNativeDefinitionSupportsStringType() 
    {
zYne's avatar
zYne committed
263 264
        $a = array('type' => 'string');

265
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
266
    }
267 268
    public function testGetNativeDefinitionSupportsArrayType2() 
    {
zYne's avatar
zYne committed
269 270
        $a = array('type' => 'array');

271
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
272
    }
273 274
    public function testGetNativeDefinitionSupportsObjectType() 
    {
zYne's avatar
zYne committed
275 276
        $a = array('type' => 'object');

277
        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(16777215)');
zYne's avatar
zYne committed
278 279
    }
}