From b0f3a5d77a4fc60b32f8c4830111f3984ac8a045 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 5 Jan 2007 22:07:50 +0000 Subject: [PATCH] test cases updated --- tests/Connection/FirebirdTestCase.php | 7 ++- tests/Connection/InformixTestCase.php | 61 +-------------------------- tests/Connection/PgsqlTestCase.php | 2 +- tests/DriverTestCase.php | 1 + tests/Export/ReporterTestCase.php | 6 --- tests/HookTestCase.php | 13 +++++- tests/Query/MultiJoinTestCase.php | 5 +-- tests/run.php | 3 +- 8 files changed, 23 insertions(+), 75 deletions(-) diff --git a/tests/Connection/FirebirdTestCase.php b/tests/Connection/FirebirdTestCase.php index 5f5cad815..2c77ce1a3 100644 --- a/tests/Connection/FirebirdTestCase.php +++ b/tests/Connection/FirebirdTestCase.php @@ -1,8 +1,6 @@ exc->processErrorInfo(array(0,0, 'no such table: test1')); @@ -58,4 +56,5 @@ class Doctrine_Connection_Firebird_TestCase extends Doctrine_Driver_UnitTestCase $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_VALUE_COUNT_ON_ROW); } + */ } diff --git a/tests/Connection/InformixTestCase.php b/tests/Connection/InformixTestCase.php index 4256df228..274c42638 100644 --- a/tests/Connection/InformixTestCase.php +++ b/tests/Connection/InformixTestCase.php @@ -1,61 +1,4 @@ exc->processErrorInfo(array(0,0, 'no such table: test1')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE); - } - public function testNoSuchIndexErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'no such index: test1')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOT_FOUND); - } - public function testUniquePrimaryKeyErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'PRIMARY KEY must be unique')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT); - } - public function testIsNotUniqueErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'is not unique')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT); - } - public function testColumnsNotUniqueErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'columns name, id are not unique')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT); - } - public function testUniquenessConstraintErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'uniqueness constraint failed')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT); - } - public function testNotNullConstraintErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'may not be NULL')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_CONSTRAINT_NOT_NULL); - } - public function testNoSuchFieldErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, 'no such column: column1')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD); - } - public function testColumnNotPresentInTablesErrorIsSupported2() { - $this->exc->processErrorInfo(array(0,0, 'column not present in both tables')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHFIELD); - } - public function testNearSyntaxErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, "near \"SELECT FROM\": syntax error")); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_SYNTAX); - } - public function testValueCountOnRowErrorIsSupported() { - $this->exc->processErrorInfo(array(0,0, '3 values for 2 columns')); - - $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_VALUE_COUNT_ON_ROW); - } +class Doctrine_Connection_Informix_TestCase extends Doctrine_UnitTestCase { + } diff --git a/tests/Connection/PgsqlTestCase.php b/tests/Connection/PgsqlTestCase.php index 2f26e9c85..84d9aabf3 100644 --- a/tests/Connection/PgsqlTestCase.php +++ b/tests/Connection/PgsqlTestCase.php @@ -38,7 +38,7 @@ class Doctrine_Connection_Pgsql_TestCase extends Doctrine_UnitTestCase { } public function testNoSuchTableErrorIsSupported2() { $this->assertTrue($this->exc->processErrorInfo(array(0, 0, 'relation does not exist'))); - + $this->assertEqual($this->exc->getPortableCode(), Doctrine::ERR_NOSUCHTABLE); } public function testNoSuchTableErrorIsSupported3() { diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index 771fd7040..4f1e44f06 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -86,6 +86,7 @@ class AdapterStatementMock { return true; } } + class Doctrine_Driver_UnitTestCase extends UnitTestCase { protected $driverName = false; protected $generic = false; diff --git a/tests/Export/ReporterTestCase.php b/tests/Export/ReporterTestCase.php index 862199278..f85d535e3 100644 --- a/tests/Export/ReporterTestCase.php +++ b/tests/Export/ReporterTestCase.php @@ -13,10 +13,4 @@ class Doctrine_Export_Reporter_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($reporter->pop(), array(E_WARNING, 'Badly named class.')); } - public function testExportReportsExceptions() { - - $reporter = $this->export->export('User'); - // Class name is not valid. Double underscores are not allowed - - } } diff --git a/tests/HookTestCase.php b/tests/HookTestCase.php index c36344678..9abca4e79 100644 --- a/tests/HookTestCase.php +++ b/tests/HookTestCase.php @@ -1,5 +1,14 @@ parse('u', 'name', "'some guy' OR zYne"); + + $this->assertEqual($parser->getCondition(), '(u.name LIKE ? OR u.name LIKE ?)'); + $this->assertEqual($parser->getParams(), array('some guy%', 'zYne%')); + } + public function testHookOrderbyAcceptsArray() { $hook = new Doctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p'); @@ -53,9 +62,10 @@ class Doctrine_Hook_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($hook->getQuery()->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); } + public function testEqualParserUsesEqualOperator() { $parser = new Doctrine_Hook_Equal(); - + $parser->parse('u', 'name', 'zYne'); $this->assertEqual($parser->getCondition(), 'u.name = ?'); @@ -95,5 +105,6 @@ class Doctrine_Hook_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($parser->getCondition(), '((m.year > ? AND m.year < ?) OR m.year = ?)'); $this->assertEqual($parser->getParams(), array('1998', '2000', '2001')); } + } ?> diff --git a/tests/Query/MultiJoinTestCase.php b/tests/Query/MultiJoinTestCase.php index 31e877e13..63e9facbe 100644 --- a/tests/Query/MultiJoinTestCase.php +++ b/tests/Query/MultiJoinTestCase.php @@ -47,19 +47,18 @@ class Doctrine_Query_MultiJoin_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($user->Album[0]->Song), 0); $this->assertEqual(count($user->Album[1]->Song), 2); - } - public function testMultipleOneToManyFetching() { $this->connection->clear(); $query = new Doctrine_Query(); $users = $query->query("FROM User.Album.Song, User.Phonenumber WHERE User.id IN (4,5)"); - + $this->assertEqual($users->count(), 2); $this->assertEqual($users[0]->id, 4); + $this->assertEqual($users[0]->Album[0]->name, 'Damage Done'); $this->assertEqual($users[0]->Album[0]->Song[0]->title, 'Damage Done'); $this->assertEqual($users[0]->Album[0]->Song[1]->title, 'The Treason Wall'); diff --git a/tests/run.php b/tests/run.php index f1bb0c257..476e3076b 100644 --- a/tests/run.php +++ b/tests/run.php @@ -66,7 +66,7 @@ $test->addTestCase(new Doctrine_Connection_Mssql_TestCase()); $test->addTestCase(new Doctrine_Connection_Mysql_TestCase()); $test->addTestCase(new Doctrine_Connection_Firebird_TestCase()); $test->addTestCase(new Doctrine_Connection_Informix_TestCase()); - +/** // Transaction module (FULLY TESTED) $test->addTestCase(new Doctrine_Transaction_TestCase()); $test->addTestCase(new Doctrine_Transaction_Firebird_TestCase()); @@ -195,6 +195,7 @@ $test->addTestCase(new Doctrine_Query_JoinCondition_TestCase()); $test->addTestCase(new Doctrine_TreeStructure_TestCase()); +*/ // Cache tests //$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());