1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/tests/Connection/PgsqlTestCase.php

218 lines
8.1 KiB
PHP
Raw Normal View History

2006-12-28 00:34:26 +03:00
<?php
/*
* $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$
*/
2007-07-06 15:56:12 +04:00
class Doctrine_Connection_Pgsql_TestCase extends Doctrine_UnitTestCase
{
public function testNoSuchTableErrorIsSupported()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'table test does not exist')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
}
2007-07-06 15:56:12 +04:00
public function testNoSuchTableErrorIsSupported2()
{
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'relation does not exist')));
2007-01-06 01:07:50 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
}
2007-07-06 15:56:12 +04:00
public function testNoSuchTableErrorIsSupported3()
{
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'sequence does not exist')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
}
2007-07-06 15:56:12 +04:00
public function testNoSuchTableErrorIsSupported4()
{
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'class xx not found')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE);
}
2007-07-06 15:56:12 +04:00
public function testSyntaxErrorIsSupported()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'parser: parse error at or near')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
}
2007-07-06 15:56:12 +04:00
public function testSyntaxErrorIsSupported2()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'syntax error at')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
}
2007-07-06 15:56:12 +04:00
public function testSyntaxErrorIsSupported3()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'column reference r.r is ambiguous')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX);
}
2007-07-06 15:56:12 +04:00
public function testInvalidNumberErrorIsSupported()
{
2006-12-28 00:34:26 +03:00
$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);
}
2007-07-06 15:56:12 +04:00
public function testInvalidNumberErrorIsSupported2()
{
2006-12-28 00:34:26 +03:00
$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);
}
2007-07-06 15:56:12 +04:00
public function testInvalidNumberErrorIsSupported3()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'integer out of range')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
}
2007-07-06 15:56:12 +04:00
public function testInvalidNumberErrorIsSupported4()
{
2006-12-28 00:34:26 +03:00
$this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'invalid input syntax for type integer')));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID_NUMBER);
}
2007-07-06 15:56:12 +04:00
public function testNoSuchFieldErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'column name (of relation xx) does not exist'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
}
2007-07-06 15:56:12 +04:00
public function testNoSuchFieldErrorIsSupported2()
{
$this->exc->processErrorInfo(array(0, 0, 'attribute xx not found'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
2006-12-28 00:34:26 +03:00
}
2007-07-06 15:56:12 +04:00
public function testNoSuchFieldErrorIsSupported3()
{
$this->exc->processErrorInfo(array(0, 0, 'relation xx does not have attribute'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
2006-12-28 00:34:26 +03:00
}
2007-07-06 15:56:12 +04:00
public function testNoSuchFieldErrorIsSupported4()
{
$this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in left table'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
2006-12-28 00:34:26 +03:00
}
2007-07-06 15:56:12 +04:00
public function testNoSuchFieldErrorIsSupported5()
{
$this->exc->processErrorInfo(array(0, 0, 'column xx specified in USING clause does not exist in right table'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD);
2006-12-28 00:34:26 +03:00
}
2007-07-06 15:56:12 +04:00
public function testNotFoundErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'index xx does not exist/'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOT_FOUND);
}
2007-07-06 15:56:12 +04:00
public function testNotNullConstraintErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'violates not-null constraint'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT_NOT_NULL);
}
2007-07-06 15:56:12 +04:00
public function testConstraintErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'referential integrity violation'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
}
2007-07-06 15:56:12 +04:00
public function testConstraintErrorIsSupported2()
{
$this->exc->processErrorInfo(array(0, 0, 'violates xx constraint'));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT);
2006-12-28 00:34:26 +03:00
}
2007-07-06 15:56:12 +04:00
public function testInvalidErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'value too long for type character'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_INVALID);
}
2007-07-06 15:56:12 +04:00
public function testAlreadyExistsErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'relation xx already exists'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ALREADY_EXISTS);
}
2007-07-06 15:56:12 +04:00
public function testDivZeroErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'division by zero'));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
}
2007-07-06 15:56:12 +04:00
public function testDivZeroErrorIsSupported2()
{
$this->exc->processErrorInfo(array(0, 0, 'divide by zero'));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_DIVZERO);
}
2007-07-06 15:56:12 +04:00
public function testAccessViolationErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'permission denied'));
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_ACCESS_VIOLATION);
}
2007-07-06 15:56:12 +04:00
public function testValueCountOnRowErrorIsSupported()
{
$this->exc->processErrorInfo(array(0, 0, 'more expressions than target columns'));
2006-12-28 00:34:26 +03:00
$this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_VALUE_COUNT_ON_ROW);
}
}