1
0
mirror of synced 2024-12-13 22:56:04 +03:00

[2.0] Fix for test suite. It was trying to recreate association tables and they're not getting deleted. SchemaTool was trying to recreate them during some executions.

This commit is contained in:
guilhermeblanco 2009-10-19 23:23:54 +00:00
parent 2a16782528
commit 7ae913a5b5
3 changed files with 39 additions and 27 deletions

View File

@ -629,7 +629,7 @@ class Connection
} else {
$result = $this->_conn->exec($query);
}
$this->_queryCount++;
return $result;

View File

@ -762,8 +762,7 @@ abstract class AbstractPlatform
public function getDecimalTypeDeclarationSql(array $columnDef)
{
$columnDef['precision'] = ( ! isset($columnDef['precision']) || empty($columnDef['precision']))
? (( ! isset($columnDef['length']) || empty($columnDef['length'])) ? 10 : $columnDef['length'])
: $columnDef['precision'];
? 10 : $columnDef['precision'];
$columnDef['scale'] = ( ! isset($columnDef['scale']) || empty($columnDef['scale']))
? 0 : $columnDef['scale'];

View File

@ -72,40 +72,45 @@ class OrmFunctionalTestCase extends OrmTestCase
protected function tearDown()
{
$conn = $this->sharedFixture['conn'];
if (isset($this->_usedModelSets['cms'])) {
$conn->executeUpdate('DELETE FROM cms_users_groups');
$conn->executeUpdate('DELETE FROM cms_groups');
$conn->executeUpdate('DELETE FROM cms_addresses');
$conn->executeUpdate('DELETE FROM cms_phonenumbers');
$conn->executeUpdate('DELETE FROM cms_articles');
$conn->executeUpdate('DELETE FROM cms_users');
$conn->executeUpdate('DROP TABLE cms_users_groups');
$conn->executeUpdate('DROP TABLE cms_groups');
$conn->executeUpdate('DROP TABLE cms_addresses');
$conn->executeUpdate('DROP TABLE cms_phonenumbers');
$conn->executeUpdate('DROP TABLE cms_articles');
$conn->executeUpdate('DROP TABLE cms_users');
}
if (isset($this->_usedModelSets['ecommerce'])) {
$conn->executeUpdate('DELETE FROM ecommerce_carts_products');
$conn->executeUpdate('DELETE FROM ecommerce_products_categories');
$conn->executeUpdate('DELETE FROM ecommerce_products_related');
$conn->executeUpdate('DELETE FROM ecommerce_carts');
$conn->executeUpdate('DELETE FROM ecommerce_customers');
$conn->executeUpdate('DELETE FROM ecommerce_features');
$conn->executeUpdate('DELETE FROM ecommerce_products');
$conn->executeUpdate('DELETE FROM ecommerce_shippings');
$conn->executeUpdate('DROP TABLE ecommerce_carts_products');
$conn->executeUpdate('DROP TABLE ecommerce_products_categories');
$conn->executeUpdate('DROP TABLE ecommerce_products_related');
$conn->executeUpdate('DROP TABLE ecommerce_carts');
$conn->executeUpdate('DROP TABLE ecommerce_customers');
$conn->executeUpdate('DROP TABLE ecommerce_features');
$conn->executeUpdate('DROP TABLE ecommerce_products');
$conn->executeUpdate('DROP TABLE ecommerce_shippings');
$conn->executeUpdate('UPDATE ecommerce_categories SET parent_id = NULL');
$conn->executeUpdate('DELETE FROM ecommerce_categories');
$conn->executeUpdate('DROP TABLE ecommerce_categories');
}
if (isset($this->_usedModelSets['company'])) {
$conn->executeUpdate('DELETE FROM company_persons_friends');
$conn->executeUpdate('DELETE FROM company_managers');
$conn->executeUpdate('DELETE FROM company_employees');
$conn->executeUpdate('DROP TABLE company_persons_friends');
$conn->executeUpdate('DROP TABLE company_managers');
$conn->executeUpdate('DROP TABLE company_employees');
$conn->executeUpdate('UPDATE company_persons SET spouse_id = NULL');
$conn->executeUpdate('DELETE FROM company_persons');
$conn->executeUpdate('DELETE FROM company_raffles');
$conn->executeUpdate('DELETE FROM company_auctions');
$conn->executeUpdate('DELETE FROM company_events');
$conn->executeUpdate('DELETE FROM company_organizations');
$conn->executeUpdate('DROP TABLE company_persons');
$conn->executeUpdate('DROP TABLE company_raffles');
$conn->executeUpdate('DROP TABLE company_auctions');
$conn->executeUpdate('DROP TABLE company_events');
$conn->executeUpdate('DROP TABLE company_organizations');
}
if (isset($this->_usedModelSets['generic'])) {
$conn->executeUpdate('DELETE FROM date_time_model');
$conn->executeUpdate('DROP TABLE date_time_model');
}
$this->_em->clear();
}
@ -121,25 +126,31 @@ class OrmFunctionalTestCase extends OrmTestCase
if ( ! isset(self::$_sharedConn)) {
self::$_sharedConn = TestUtil::getConnection();
}
$this->sharedFixture['conn'] = self::$_sharedConn;
if ($this->sharedFixture['conn']->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
$forceCreateTables = true;
}
}
if ( ! $this->_em) {
$this->_em = $this->_getEntityManager();
$this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em);
}
$classes = array();
foreach ($this->_usedModelSets as $setName => $bool) {
if ( ! isset(self::$_tablesCreated[$setName])/* || $forceCreateTables*/) {
foreach (self::$_modelSets[$setName] as $className) {
$classes[] = $this->_em->getClassMetadata($className);
}
self::$_tablesCreated[$setName] = true;
}
}
if ($classes) {
$this->_schemaTool->createSchema($classes);
}
@ -159,9 +170,11 @@ class OrmFunctionalTestCase extends OrmTestCase
if (is_null(self::$_metadataCacheImpl)) {
self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
}
if (is_null(self::$_queryCacheImpl)) {
self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
}
//FIXME: two different configs! $conn and the created entity manager have
// different configs.
$config = new \Doctrine\ORM\Configuration();