PgsqlTestCase.php 8.08 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
/*
 *  $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>.
20 21 22 23 24 25 26 27 28
 */

/**
 * Doctrine_Connection_Pgsql_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
30 31 32
 * @since       1.0
 * @version     $Revision$
 */
zYne's avatar
zYne committed
33 34 35 36 37
class Doctrine_Connection_Pgsql_TestCase extends Doctrine_UnitTestCase 
{

    public function testNoSuchTableErrorIsSupported() 
    {
zYne's avatar
zYne committed
38 39 40 41
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'table test does not exist')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
zYne's avatar
zYne committed
42 43 44

    public function testNoSuchTableErrorIsSupported2() 
    {
45
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'relation does not exist')));
zYne's avatar
zYne committed
46

47 48
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
zYne's avatar
zYne committed
49 50 51

    public function testNoSuchTableErrorIsSupported3() 
    {
52 53 54 55
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'sequence does not exist')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
zYne's avatar
zYne committed
56 57 58

    public function testNoSuchTableErrorIsSupported4() 
    {
59 60 61 62
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'class xx not found')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
zYne's avatar
zYne committed
63 64 65

    public function testSyntaxErrorIsSupported() 
    {
zYne's avatar
zYne committed
66 67 68 69
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'parser: parse error at or near')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
zYne's avatar
zYne committed
70 71 72

    public function testSyntaxErrorIsSupported2() 
    {
zYne's avatar
zYne committed
73 74 75 76
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'syntax error at')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
zYne's avatar
zYne committed
77 78 79

    public function testSyntaxErrorIsSupported3() 
    {
zYne's avatar
zYne committed
80 81 82 83
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'column reference r.r is ambiguous')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
zYne's avatar
zYne committed
84 85 86

    public function testInvalidNumberErrorIsSupported() 
    {
zYne's avatar
zYne committed
87 88 89 90
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'pg_atoi: error in somewhere: can\'t parse ')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
zYne's avatar
zYne committed
91 92 93

    public function testInvalidNumberErrorIsSupported2() 
    {
zYne's avatar
zYne committed
94 95 96 97
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'value unknown is out of range for type bigint')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
zYne's avatar
zYne committed
98 99 100

    public function testInvalidNumberErrorIsSupported3() 
    {
zYne's avatar
zYne committed
101 102 103 104
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'integer out of range')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
zYne's avatar
zYne committed
105 106 107

    public function testInvalidNumberErrorIsSupported4() 
    {
zYne's avatar
zYne committed
108 109 110 111
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'invalid input syntax for type integer')));

        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
zYne's avatar
zYne committed
112 113 114

    public function testNoSuchFieldErrorIsSupported() 
    {
115
        $this->exc->processErrorInfo(array(0, 0, 'column name (of relation xx) does not exist'));
zYne's avatar
zYne committed
116 117 118
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
    }
zYne's avatar
zYne committed
119 120 121

    public function testNoSuchFieldErrorIsSupported2() 
    {
122
        $this->exc->processErrorInfo(array(0, 0, 'attribute xx not found'));
zYne's avatar
zYne committed
123
        
124
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
125
    }
zYne's avatar
zYne committed
126 127 128

    public function testNoSuchFieldErrorIsSupported3() 
    {
129
        $this->exc->processErrorInfo(array(0, 0, 'relation xx does not have attribute'));
zYne's avatar
zYne committed
130
        
131
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
132
    }
zYne's avatar
zYne committed
133 134 135

    public function testNoSuchFieldErrorIsSupported4() 
    {
136
        $this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in left table'));
zYne's avatar
zYne committed
137
        
138
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
139
    }
zYne's avatar
zYne committed
140 141 142

    public function testNoSuchFieldErrorIsSupported5() 
    {
143
        $this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in right table'));
zYne's avatar
zYne committed
144
        
145
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
146
    }
zYne's avatar
zYne committed
147 148 149

    public function testNotFoundErrorIsSupported() 
    {
150
        $this->exc->processErrorInfo(array(0, 0, 'index xx does not exist/'));
zYne's avatar
zYne committed
151 152 153
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOT_FOUND);
    }
154
    
zYne's avatar
zYne committed
155 156
    public function testNotNullConstraintErrorIsSupported() 
    {
157
        $this->exc->processErrorInfo(array(0, 0, 'violates not-null constraint'));
zYne's avatar
zYne committed
158 159 160
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT_NOT_NULL);
    }
zYne's avatar
zYne committed
161 162 163

    public function testConstraintErrorIsSupported() 
    {
164
        $this->exc->processErrorInfo(array(0, 0, 'referential integrity violation'));
zYne's avatar
zYne committed
165
        
166 167
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
    }
zYne's avatar
zYne committed
168 169 170

    public function testConstraintErrorIsSupported2() 
    {
171 172 173
        $this->exc->processErrorInfo(array(0, 0, 'violates xx constraint'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
zYne's avatar
zYne committed
174
    }
zYne's avatar
zYne committed
175 176 177

    public function testInvalidErrorIsSupported()
    {
178
        $this->exc->processErrorInfo(array(0, 0, 'value too long for type character'));
zYne's avatar
zYne committed
179 180 181
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID);
    }
zYne's avatar
zYne committed
182 183 184

    public function testAlreadyExistsErrorIsSupported() 
    {
185
        $this->exc->processErrorInfo(array(0, 0, 'relation xx already exists'));
zYne's avatar
zYne committed
186 187 188
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ALREADY_EXISTS);
    }
zYne's avatar
zYne committed
189 190 191

    public function testDivZeroErrorIsSupported() 
    {
192 193 194 195
        $this->exc->processErrorInfo(array(0, 0, 'division by zero'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
    }
zYne's avatar
zYne committed
196 197 198

    public function testDivZeroErrorIsSupported2() 
    {
199 200 201 202
        $this->exc->processErrorInfo(array(0, 0, 'divide by zero'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
    }
zYne's avatar
zYne committed
203 204 205

    public function testAccessViolationErrorIsSupported()
    {
206 207 208 209
        $this->exc->processErrorInfo(array(0, 0, 'permission denied'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ACCESS_VIOLATION);
    }
zYne's avatar
zYne committed
210 211 212
    
    public function testValueCountOnRowErrorIsSupported() 
    {
213
        $this->exc->processErrorInfo(array(0, 0, 'more expressions than target columns'));
zYne's avatar
zYne committed
214 215 216 217
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_VALUE_COUNT_ON_ROW);
    }
}