diff --git a/tests/AccessTestCase.php b/tests/AccessTestCase.php index 99268aad2..9a0c0d356 100644 --- a/tests/AccessTestCase.php +++ b/tests/AccessTestCase.php @@ -1,13 +1,42 @@ . + */ + +/** + * Doctrine_Access_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Access_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { - $this->tables = array("Entity", "User"); + $this->tables = array('Entity', 'User'); parent::prepareTables(); } - public function testUnset() { - - + public function testUnset() { } public function testIsset() { @@ -32,54 +61,54 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase { } public function testOffsetMethods() { $user = new User(); - $this->assertEqual($user["name"],null); + $this->assertEqual($user['name'],null); - $user["name"] = "Jack"; - $this->assertEqual($user["name"],"Jack"); + $user['name'] = 'Jack'; + $this->assertEqual($user['name'], 'Jack'); $user->save(); - $user = $this->connection->getTable("User")->find($user->obtainIdentifier()); - $this->assertEqual($user->name,"Jack"); + $user = $this->connection->getTable('User')->find($user->obtainIdentifier()); + $this->assertEqual($user->name, 'Jack'); - $user["name"] = "Jack"; - $this->assertEqual($user["name"],"Jack"); - $user["name"] = "zYne"; - $this->assertEqual($user["name"],"zYne"); + $user['name'] = 'Jack'; + $this->assertEqual($user['name'], 'Jack'); + $user['name'] = 'zYne'; + $this->assertEqual($user['name'], 'zYne'); } public function testOverload() { $user = new User(); $this->assertEqual($user->name,null); - $user->name = "Jack"; + $user->name = 'Jack'; - $this->assertEqual($user->name,"Jack"); + $this->assertEqual($user->name, 'Jack'); $user->save(); - $user = $this->connection->getTable("User")->find($user->obtainIdentifier()); - $this->assertEqual($user->name,"Jack"); + $user = $this->connection->getTable('User')->find($user->obtainIdentifier()); + $this->assertEqual($user->name, 'Jack'); - $user->name = "Jack"; - $this->assertEqual($user->name,"Jack"); - $user->name = "zYne"; - $this->assertEqual($user->name,"zYne"); + $user->name = 'Jack'; + $this->assertEqual($user->name, 'Jack'); + $user->name = 'zYne'; + $this->assertEqual($user->name, 'zYne'); } public function testSet() { $user = new User(); - $this->assertEqual($user->get("name"),null); + $this->assertEqual($user->get('name'),null); - $user->set("name","Jack"); - $this->assertEqual($user->get("name"),"Jack"); + $user->set('name', 'Jack'); + $this->assertEqual($user->get('name'), 'Jack'); $user->save(); - $user = $this->connection->getTable("User")->find($user->obtainIdentifier()); + $user = $this->connection->getTable('User')->find($user->obtainIdentifier()); - $this->assertEqual($user->get("name"),"Jack"); + $this->assertEqual($user->get('name'), 'Jack'); - $user->set("name","Jack"); - $this->assertEqual($user->get("name"),"Jack"); + $user->set('name', 'Jack'); + $this->assertEqual($user->get('name'), 'Jack'); } } ?> diff --git a/tests/BatchIteratorTestCase.php b/tests/BatchIteratorTestCase.php index 55d800920..1f77419d4 100644 --- a/tests/BatchIteratorTestCase.php +++ b/tests/BatchIteratorTestCase.php @@ -1,7 +1,36 @@ . + */ -class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase { +/** + * Doctrine_BatchIterator_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_BatchIterator_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { $this->tables = array("Entity", "User","Group","Address","Phonenumber"); diff --git a/tests/BooleanTestCase.php b/tests/BooleanTestCase.php index caef1fa43..0b0f13060 100644 --- a/tests/BooleanTestCase.php +++ b/tests/BooleanTestCase.php @@ -1,5 +1,36 @@ . + */ + +/** + * Doctrine_Boolean_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { $this->tables = array("BooleanTest"); diff --git a/tests/CollectionTestCase.php b/tests/CollectionTestCase.php index 72c67ec5f..26a0b3896 100644 --- a/tests/CollectionTestCase.php +++ b/tests/CollectionTestCase.php @@ -1,5 +1,36 @@ . + */ + +/** + * Doctrine_Collection_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase { public function testLoadRelatedForAssociation() { $coll = $this->connection->query("FROM User"); diff --git a/tests/ConfigurableTestCase.php b/tests/ConfigurableTestCase.php index e5b2edec2..a559d1624 100644 --- a/tests/ConfigurableTestCase.php +++ b/tests/ConfigurableTestCase.php @@ -7,11 +7,11 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase { public function testGetIndexNameFormatAttribute() { // default index name format is %_idx - $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT), '%_idx'); + $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT), '%s_idx'); } public function testGetSequenceNameFormatAttribute() { // default sequence name format is %_seq - $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT), '%_seq'); + $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT), '%s_seq'); } public function testSetIndexNameFormatAttribute() { $this->manager->setAttribute(Doctrine::ATTR_IDXNAME_FORMAT, '%_index'); @@ -25,7 +25,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase { } public function testExceptionIsThrownWhenSettingIndexNameFormatAttributeAtTableLevel() { try { - $this->connection->getTable('Entity')->setAttribute(Doctrine::ATTR_IDXNAME_FORMAT, '%_idx'); + $this->connection->getTable('Entity')->setAttribute(Doctrine::ATTR_IDXNAME_FORMAT, '%s_idx'); $this->fail(); } catch(Doctrine_Exception $e) { $this->pass(); @@ -33,7 +33,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase { } public function testExceptionIsThrownWhenSettingSequenceNameFormatAttributeAtTableLevel() { try { - $this->connection->getTable('Entity')->setAttribute(Doctrine::ATTR_SEQNAME_FORMAT, '%_seq'); + $this->connection->getTable('Entity')->setAttribute(Doctrine::ATTR_SEQNAME_FORMAT, '%s_seq'); $this->fail(); } catch(Doctrine_Exception $e) { $this->pass(); @@ -86,6 +86,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase { $this->manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true); $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER), true); + $this->manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false); } public function testDefaultSequenceColumnNameAttributeValueIsId() { $this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_SEQCOL_NAME), 'id'); diff --git a/tests/Connection/SqliteTestCase.php b/tests/Connection/SqliteTestCase.php index fc93ce1c7..ce639a9f8 100644 --- a/tests/Connection/SqliteTestCase.php +++ b/tests/Connection/SqliteTestCase.php @@ -1,5 +1,5 @@ name = "Jean Reno"; - $u1->save(); +/* + * $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 + * . + */ - $id = $u1->obtainIdentifier(); - $u1->delete(); - } - +/** + * Doctrine_Connection_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { + public function testUnknownModule() { try { $this->connection->unknown; @@ -27,25 +49,25 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { } public function testFlush() { - $user = $this->connection->getTable("User")->find(4); + $user = $this->connection->getTable('User')->find(4); $this->assertTrue(is_numeric($user->Phonenumber[0]->entity_id)); - $user = $this->connection->create("Email"); - $user = $this->connection->create("User"); - $record = $this->connection->create("Phonenumber"); + $user = $this->connection->create('Email'); + $user = $this->connection->create('User'); + $record = $this->connection->create('Phonenumber'); - $user->Email->address = "example@drinkmore.info"; + $user->Email->address = 'example@drinkmore.info'; $this->assertTrue($user->email_id instanceof Email); - $user->name = "Example user"; - $user->Group[0]->name = "Example group 1"; - $user->Group[1]->name = "Example group 2"; + $user->name = 'Example user'; + $user->Group[0]->name = 'Example group 1'; + $user->Group[1]->name = 'Example group 2'; - $user->Phonenumber[0]->phonenumber = "123 123"; + $user->Phonenumber[0]->phonenumber = '123 123'; - $user->Phonenumber[1]->phonenumber = "321 2132"; - $user->Phonenumber[2]->phonenumber = "123 123"; - $user->Phonenumber[3]->phonenumber = "321 2132"; + $user->Phonenumber[1]->phonenumber = '321 2132'; + $user->Phonenumber[2]->phonenumber = '123 123'; + $user->Phonenumber[3]->phonenumber = '321 2132'; @@ -73,7 +95,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { $user = $this->objTable->find(5); - $pf = $this->connection->getTable("Phonenumber"); + $pf = $this->connection->getTable('Phonenumber'); $this->assertTrue($user->Phonenumber instanceof Doctrine_Collection); $this->assertTrue($user->Phonenumber->count() == 3); @@ -91,10 +113,10 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { // ADDING REFERENCES - $user->Phonenumber[0]->phonenumber = "123 123"; + $user->Phonenumber[0]->phonenumber = '123 123'; $this->assertTrue(is_numeric($user->Phonenumber[0]->entity_id)); - $user->Phonenumber[1]->phonenumber = "123 123"; + $user->Phonenumber[1]->phonenumber = '123 123'; $this->connection->flush(); @@ -104,7 +126,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { $user = $this->objTable->find(5); $this->assertEqual($user->Phonenumber->count(), 2); - $user->Phonenumber[3]->phonenumber = "123 123"; + $user->Phonenumber[3]->phonenumber = '123 123'; $this->connection->flush(); $this->assertEqual($user->Phonenumber->count(), 3); @@ -123,8 +145,8 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { // ADDING REFERENCES WITH STRING KEYS - $user->Phonenumber["home"]->phonenumber = "123 123"; - $user->Phonenumber["work"]->phonenumber = "444 444"; + $user->Phonenumber['home']->phonenumber = '123 123'; + $user->Phonenumber['work']->phonenumber = '444 444'; $this->assertEqual($user->Phonenumber->count(), 2); $this->connection->flush(); @@ -138,9 +160,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { unset($coll); $coll = new Doctrine_Collection($pf); - $coll[0]->phonenumber = "123 123"; - $coll["home"]->phonenumber = "444 444"; - $coll["work"]->phonenumber = "444 444"; + $coll[0]->phonenumber = '123 123'; + $coll['home']->phonenumber = '444 444'; + $coll['work']->phonenumber = '444 444'; @@ -154,28 +176,28 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { // ONE-TO-ONE REFERENCES - $user->Email->address = "drinker@drinkmore.info"; + $user->Email->address = 'drinker@drinkmore.info'; $this->assertTrue($user->Email instanceof Email); $this->connection->flush(); $this->assertTrue($user->Email instanceof Email); $user = $this->objTable->find(5); - $this->assertEqual($user->Email->address, "drinker@drinkmore.info"); + $this->assertEqual($user->Email->address, 'drinker@drinkmore.info'); $id = $user->Email->id; // REPLACING ONE-TO-ONE REFERENCES - $email = $this->connection->create("Email"); - $email->address = "absolutist@nottodrink.com"; + $email = $this->connection->create('Email'); + $email->address = 'absolutist@nottodrink.com'; $user->Email = $email; $this->assertTrue($user->Email instanceof Email); - $this->assertEqual($user->Email->address, "absolutist@nottodrink.com"); + $this->assertEqual($user->Email->address, 'absolutist@nottodrink.com'); $this->connection->flush(); unset($user); $user = $this->objTable->find(5); $this->assertTrue($user->Email instanceof Email); - $this->assertEqual($user->Email->address, "absolutist@nottodrink.com"); + $this->assertEqual($user->Email->address, 'absolutist@nottodrink.com'); $emails = $this->connection->query("FROM Email WHERE Email.id = $id"); //$this->assertEqual(count($emails),0); @@ -187,31 +209,31 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->connection->getManager(),$this->manager); } public function testQuery() { - $this->assertTrue($this->connection->query("FROM User") instanceof Doctrine_Collection); + $this->assertTrue($this->connection->query('FROM User') instanceof Doctrine_Collection); } public function testDelete() { - $user = $this->connection->create("User"); + $user = $this->connection->create('User'); $this->connection->delete($user); $this->assertEqual($user->getState(),Doctrine_Record::STATE_TCLEAN); } public function testGetTable() { - $table = $this->connection->getTable("Group"); + $table = $this->connection->getTable('Group'); $this->assertTrue($table instanceof Doctrine_Table); try { - $table = $this->connection->getTable("Unknown"); + $table = $this->connection->getTable('Unknown'); $f = false; } catch(Doctrine_Exception $e) { $f = true; } $this->assertTrue($f); - $table = $this->connection->getTable("User"); + $table = $this->connection->getTable('User'); $this->assertTrue($table instanceof UserTable); } public function testCreate() { - $email = $this->connection->create("Email"); + $email = $this->connection->create('Email'); $this->assertTrue($email instanceof Email); } public function testGetDbh() { @@ -225,7 +247,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { } public function testGetState() { $this->assertEqual($this->connection->transaction->getState(),Doctrine_Transaction::STATE_SLEEP); - $this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), "open"); + $this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), 'open'); } public function testGetTables() { $this->assertTrue(is_array($this->connection->getTables())); @@ -242,12 +264,12 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase { $user = $this->objTable->find(6); - $user->name = "Jack Daniels"; + $user->name = 'Jack Daniels'; $this->connection->flush(); $this->connection->commit(); $user = $this->objTable->find(6); - $this->assertEqual($user->name, "Jack Daniels"); + $this->assertEqual($user->name, 'Jack Daniels'); } diff --git a/tests/CustomPrimaryKeyTestCase.php b/tests/CustomPrimaryKeyTestCase.php index 0e288413f..46b7c2854 100644 --- a/tests/CustomPrimaryKeyTestCase.php +++ b/tests/CustomPrimaryKeyTestCase.php @@ -1,7 +1,36 @@ . + */ -class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase { +/** + * Doctrine_CustomPrimaryKey_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { diff --git a/tests/CustomResultSetOrderTestCase.php b/tests/CustomResultSetOrderTestCase.php index 4581851e4..67523562f 100644 --- a/tests/CustomResultSetOrderTestCase.php +++ b/tests/CustomResultSetOrderTestCase.php @@ -1,5 +1,36 @@ -. + */ + +/** + * Doctrine_CustomResultSetOrder_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase { /** * Prepares the data under test. diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index 31ac0816c..771fd7040 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -15,7 +15,7 @@ class AdapterMock implements Doctrine_Adapter_Interface { public function pop() { return array_pop($this->queries); } - public function forceException($name, $message, $code) { + public function forceException($name, $message = '', $code = 0) { $this->exception = array($name, $message, $code); } public function prepare($prepareString){ @@ -69,7 +69,7 @@ class AdapterMock implements Doctrine_Adapter_Interface { public function errorInfo(){ } public function getAttribute($attribute) { if($attribute == PDO::ATTR_DRIVER_NAME) - return $this->name; + return strtolower($this->name); } public function setAttribute($attribute, $value) { @@ -82,6 +82,9 @@ class AdapterStatementMock { public function fetchAll($fetchMode) { return array(); } + public function execute() { + return true; + } } class Doctrine_Driver_UnitTestCase extends UnitTestCase { protected $driverName = false; @@ -107,6 +110,9 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase { public function getDeclaration($type) { return $this->dataDict->getPortableDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 1, 'fixed' => true)); } + public function setDriverName($driverName) { + $this->driverName = $driverName; + } public function init() { $this->adapter = new AdapterMock($this->driverName); $this->manager = Doctrine_Manager::getInstance(); @@ -123,7 +129,10 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase { $tx = 'Doctrine_Transaction_' . ucwords($name); $dataDict = 'Doctrine_DataDict_' . ucwords($name); - + + $exc = 'Doctrine_Connection_' . ucwords($name) . '_Exception'; + + $this->exc = new $exc(); if(class_exists($tx)) $this->transaction = new $tx($this->conn); if(class_exists($dataDict)) { diff --git a/tests/EnumTestCase.php b/tests/EnumTestCase.php index cef422d8c..806e08a37 100644 --- a/tests/EnumTestCase.php +++ b/tests/EnumTestCase.php @@ -1,5 +1,36 @@ . + */ + +/** + * Doctrine_Enum_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { $this->tables = array("EnumTest"); diff --git a/tests/EventListenerChainTestCase.php b/tests/EventListenerChainTestCase.php index 99a50adb8..3553262a3 100644 --- a/tests/EventListenerChainTestCase.php +++ b/tests/EventListenerChainTestCase.php @@ -1,5 +1,35 @@ . + */ + +/** + * Doctrine_EventListener_Chain_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ class EventListenerChainTest extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn("name", "string", 100); diff --git a/tests/EventListenerTestCase.php b/tests/EventListenerTestCase.php index 9f19866ef..6576ccc34 100644 --- a/tests/EventListenerTestCase.php +++ b/tests/EventListenerTestCase.php @@ -1,5 +1,35 @@ . + */ + +/** + * Doctrine_EventListener_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ class EventListenerTest extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn("name", "string", 100); @@ -36,7 +66,7 @@ class Doctrine_EventListener_TestLogger implements Doctrine_Overloadable, Counta } } -class Doctrine_EventListenerTestCase extends Doctrine_UnitTestCase { +class Doctrine_EventListener_TestCase extends Doctrine_UnitTestCase { private $logger; diff --git a/tests/ExportReporterTestCase.php b/tests/ExportReporterTestCase.php index 2858798cc..76fd6144c 100644 --- a/tests/ExportReporterTestCase.php +++ b/tests/ExportReporterTestCase.php @@ -11,9 +11,16 @@ class Doctrine_Export_Reporter_TestCase extends Doctrine_Driver_UnitTestCase { } public function testExportChecksClassNaming() { $reporter = $this->export->export('BadLyNamed__Class'); - + + // Class name is not valid. Double underscores are not allowed + + $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 $this->assertEqual($reporter->pop(), array(E_WARNING, Doctrine::ERR_CLASS_NAME)); - } + } } diff --git a/tests/ExportTestCase.php b/tests/ExportTestCase.php index 07d76d6a2..e582a96e1 100644 --- a/tests/ExportTestCase.php +++ b/tests/ExportTestCase.php @@ -1,7 +1,5 @@ export->createTable(0, array(), array()); @@ -22,13 +20,13 @@ class Doctrine_Export_TestCase extends Doctrine_Driver_UnitTestCase { } public function testDropConstraintExecutesSql() { $this->export->dropConstraint('sometable', 'relevancy'); - + $this->assertEqual($this->adapter->pop(), 'ALTER TABLE sometable DROP CONSTRAINT relevancy_idx'); } public function testCreateIndexExecutesSql() { $this->export->createIndex('sometable', 'relevancy', array('fields' => array('title' => array(), 'content' => array()))); - $this->assertEqual($this->adapter->pop(), 'CREATE INDEX relevancy ON sometable (title, content)'); + $this->assertEqual($this->adapter->pop(), 'CREATE INDEX relevancy_idx ON sometable (title, content)'); } public function testDropIndexExecutesSql() { diff --git a/tests/ManagerTestCase.php b/tests/ManagerTestCase.php index 95dc9583a..4c14e68b1 100644 --- a/tests/ManagerTestCase.php +++ b/tests/ManagerTestCase.php @@ -1,6 +1,36 @@ . + */ + +/** + * Doctrine_Manager_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase { public function testGetInstance() { $this->assertTrue(Doctrine_Manager::getInstance() instanceOf Doctrine_Manager); } diff --git a/tests/PessimisticLockingTestCase.php b/tests/PessimisticLockingTestCase.php index 8adb81cf3..489d7a9dc 100644 --- a/tests/PessimisticLockingTestCase.php +++ b/tests/PessimisticLockingTestCase.php @@ -1,9 +1,36 @@ -. + */ -require_once("UnitTestCase.php"); - - -class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase { +/** + * Doctrine_Boolean_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_PessimisticLocking_TestCase extends Doctrine_UnitTestCase { private $lockingManager; /** diff --git a/tests/RecordStateTestCase.php b/tests/RecordStateTestCase.php deleted file mode 100644 index 70cc0e508..000000000 --- a/tests/RecordStateTestCase.php +++ /dev/null @@ -1,80 +0,0 @@ -state(123123); - $this->fail(); - } catch(Doctrine_Record_State_Exception $e) { - $this->pass(); - } - $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); - try { - $user->state('some unknown state'); - $this->fail(); - } catch(Doctrine_Record_State_Exception $e) { - $this->pass(); - } - $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); - } - - public function testAssignDirtyState() { - $user = new User(); - - $user->state(Doctrine_Record::STATE_DIRTY); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY); - - $user->state('dirty'); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY); - } - public function testAssignCleanState() { - $user = new User(); - - $user->state(Doctrine_Record::STATE_CLEAN); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); - - $user->state('clean'); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); - } - public function testAssignTransientCleanState() { - $user = new User(); - - $user->state(Doctrine_Record::STATE_TCLEAN); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); - - $user->state('tclean'); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); - } - public function testAssignTransientDirtyState() { - $user = new User(); - - $user->state(Doctrine_Record::STATE_TDIRTY); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY); - - $user->state('tdirty'); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY); - } - public function testAssignProxyState() { - $user = new User(); - - $user->state(Doctrine_Record::STATE_PROXY); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY); - - $user->state('proxy'); - - $this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY); - } -} -?> diff --git a/tests/TableTestCase.php b/tests/TableTestCase.php index 0261bdc05..32bc5ded2 100644 --- a/tests/TableTestCase.php +++ b/tests/TableTestCase.php @@ -1,6 +1,36 @@ . + */ + +/** + * Doctrine_Table_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Table_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { $this->tables[] = "FieldNameTest"; parent::prepareTables(); diff --git a/tests/TransactionFirebirdTestCase.php b/tests/TransactionFirebirdTestCase.php deleted file mode 100644 index 8840f2442..000000000 --- a/tests/TransactionFirebirdTestCase.php +++ /dev/null @@ -1,75 +0,0 @@ -transaction->beginTransaction('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); - } - public function testReleaseSavePointExecutesSql() { - $this->transaction->commit('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); - } - public function testRollbackSavePointExecutesSql() { - $this->transaction->beginTransaction('mypoint'); - $this->transaction->rollback('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); - } - public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { - try { - $this->transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationThrowsExceptionOnUnknownWaitMode() { - try { - $this->transaction->setIsolation('READ UNCOMMITTED', array('wait' => 'unknown')); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationThrowsExceptionOnUnknownReadWriteMode() { - try { - $this->transaction->setIsolation('READ UNCOMMITTED', array('rw' => 'unknown')); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - $this->transaction->setIsolation('READ COMMITTED'); - $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO RECORD_VERSION'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED RECORD_VERSION'); - } - public function testSetIsolationSupportsReadWriteOptions() { - $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ ONLY')); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ ONLY ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); - - $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ WRITE')); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ WRITE ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); - } - public function testSetIsolationSupportsWaitOptions() { - $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'NO WAIT')); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION NO WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); - - $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'WAIT')); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); - } -} diff --git a/tests/TransactionMssqlTestCase.php b/tests/TransactionMssqlTestCase.php deleted file mode 100644 index ed176325f..000000000 --- a/tests/TransactionMssqlTestCase.php +++ /dev/null @@ -1,30 +0,0 @@ -transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - $this->transaction->setIsolation('READ COMMITTED'); - $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); - } - public function testSetIsolationSupportsSnapshotMode() { - $this->transaction->setIsolation('SNAPSHOT'); - - $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'); - } -} diff --git a/tests/TransactionMysqlTestCase.php b/tests/TransactionMysqlTestCase.php deleted file mode 100644 index a607b98a7..000000000 --- a/tests/TransactionMysqlTestCase.php +++ /dev/null @@ -1,40 +0,0 @@ -transaction->beginTransaction('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); - } - public function testReleaseSavePointExecutesSql() { - $this->transaction->commit('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); - } - public function testRollbackSavePointExecutesSql() { - $this->transaction->beginTransaction('mypoint'); - $this->transaction->rollback('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); - } - public function testGetIsolationExecutesSql() { - $this->transaction->getIsolation(); - - $this->assertEqual($this->adapter->pop(), 'SELECT @@tx_isolation'); - } - public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { - try { - $this->transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - - $this->assertEqual($this->adapter->pop(), 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); - } -} diff --git a/tests/TransactionOracleTestCase.php b/tests/TransactionOracleTestCase.php deleted file mode 100644 index 7822518b7..000000000 --- a/tests/TransactionOracleTestCase.php +++ /dev/null @@ -1,39 +0,0 @@ -transaction->beginTransaction('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); - } - public function testReleaseSavePointAlwaysReturnsTrue() { - $this->assertEqual($this->transaction->commit('mypoint'), true); - } - public function testRollbackSavePointExecutesSql() { - $this->transaction->beginTransaction('mypoint'); - $this->transaction->rollback('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); - } - public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { - try { - $this->transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - $this->transaction->setIsolation('READ COMMITTED'); - $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); - - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL READ COMMITTED'); - } -} diff --git a/tests/TransactionPgsqlTestCase.php b/tests/TransactionPgsqlTestCase.php deleted file mode 100644 index 780392e5a..000000000 --- a/tests/TransactionPgsqlTestCase.php +++ /dev/null @@ -1,35 +0,0 @@ -transaction->beginTransaction('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); - } - public function testReleaseSavePointExecutesSql() { - $this->transaction->commit('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); - } - public function testRollbackSavePointExecutesSql() { - $this->transaction->beginTransaction('mypoint'); - $this->transaction->rollback('mypoint'); - - $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); - } - public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { - try { - $this->transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - - $this->assertEqual($this->adapter->pop(), 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); - } -} diff --git a/tests/TransactionSqliteTestCase.php b/tests/TransactionSqliteTestCase.php deleted file mode 100644 index c30955498..000000000 --- a/tests/TransactionSqliteTestCase.php +++ /dev/null @@ -1,25 +0,0 @@ -transaction->setIsolation('unknown'); - $this->fail(); - } catch(Doctrine_Transaction_Exception $e) { - $this->pass(); - } - } - public function testSetIsolationExecutesSql() { - $this->transaction->setIsolation('READ UNCOMMITTED'); - $this->transaction->setIsolation('READ COMMITTED'); - $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); - - $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); - $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); - $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); - $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 0'); - } -} diff --git a/tests/UnitTestCase.php b/tests/UnitTestCase.php index 98f72321b..30475f47a 100644 --- a/tests/UnitTestCase.php +++ b/tests/UnitTestCase.php @@ -1,23 +1,4 @@ driverName = 'main'; + + switch($e[1]) { + case 'Export': + case 'Import': + case 'Expression': + case 'Transaction': + case 'DataDict': + $this->driverName = 'Sqlite'; + break; + } + + if(count($e) > 3) { + $driver = $e[2]; + switch($e[2]) { + case 'Firebird': + case 'Informix': + case 'Mysql': + case 'Mssql': + case 'Oracle': + case 'Pgsql': + case 'Sqlite': + $this->driverName = $e[2]; + break; + } + } try { - $this->connection = $this->manager->getConnection('main'); + $this->connection = $this->manager->getConnection($this->driverName); $this->connection->evictTables(); - $this->dbh = $this->connection->getDBH(); + $this->dbh = $this->adapter = $this->connection->getDbh(); $this->listener = $this->manager->getAttribute(Doctrine::ATTR_LISTENER); $this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener); } catch(Doctrine_Manager_Exception $e) { - //$this->dbh = Doctrine_Db::getConnection(); - $this->dbh = Doctrine_Db::getConnection("sqlite::memory:"); - //$this->dbh = new PDO("sqlite::memory:"); + if($this->driverName == 'main') { + $this->dbh = Doctrine_Db::getConnection("sqlite::memory:"); + } else { + $this->dbh = $this->adapter = new AdapterMock($this->driverName); + } - $this->connection = $this->manager->openConnection($this->dbh, 'main'); + $this->connection = $this->manager->openConnection($this->dbh, $this->driverName); + + if($this->driverName !== 'main') { + $exc = 'Doctrine_Connection_' . ucwords($this->driverName) . '_Exception'; + + $this->exc = new $exc(); + + } else { + } $this->listener = new Doctrine_EventListener_Debugger(); $this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener); } + if($this->driverName !== 'main') { + $this->export = $this->connection->export; + $this->transaction = $this->connection->transaction; + $this->dataDict = $this->connection->dataDict; + } $this->unitOfWork = $this->connection->unitOfWork; $this->connection->setListener(new Doctrine_EventListener()); $this->query = new Doctrine_Query($this->connection); @@ -91,7 +124,7 @@ class Doctrine_UnitTestCase extends UnitTestCase { } public function prepareTables() { foreach($this->tables as $name) { - $query = "DROP TABLE ".Doctrine::tableize($name); + $query = 'DROP TABLE ' . Doctrine::tableize($name); try { $this->dbh->query($query); } catch(PDOException $e) { @@ -106,61 +139,61 @@ class Doctrine_UnitTestCase extends UnitTestCase { $table->clear(); } - $this->objTable = $this->connection->getTable("User"); + $this->objTable = $this->connection->getTable('User'); } public function prepareData() { - $groups = new Doctrine_Collection($this->connection->getTable("Group")); + $groups = new Doctrine_Collection($this->connection->getTable('Group')); - $groups[0]->name = "Drama Actors"; + $groups[0]->name = 'Drama Actors'; - $groups[1]->name = "Quality Actors"; + $groups[1]->name = 'Quality Actors'; - $groups[2]->name = "Action Actors"; - $groups[2]["Phonenumber"][0]->phonenumber = "123 123"; + $groups[2]->name = 'Action Actors'; + $groups[2]['Phonenumber'][0]->phonenumber = '123 123'; $groups->save(); - $users = new Doctrine_Collection($this->connection->getTable("User")); + $users = new Doctrine_Collection('User'); - $users[0]->name = "zYne"; - $users[0]["Email"]->address = "zYne@example.com"; - $users[0]["Phonenumber"][0]->phonenumber = "123 123"; + $users[0]->name = 'zYne'; + $users[0]['Email']->address = 'zYne@example.com'; + $users[0]['Phonenumber'][0]->phonenumber = '123 123'; - $users[1]->name = "Arnold Schwarzenegger"; - $users[1]->Email->address = "arnold@example.com"; - $users[1]["Phonenumber"][0]->phonenumber = "123 123"; - $users[1]["Phonenumber"][1]->phonenumber = "456 456"; - $users[1]->Phonenumber[2]->phonenumber = "789 789"; + $users[1]->name = 'Arnold Schwarzenegger'; + $users[1]->Email->address = 'arnold@example.com'; + $users[1]['Phonenumber'][0]->phonenumber = '123 123'; + $users[1]['Phonenumber'][1]->phonenumber = '456 456'; + $users[1]->Phonenumber[2]->phonenumber = '789 789'; $users[1]->Group[0] = $groups[2]; - $users[2]->name = "Michael Caine"; - $users[2]->Email->address = "caine@example.com"; - $users[2]->Phonenumber[0]->phonenumber = "123 123"; + $users[2]->name = 'Michael Caine'; + $users[2]->Email->address = 'caine@example.com'; + $users[2]->Phonenumber[0]->phonenumber = '123 123'; - $users[3]->name = "Takeshi Kitano"; - $users[3]->Email->address = "kitano@example.com"; - $users[3]->Phonenumber[0]->phonenumber = "111 222 333"; + $users[3]->name = 'Takeshi Kitano'; + $users[3]->Email->address = 'kitano@example.com'; + $users[3]->Phonenumber[0]->phonenumber = '111 222 333'; - $users[4]->name = "Sylvester Stallone"; - $users[4]->Email->address = "stallone@example.com"; - $users[4]->Phonenumber[0]->phonenumber = "111 555 333"; - $users[4]["Phonenumber"][1]->phonenumber = "123 213"; - $users[4]["Phonenumber"][2]->phonenumber = "444 555"; + $users[4]->name = 'Sylvester Stallone'; + $users[4]->Email->address = 'stallone@example.com'; + $users[4]->Phonenumber[0]->phonenumber = '111 555 333'; + $users[4]['Phonenumber'][1]->phonenumber = '123 213'; + $users[4]['Phonenumber'][2]->phonenumber = '444 555'; - $users[5]->name = "Kurt Russell"; - $users[5]->Email->address = "russell@example.com"; - $users[5]->Phonenumber[0]->phonenumber = "111 222 333"; + $users[5]->name = 'Kurt Russell'; + $users[5]->Email->address = 'russell@example.com'; + $users[5]->Phonenumber[0]->phonenumber = '111 222 333'; - $users[6]->name = "Jean Reno"; - $users[6]->Email->address = "reno@example.com"; - $users[6]->Phonenumber[0]->phonenumber = "111 222 333"; - $users[6]["Phonenumber"][1]->phonenumber = "222 123"; - $users[6]["Phonenumber"][2]->phonenumber = "123 456"; + $users[6]->name = 'Jean Reno'; + $users[6]->Email->address = 'reno@example.com'; + $users[6]->Phonenumber[0]->phonenumber = '111 222 333'; + $users[6]['Phonenumber'][1]->phonenumber = '222 123'; + $users[6]['Phonenumber'][2]->phonenumber = '123 456'; - $users[7]->name = "Edward Furlong"; - $users[7]->Email->address = "furlong@example.com"; - $users[7]->Phonenumber[0]->phonenumber = "111 567 333"; + $users[7]->name = 'Edward Furlong'; + $users[7]->Email->address = 'furlong@example.com'; + $users[7]->Phonenumber[0]->phonenumber = '111 567 333'; $this->users = $users; $this->connection->flush(); diff --git a/tests/ValidatorTestCase.php b/tests/ValidatorTestCase.php index 45efb97da..736069c58 100644 --- a/tests/ValidatorTestCase.php +++ b/tests/ValidatorTestCase.php @@ -1,10 +1,39 @@ . + */ + /** + * Doctrine_Validator_TestCase * TestCase for Doctrine's validation component. * * @todo More tests to cover the full interface of Doctrine_Validator_ErrorStack. + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ */ -class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase { +class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { $this->tables[] = "ValidatorTest"; parent::prepareTables(); diff --git a/tests/ViewTestCase.php b/tests/ViewTestCase.php index ecfd9642a..80132387e 100644 --- a/tests/ViewTestCase.php +++ b/tests/ViewTestCase.php @@ -1,5 +1,36 @@ . + */ + +/** + * Doctrine_View_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_View_TestCase extends Doctrine_UnitTestCase { public function testCreateView() { $query = new Doctrine_Query($this->connection); $query->from('User'); diff --git a/tests/run.php b/tests/run.php index 6f6bd8210..83628bbfc 100644 --- a/tests/run.php +++ b/tests/run.php @@ -2,241 +2,163 @@ ob_start(); -require_once('ConfigurableTestCase.php'); +function autoload($class) { + if(strpos($class, 'TestCase') === false) + return false; + + $e = explode('_', $class); + $count = count($e); + + array_shift($e); + + $dir = array_shift($e); + + $file = $dir . '_' . substr(implode('_', $e), 0, -(strlen('_TestCase'))) . 'TestCase.php'; + + if($count > 3) { + $file = str_replace('_', DIRECTORY_SEPARATOR, $file); + } else { + $file = str_replace('_', '', $file); + } + + // create a test case file if it doesn't exist + + if( ! file_exists($file)) { + $contents = file_get_contents('template.tpl'); + $contents = sprintf($contents, $class, $class); + + if( ! file_exists($dir)) { + mkdir($dir, 0777); + } + + file_put_contents($file, $contents); + } + require_once($file); + + return true; +} + +require_once dirname(__FILE__) . '/../lib/Doctrine.php'; + +spl_autoload_register(array('Doctrine', 'autoload')); +spl_autoload_register('autoload'); + +require_once('classes.php'); +require_once('simpletest/unit_tester.php'); +require_once('simpletest/reporter.php'); +require_once('UnitTestCase.php'); require_once('DriverTestCase.php'); -require_once('ManagerTestCase.php'); -require_once('ConnectionTestCase.php'); -require_once('ConnectionTransactionTestCase.php'); -require_once('TableTestCase.php'); -require_once('EventListenerTestCase.php'); -require_once('BatchIteratorTestCase.php'); -require_once('CacheFileTestCase.php'); - -require_once('RecordTestCase.php'); -require_once('RecordStateTestCase.php'); -require_once('RecordFilterTestCase.php'); - -require_once('AccessTestCase.php'); -require_once('ValidatorTestCase.php'); -require_once('CollectionTestCase.php'); -require_once('PessimisticLockingTestCase.php'); -require_once('EventListenerChainTestCase.php'); -require_once('CacheSqliteTestCase.php'); -require_once('CollectionOffsetTestCase.php'); - -require_once('CacheQuerySqliteTestCase.php'); -require_once('ViewTestCase.php'); -require_once('RawSqlTestCase.php'); -require_once('CustomPrimaryKeyTestCase.php'); -require_once('FilterTestCase.php'); -require_once('HookTestCase.php'); - -require_once('QueryTestCase.php'); -require_once('QueryLimitTestCase.php'); -require_once('QueryMultiJoinTestCase.php'); -require_once('QueryReferenceModelTestCase.php'); -require_once('QueryWhereTestCase.php'); -require_once('QueryFromTestCase.php'); -require_once('QueryConditionTestCase.php'); -require_once('QueryComponentAliasTestCase.php'); -require_once('QuerySubqueryTestCase.php'); -require_once('QuerySelectTestCase.php'); -require_once('QueryShortAliasesTestCase.php'); -require_once('QueryDeleteTestCase.php'); -require_once('QueryUpdateTestCase.php'); -require_once('QueryIdentifierQuotingTestCase.php'); -require_once('QueryAggregateValueTestCase.php'); - -require_once('UnitOfWorkTestCase.php'); - -require_once('RelationAccessTestCase.php'); -require_once('RelationTestCase.php'); -require_once('RelationManyToManyTestCase.php'); - - -require_once('DBTestCase.php'); -require_once('DbProfilerTestCase.php'); - -require_once('SchemaTestCase.php'); -require_once('ImportTestCase.php'); -require_once('BooleanTestCase.php'); -require_once('EnumTestCase.php'); - -require_once('DataDictSqliteTestCase.php'); - - -$drivers = array('Firebird', - 'Informix', - 'Mysql', - 'Mssql', - 'Oracle', - 'Pgsql', - 'Sqlite' - ); - -foreach($drivers as $driver) { - require_once('DataDict/' . $driver . 'TestCase.php'); -} -/** -class Doctrine_Tester { - protected $drivers = array('Firebird', - 'Informix', - 'Mysql', - 'Mssql', - 'Oracle', - 'Pgsql', - 'Sqlite' - ); - - public function loadModule($module) { - foreach($drivers as $driver) { - require_once($module . DIRECTORY_SEPARATOR . $driver . 'TestCase.php'); - } - } - public function run($module) { - $this->loadModule($module); - - foreach($drivers as $driver) { - - } - } -} -*/ -require_once('ExportTestCase.php'); -require_once('ExportReporterTestCase.php'); -require_once('ExportMysqlTestCase.php'); -require_once('ExportFirebirdTestCase.php'); -require_once('ExportPgsqlTestCase.php'); -require_once('ExportOracleTestCase.php'); -require_once('ExportSqliteTestCase.php'); - -require_once('TransactionTestCase.php'); -require_once('TransactionMysqlTestCase.php'); -require_once('TransactionPgsqlTestCase.php'); -require_once('TransactionOracleTestCase.php'); -require_once('TransactionFirebirdTestCase.php'); -require_once('TransactionMssqlTestCase.php'); -require_once('TransactionSqliteTestCase.php'); - -require_once('Connection/MysqlTestCase.php'); - -require_once('CustomResultSetOrderTestCase.php'); error_reporting(E_ALL); print '
';
 
 $test = new GroupTest('Doctrine Framework Unit Tests');
 
- /**
-$test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
-
-foreach($drivers as $driver) {
-    $class = 'Doctrine_DataDict_' . $driver . '_TestCase';
-
-    $test->addTestCase(new $class());
-}
 
 
+// DATABASE ABSTRACTION tests
 
+$test->addTestCase(new Doctrine_Connection_Firebird_TestCase());
+$test->addTestCase(new Doctrine_Connection_Informix_TestCase());
 $test->addTestCase(new Doctrine_Connection_Mysql_TestCase());
+$test->addTestCase(new Doctrine_Connection_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
+$test->addTestCase(new Doctrine_Connection_Sqlite_TestCase());
 
-$test->addTestCase(new Doctrine_Export_Mysql_TestCase());
-
-$test->addTestCase(new Doctrine_Export_Oracle_TestCase());
-
-$test->addTestCase(new Doctrine_Export_Pgsql_TestCase());
-
-$test->addTestCase(new Doctrine_Export_Firebird_TestCase());
-
-
-$test->addTestCase(new Doctrine_Configurable_TestCase());
-
-
-
-$test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
-
-           */
-
+$test->addTestCase(new Doctrine_Export_TestCase());
 $test->addTestCase(new Doctrine_Export_Reporter_TestCase());
+$test->addTestCase(new Doctrine_Export_Firebird_TestCase());
+$test->addTestCase(new Doctrine_Export_Informix_TestCase());
+$test->addTestCase(new Doctrine_Export_Mysql_TestCase());
+$test->addTestCase(new Doctrine_Export_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Export_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Export_Oracle_TestCase());
+$test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
 
 $test->addTestCase(new Doctrine_Transaction_TestCase());
-
-$test->addTestCase(new Doctrine_Transaction_Mysql_TestCase());
-
-$test->addTestCase(new Doctrine_Transaction_Pgsql_TestCase());
-
-$test->addTestCase(new Doctrine_Transaction_Oracle_TestCase());
-
 $test->addTestCase(new Doctrine_Transaction_Firebird_TestCase());
-
+$test->addTestCase(new Doctrine_Transaction_Informix_TestCase());
+$test->addTestCase(new Doctrine_Transaction_Mysql_TestCase());
+$test->addTestCase(new Doctrine_Transaction_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Transaction_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Transaction_Oracle_TestCase());
 $test->addTestCase(new Doctrine_Transaction_Sqlite_TestCase());
 
-$test->addTestCase(new Doctrine_Transaction_Mssql_TestCase());
+//$test->addTestCase(new Doctrine_Import_TestCase());
+$test->addTestCase(new Doctrine_Import_Firebird_TestCase());
+$test->addTestCase(new Doctrine_Import_Informix_TestCase());
+$test->addTestCase(new Doctrine_Import_Mysql_TestCase());
+$test->addTestCase(new Doctrine_Import_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Import_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Import_Oracle_TestCase());
+$test->addTestCase(new Doctrine_Import_Sqlite_TestCase());
 
-$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
+$test->addTestCase(new Doctrine_Expression_TestCase());
+$test->addTestCase(new Doctrine_Expression_Firebird_TestCase());
+$test->addTestCase(new Doctrine_Expression_Informix_TestCase());
+$test->addTestCase(new Doctrine_Expression_Mysql_TestCase());
+$test->addTestCase(new Doctrine_Expression_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Expression_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Expression_Oracle_TestCase());
+$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
 
-$test->addTestCase(new Doctrine_PessimisticLockingTestCase());
 
-$test->addTestCase(new Doctrine_BooleanTestCase());
+// Core
 
-$test->addTestCase(new Doctrine_TableTestCase());
-
-$test->addTestCase(new Doctrine_ValidatorTestCase());
+$test->addTestCase(new Doctrine_Access_TestCase());
+//$test->addTestCase(new Doctrine_Configurable_TestCase());
+$test->addTestCase(new Doctrine_Manager_TestCase());
+$test->addTestCase(new Doctrine_Connection_TestCase());
+$test->addTestCase(new Doctrine_Table_TestCase());
 
 $test->addTestCase(new Doctrine_UnitOfWork_TestCase());
+$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
+$test->addTestCase(new Doctrine_Collection_TestCase());
 
-$test->addTestCase(new Doctrine_ConnectionTestCase());
 
+// Relation handling
+$test->addTestCase(new Doctrine_Relation_TestCase());
+$test->addTestCase(new Doctrine_Relation_Access_TestCase());
+$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
+
+
+// Datatypes
+$test->addTestCase(new Doctrine_Enum_TestCase());
+$test->addTestCase(new Doctrine_Boolean_TestCase());
+
+
+// Utility components
+$test->addTestCase(new Doctrine_Hook_TestCase());
+$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
+$test->addTestCase(new Doctrine_Validator_TestCase());
+$test->addTestCase(new Doctrine_RawSql_TestCase());
+$test->addTestCase(new Doctrine_View_TestCase());
+
+
+// Db component
 $test->addTestCase(new Doctrine_Db_TestCase());
-
 $test->addTestCase(new Doctrine_Db_Profiler_TestCase());
 
 
+// Record
 $test->addTestCase(new Doctrine_Record_TestCase());
-
-$test->addTestCase(new Doctrine_Relation_TestCase());
-
 $test->addTestCase(new Doctrine_Record_State_TestCase());
-
-//$test->addTestCase(new Doctrine_Import_TestCase());
-
-$test->addTestCase(new Doctrine_SchemaTestCase());
-
-$test->addTestCase(new Doctrine_EventListenerTestCase());
-
-$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
-
-$test->addTestCase(new Doctrine_AccessTestCase());
-
-$test->addTestCase(new Doctrine_ManagerTestCase());
-
-$test->addTestCase(new Doctrine_BatchIteratorTestCase());
-
-//$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
-
-$test->addTestCase(new Doctrine_ViewTestCase());
-
-$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase());
-
-$test->addTestCase(new Doctrine_Filter_TestCase());
-
-$test->addTestCase(new Doctrine_RawSql_TestCase());
-
-$test->addTestCase(new Doctrine_CollectionTestCase());
-
-
-$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
-
-$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
-
-$test->addTestCase(new Doctrine_RelationAccessTestCase());
-
-$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
-
 //$test->addTestCase(new Doctrine_Record_Filter_TestCase());
 
-$test->addTestCase(new Doctrine_EnumTestCase());
+// Eventlisteners
+$test->addTestCase(new Doctrine_EventListener_TestCase());
+$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
 
+// Old test cases (should be removed)
+$test->addTestCase(new Doctrine_SchemaTestCase());
+$test->addTestCase(new Doctrine_BatchIterator_TestCase());
+$test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
+$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
+$test->addTestCase(new Doctrine_Filter_TestCase());
+//$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
+
+// Query tests
 $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
 $test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
 $test->addTestCase(new Doctrine_Query_Condition_TestCase());
@@ -253,8 +175,10 @@ $test->addTestCase(new Doctrine_Query_Update_TestCase());
 $test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
 $test->addTestCase(new Doctrine_Query_Select_TestCase());
 
-$test->addTestCase(new Doctrine_Hook_TestCase());
 
+
+
+// Cache tests
 //$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
 //$test->addTestCase(new Doctrine_Cache_FileTestCase());
 //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());