PgsqlTestCase.php 7.87 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 23 24 25 26 27 28 29 30 31 32
/*
 *  $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>.
 */

/**
 * 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
 * @link        www.phpdoctrine.com
 * @since       1.0
 * @version     $Revision$
 */
zYne's avatar
zYne committed
33 34 35 36 37 38
class Doctrine_Connection_Pgsql_TestCase extends Doctrine_UnitTestCase {
    public function testNoSuchTableErrorIsSupported() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'table test does not exist')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
39 40
    public function testNoSuchTableErrorIsSupported2() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'relation does not exist')));
zYne's avatar
zYne committed
41

42 43 44 45 46 47 48 49 50 51 52 53
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
    public function testNoSuchTableErrorIsSupported3() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'sequence does not exist')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
    }
    public function testNoSuchTableErrorIsSupported4() {
        $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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    public function testSyntaxErrorIsSupported() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'parser: parse error at or near')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
    public function testSyntaxErrorIsSupported2() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'syntax error at')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
    public function testSyntaxErrorIsSupported3() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'column reference r.r is ambiguous')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
    }
    public function testInvalidNumberErrorIsSupported() {
        $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);
    }
    public function testInvalidNumberErrorIsSupported2() {
        $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);
    }
    public function testInvalidNumberErrorIsSupported3() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'integer out of range')));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
    public function testInvalidNumberErrorIsSupported4() {
        $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'invalid input syntax for type integer')));

        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
    }
    public function testNoSuchFieldErrorIsSupported() {
90
        $this->exc->processErrorInfo(array(0, 0, 'column name (of relation xx) does not exist'));
zYne's avatar
zYne committed
91 92 93
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
    }
94 95
    public function testNoSuchFieldErrorIsSupported2() {
        $this->exc->processErrorInfo(array(0, 0, 'attribute xx not found'));
zYne's avatar
zYne committed
96
        
97
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
98
    }
99 100
    public function testNoSuchFieldErrorIsSupported3() {
        $this->exc->processErrorInfo(array(0, 0, 'relation xx does not have attribute'));
zYne's avatar
zYne committed
101
        
102
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
103
    }
104 105
    public function testNoSuchFieldErrorIsSupported4() {
        $this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in left table'));
zYne's avatar
zYne committed
106
        
107
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
108
    }
109 110
    public function testNoSuchFieldErrorIsSupported5() {
        $this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in right table'));
zYne's avatar
zYne committed
111
        
112
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
zYne's avatar
zYne committed
113 114
    }
    public function testNotFoundErrorIsSupported() {
115
        $this->exc->processErrorInfo(array(0, 0, 'index xx does not exist/'));
zYne's avatar
zYne committed
116 117 118
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOT_FOUND);
    }
119
    
zYne's avatar
zYne committed
120
    public function testNotNullConstraintErrorIsSupported() {
121
        $this->exc->processErrorInfo(array(0, 0, 'violates not-null constraint'));
zYne's avatar
zYne committed
122 123 124
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT_NOT_NULL);
    }
125 126
    public function testConstraintErrorIsSupported() {
        $this->exc->processErrorInfo(array(0, 0, 'referential integrity violation'));
zYne's avatar
zYne committed
127
        
128 129 130 131 132 133
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
    }
    public function testConstraintErrorIsSupported2() {
        $this->exc->processErrorInfo(array(0, 0, 'violates xx constraint'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
zYne's avatar
zYne committed
134 135
    }
    public function testInvalidErrorIsSupported() {
136
        $this->exc->processErrorInfo(array(0, 0, 'value too long for type character'));
zYne's avatar
zYne committed
137 138 139 140
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID);
    }
    public function testAlreadyExistsErrorIsSupported() {
141
        $this->exc->processErrorInfo(array(0, 0, 'relation xx already exists'));
zYne's avatar
zYne committed
142 143 144
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ALREADY_EXISTS);
    }
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    public function testDivZeroErrorIsSupported() {
        $this->exc->processErrorInfo(array(0, 0, 'division by zero'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
    }
    public function testDivZeroErrorIsSupported2() {
        $this->exc->processErrorInfo(array(0, 0, 'divide by zero'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
    }
    public function testAccessViolationErrorIsSupported() {
        $this->exc->processErrorInfo(array(0, 0, 'permission denied'));
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ACCESS_VIOLATION);
    }
zYne's avatar
zYne committed
160
    public function testValueCountOnRowErrorIsSupported() {
161
        $this->exc->processErrorInfo(array(0, 0, 'more expressions than target columns'));
zYne's avatar
zYne committed
162 163 164 165
        
        $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_VALUE_COUNT_ON_ROW);
    }
}