Changeset 3701 for trunk/tests/DoctrineTest
- Timestamp:
- 02/03/08 21:29:57 (11 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/DoctrineTest/Doctrine_UnitTestCase.php
r3460 r3701 66 66 $this->_name = get_class($this); 67 67 68 $this->manager = Doctrine_Manager::getInstance();68 $this->manager = Doctrine_Manager::getInstance(); 69 69 $this->manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL); 70 70 71 71 $this->tables = array_merge($this->tables, 72 array('entity', 73 'entityReference', 74 'email', 75 'phonenumber', 76 'groupuser', 77 'album', 78 'song', 79 'element', 80 'error', 81 'description', 82 'address', 83 'account', 84 'task', 85 'resource', 86 'assignment', 87 'resourceType', 88 'resourceReference') 72 array('Entity', 73 'EntityReference', 74 'Email', 75 'Phonenumber', 76 'Groupuser', 77 'Album', 78 'Book', 79 'Song', 80 'Element', 81 'Error', 82 'Description', 83 'Address', 84 'Account', 85 'Task', 86 'Resource', 87 'Assignment', 88 'ResourceType', 89 'ResourceReference') 89 90 ); 90 91 91 92 92 93 $class = get_class($this); 93 $e = explode('_', $class);94 $e = explode('_', $class); 94 95 95 96 … … 135 136 $this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener); 136 137 137 } catch (Doctrine_Manager_Exception $e) {138 } catch (Doctrine_Manager_Exception $e) { 138 139 if($this->driverName == 'main') { 139 140 $this->dbh = new PDO('sqlite::memory:'); … … 145 146 $this->conn = $this->connection = $this->manager->openConnection($this->dbh, $this->driverName); 146 147 147 if ($this->driverName !== 'main') {148 if ($this->driverName !== 'main') { 148 149 $exc = 'Doctrine_Connection_' . ucwords($this->driverName) . '_Exception'; 149 150 … … 156 157 $this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener); 157 158 } 159 158 160 if ($this->driverName !== 'main') { 159 160 161 if (isset($module)) { 161 162 switch($module) { … … 175 176 } 176 177 } 178 177 179 $this->unitOfWork = $this->connection->unitOfWork; 178 180 $this->connection->setListener(new Doctrine_EventListener()); 179 181 $this->query = new Doctrine_Query($this->connection); 180 182 181 183 if ($this->driverName === 'main') { 182 184 $this->prepareTables(); … … 184 186 } 185 187 } 188 186 189 public function prepareTables() { 187 foreach($this->tables as $name) { 188 $name = ucwords($name); 189 $table = $this->connection->getTable($name); 190 foreach ($this->tables as $name) { 191 $table = $this->connection->getMetadata($name); 190 192 $query = 'DROP TABLE ' . $table->getTableName(); 191 193 try { 192 194 $this->conn->exec($query); 193 } catch (Doctrine_Connection_Exception $e) {194 195 }196 }195 } catch (Doctrine_Connection_Exception $e) {} 196 } 197 //echo "exporting : " . var_dump($this->tables); 198 //echo "<br /><br />"; 197 199 $this->conn->export->exportClasses($this->tables); 198 200 $this->objTable = $this->connection->getMapper('User'); 199 201 } 202 200 203 public function prepareData() 201 204 { … … 256 259 $this->users->save(); 257 260 } 261 258 262 public function getConnection() 259 263 { 260 264 return $this->connection; 261 265 } 266 262 267 public function assertDeclarationType($type, $type2) 263 268 { … … 270 275 $this->assertEqual($dec['type'], $type2); 271 276 } 277 272 278 public function getDeclaration($type) 273 279 { 274 280 return $this->dataDict->getPortableDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 1, 'fixed' => true)); 275 281 } 282 276 283 public function clearCache() 277 284 { … … 281 288 } 282 289 } 290 283 291 public function setUp() 284 292 { … … 286 294 $this->init(); 287 295 } 296 288 297 if (isset($this->objTable)) { 289 298 $this->objTable->clear();