Changeset 3791
- Timestamp:
- 02/15/08 17:45:10 (17 months ago)
- Location:
- branches/0.10
- Files:
-
- 1 removed
- 16 modified
-
lib/Doctrine.php (modified) (2 diffs)
-
lib/Doctrine/Configurable.php (modified) (1 diff)
-
lib/Doctrine/Connection.php (modified) (4 diffs)
-
lib/Doctrine/Connection/Sqlite.php (modified) (1 diff)
-
lib/Doctrine/Connection/UnitOfWork.php (modified) (1 diff)
-
lib/Doctrine/Export.php (modified) (1 diff)
-
lib/Doctrine/Export/Sqlite.php (modified) (1 diff)
-
lib/Doctrine/Manager.php (modified) (13 diffs)
-
lib/Doctrine/Query.php (modified) (1 diff)
-
lib/Doctrine/Query/Tokenizer.php (modified) (1 diff)
-
lib/Doctrine/Task/CreateDb.php (modified) (1 diff)
-
lib/Doctrine/Task/DropDb.php (modified) (1 diff)
-
tests/Export/SqliteTestCase.php (modified) (1 diff)
-
tests/ManagerTestCase.php (modified) (1 diff)
-
tests/TreeStructureTestCase.php (modified) (1 diff)
-
tools/sandbox/config.php.dist (modified) (2 diffs)
-
tools/sandbox/sandbox.db (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine.php
r3672 r3791 809 809 public static function createDatabases($specifiedConnections = array()) 810 810 { 811 if ( ! is_array($specifiedConnections)) { 812 $specifiedConnections = (array) $specifiedConnections; 813 } 814 815 $manager = Doctrine_Manager::getInstance(); 816 $connections = $manager->getConnections(); 817 818 $results = array(); 819 820 foreach ($connections as $name => $connection) { 821 if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 822 continue; 823 } 824 825 $info = $manager->parsePdoDsn($connection->getOption('dsn')); 826 $username = $connection->getOption('username'); 827 $password = $connection->getOption('password'); 828 829 // Make connection without database specified so we can create it 830 $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); 831 832 try { 833 // Create database 834 $connect->export->createDatabase($name); 835 836 // Close the tmp connection with no database 837 $manager->closeConnection($connect); 838 839 // Close original connection 840 $manager->closeConnection($connection); 841 842 // Reopen original connection with newly created database 843 $manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); 844 845 $results[$name] = true; 846 } catch (Exception $e) { 847 $results[$name] = false; 848 } 849 } 850 851 return $results; 811 return Doctrine_Manager::getInstance()->createDatabases($specifiedConnections); 852 812 } 853 813 … … 862 822 public static function dropDatabases($specifiedConnections = array()) 863 823 { 864 if ( ! is_array($specifiedConnections)) { 865 $specifiedConnections = (array) $specifiedConnections; 866 } 867 868 $manager = Doctrine_Manager::getInstance(); 869 870 $connections = $manager->getConnections(); 871 872 $results = array(); 873 874 foreach ($connections as $name => $connection) { 875 if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 876 continue; 877 } 878 879 try { 880 $connection->export->dropDatabase($name); 881 882 $results[$name] = true; 883 } catch (Exception $e) { 884 $results[$name] = false; 885 } 886 } 887 888 return $results; 824 return Doctrine_Manager::getInstance()->dropDatabases($specifiedConnections); 889 825 } 890 826 -
branches/0.10/lib/Doctrine/Configurable.php
r3678 r3791 381 381 public function getAttribute($attribute) 382 382 { 383 if (is_string($attribute)) { 384 $upper = strtoupper($attribute); 385 386 $const = 'Doctrine::ATTR_' . $upper; 387 388 if (defined($const)) { 389 $attribute = constant($const); 390 $this->_state = $attribute; 391 } else { 392 throw new Doctrine_Exception('Unknown attribute: "' . $attribute . '"'); 393 } 394 } 395 383 396 $attribute = (int) $attribute; 384 397 -
branches/0.10/lib/Doctrine/Connection.php
r3416 r3791 68 68 69 69 /** 70 * @var string $driverName the name of this connection driver 70 * $_name 71 * 72 * Name of the connection 73 * 74 * @var string $_name 75 */ 76 protected $_name; 77 78 /** 79 * The name of this connection driver. 80 * 81 * @var string $driverName 71 82 */ 72 83 protected $driverName; … … 292 303 public function getName() 293 304 { 305 return $this->_name; 306 } 307 308 /** 309 * setName 310 * 311 * Sets the name of the connection 312 * 313 * @param string $name 314 * @return void 315 */ 316 public function setName($name) 317 { 318 $this->_name = $name; 319 } 320 321 /** 322 * getDriverName 323 * 324 * Gets the name of the instance driver 325 * 326 * @return void 327 */ 328 public function getDriverName() 329 { 294 330 return $this->driverName; 295 331 } … … 326 362 break; 327 363 default: 328 $class = 'Doctrine_' . ucwords($name) . '_' . $this->get Name();364 $class = 'Doctrine_' . ucwords($name) . '_' . $this->getDriverName(); 329 365 $this->modules[$name] = new $class($this); 330 366 } … … 1318 1354 } 1319 1355 1356 public function createDatabase() 1357 { 1358 try { 1359 if ( ! $dsn = $this->getOption('dsn')) { 1360 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 1361 } 1362 1363 $manager = $this->getManager(); 1364 1365 $info = $manager->parsePdoDsn($dsn); 1366 $username = $this->getOption('username'); 1367 $password = $this->getOption('password'); 1368 1369 // Make connection without database specified so we can create it 1370 $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); 1371 1372 // Create database 1373 $connect->export->createDatabase($info['dbname']); 1374 1375 // Close the tmp connection with no database 1376 $manager->closeConnection($connect); 1377 1378 // Close original connection 1379 $manager->closeConnection($this); 1380 1381 // Reopen original connection with newly created database 1382 $manager->openConnection(new PDO($info['dsn'], $username, $password), $this->getName(), true); 1383 1384 return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 1385 } catch (Exception $e) { 1386 return $e; 1387 } 1388 } 1389 1390 /** 1391 * dropDatabase 1392 * 1393 * Method for dropping the database for the connection instance 1394 * 1395 * @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success 1396 */ 1397 public function dropDatabase() 1398 { 1399 try { 1400 if ( ! $dsn = $this->getOption('dsn')) { 1401 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 1402 } 1403 1404 $info = $this->getManager()->parsePdoDsn($dsn); 1405 1406 $this->export->dropDatabase($info['dbname']); 1407 1408 return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 1409 } catch (Exception $e) { 1410 return $e; 1411 } 1412 } 1413 1320 1414 /** 1321 1415 * returns a string representation of this object -
branches/0.10/lib/Doctrine/Connection/Sqlite.php
r3032 r3791 99 99 100 100 /** 101 * getDatabaseFile101 * createDatabase 102 102 * 103 * @param string $name the name of the database 104 * @return string 103 * @return void 105 104 */ 106 public function getDatabaseFile($name)105 public function createDatabase() 107 106 { 108 return $name . '.db'; 107 try { 108 if ( ! $dsn = $this->getOption('dsn')) { 109 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 110 } 111 112 $info = $this->getManager()->parseDsn($dsn); 113 114 $this->export->createDatabase($info['database']); 115 116 return 'Successfully created database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 117 } catch (Exception $e) { 118 return $e; 119 } 120 } 121 122 /** 123 * dropDatabase 124 * 125 * @return void 126 */ 127 public function dropDatabase() 128 { 129 try { 130 if ( ! $dsn = $this->getOption('dsn')) { 131 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 132 } 133 134 $info = $this->getManager()->parseDsn($dsn); 135 136 $this->export->dropDatabase($info['database']); 137 138 return 'Successfully dropped database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 139 } catch (Exception $e) { 140 return $e; 141 } 109 142 } 110 143 } -
branches/0.10/lib/Doctrine/Connection/UnitOfWork.php
r3702 r3791 702 702 $table->getIdentifierType() != Doctrine::IDENTIFIER_NATURAL) { 703 703 704 if (strtolower($this->conn->get Name()) == 'pgsql') {704 if (strtolower($this->conn->getDriverName()) == 'pgsql') { 705 705 $seq = $table->getTableName() . '_' . $identifier[0]; 706 706 } -
branches/0.10/lib/Doctrine/Export.php
r3770 r3791 1059 1059 * @return void 1060 1060 */ 1061 public function exportClasses(array $classes) 1062 { 1063 $connections = array(); 1064 foreach ($classes as $class) { 1065 $record = new $class(); 1066 $connection = $record->getTable()->getConnection(); 1067 $connectionName = Doctrine_Manager::getInstance()->getConnectionName($connection); 1068 1069 if ( ! isset($connections[$connectionName])) { 1070 $connections[$connectionName] = array(); 1071 $connections[$connectionName]['creates'] = array(); 1072 $connections[$connectionName]['alters'] = array(); 1073 } 1074 1075 $sql = $this->exportClassesSql(array($class)); 1076 // Build array of all the creates 1077 // We need these to happen first 1078 foreach ($sql as $key => $query) { 1079 if (strstr($query, 'CREATE')) { 1080 $connections[$connectionName]['creates'][] = $query; 1081 // Unset the create from sql so we can have an array of everything else but creates 1082 unset($sql[$key]); 1083 } 1084 } 1085 1086 $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql); 1087 } 1088 1089 // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom 1090 $build = array(); 1091 foreach ($connections as $connectionName => $sql) { 1092 $build[$connectionName] = array_merge($sql['creates'], $sql['alters']); 1093 } 1094 1095 foreach ($build as $connectionName => $sql) { 1096 $connection = Doctrine_Manager::getInstance()->getConnection($connectionName); 1097 1098 $connection->beginTransaction(); 1099 1100 foreach ($sql as $query) { 1101 try { 1102 $connection->exec($query); 1103 } catch (Doctrine_Connection_Exception $e) { 1104 // we only want to silence table already exists errors 1105 if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { 1106 $connection->rollback(); 1107 throw new Doctrine_Export_Exception($e->getMessage() . '. Failing Query: ' . $query); 1108 } 1109 } 1110 } 1111 1112 $connection->commit(); 1113 } 1114 } 1061 public function exportClasses(array $classes) 1062 { 1063 $connections = array(); 1064 foreach ($classes as $class) { 1065 $record = new $class(); 1066 $connection = $record->getTable()->getConnection(); 1067 $connectionName = Doctrine_Manager::getInstance()->getConnectionName($connection); 1068 1069 if ( ! isset($connections[$connectionName])) { 1070 $connections[$connectionName] = array( 1071 'create_tables' => array(), 1072 'create_sequences' => array(), 1073 'alters' => array() 1074 ); 1075 } 1076 1077 $sql = $this->exportClassesSql(array($class)); 1078 1079 // Build array of all the creates 1080 // We need these to happen first 1081 foreach ($sql as $key => $query) { 1082 if (strstr($query, 'CREATE TABLE')) { 1083 $connections[$connectionName]['create_tables'][] = $query; 1084 1085 unset($sql[$key]); 1086 } 1087 1088 if (strstr($query, 'CREATE SEQUENCE')) { 1089 $connections[$connectionName]['create_sequences'][] = $query; 1090 1091 unset($sql[$key]); 1092 } 1093 } 1094 1095 $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql); 1096 } 1097 1098 // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom 1099 $build = array(); 1100 foreach ($connections as $connectionName => $sql) { 1101 $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql['alters']); 1102 } 1103 1104 foreach ($build as $connectionName => $sql) { 1105 $connection = Doctrine_Manager::getInstance()->getConnection($connectionName); 1106 1107 $connection->beginTransaction(); 1108 1109 foreach ($sql as $query) { 1110 try { 1111 $connection->exec($query); 1112 } catch (Doctrine_Connection_Exception $e) { 1113 // we only want to silence table already exists errors 1114 if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { 1115 $connection->rollback(); 1116 throw new Doctrine_Export_Exception($e->getMessage() . '. Failing Query: ' . $query); 1117 } 1118 } 1119 } 1120 1121 $connection->commit(); 1122 } 1123 } 1115 1124 1116 1125 /** -
branches/0.10/lib/Doctrine/Export/Sqlite.php
r3048 r3791 35 35 { 36 36 /** 37 * dropDatabase 38 * 37 39 * drop an existing database 38 40 * 39 * @param string $ name nameof the database that should be dropped41 * @param string $databaseFile Path of the database that should be dropped 40 42 * @throws Doctrine_Export_Exception if the database file does not exist 41 43 * @throws Doctrine_Export_Exception if something failed during the removal of the database file 42 44 * @return void 43 45 */ 44 public function dropDatabase($name) 45 { 46 $databaseFile = $this->conn->getDatabaseFile($name); 46 public function dropDatabase($databaseFile) 47 { 47 48 if ( ! @file_exists($databaseFile)) { 48 49 throw new Doctrine_Export_Exception('database does not exist'); 49 50 } 51 50 52 $result = @unlink($databaseFile); 53 51 54 if ( ! $result) { 52 55 throw new Doctrine_Export_Exception('could not remove the database file'); 53 56 } 57 } 58 59 /** 60 * createDatabase 61 * 62 * Create sqlite database file 63 * 64 * @param string $databaseFile Path of the database that should be dropped 65 * @return void 66 */ 67 public function createDatabase($databaseFile) 68 { 69 return new PDO('sqlite:' . $databaseFile); 54 70 } 55 71 -
branches/0.10/lib/Doctrine/Manager.php
r3381 r3791 257 257 258 258 $driverName = $adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME); 259 } else if (is_array($adapter)) {259 } else if (is_array($adapter)) { 260 260 if ( ! isset($adapter[0])) { 261 261 throw new Doctrine_Manager_Exception('Empty data source name given.'); … … 271 271 $parts['user'] = (isset($adapter[1])) ? $adapter[1] : null; 272 272 $parts['pass'] = (isset($adapter[2])) ? $adapter[2] : null; 273 273 274 274 $driverName = $e[0]; 275 275 $adapter = $parts; 276 276 } else { 277 277 $parts = $this->parseDsn($adapter); 278 279 278 $driverName = $parts['scheme']; 280 281 279 $adapter = $parts; 282 280 } … … 297 295 $this->_index++; 298 296 } 299 300 297 301 298 $drivers = array('mysql' => 'Doctrine_Connection_Mysql', … … 310 307 'informix' => 'Doctrine_Connection_Informix', 311 308 'mock' => 'Doctrine_Connection_Mock'); 309 312 310 if ( ! isset($drivers[$driverName])) { 313 311 throw new Doctrine_Manager_Exception('Unknown driver ' . $driverName); 314 312 } 315 313 316 314 $className = $drivers[$driverName]; 317 315 $conn = new $className($this, $adapter); 316 $conn->setName($name); 318 317 319 318 $this->_connections[$name] = $conn; … … 326 325 327 326 /** 328 * parsePdoDsn 329 * 330 * @param array $dsn An array of dsn information 327 * parsePdoDsn 328 * 329 * @param array $dsn An array of dsn information 331 330 * @return array The array parsed 331 * @todo package:dbal 332 332 */ 333 333 public function parsePdoDsn($dsn) 334 334 { 335 335 $parts = array(); 336 336 337 337 $names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'); 338 338 … … 342 342 } 343 343 } 344 344 345 345 $e = explode(':', $dsn); 346 346 $parts['scheme'] = $e[0]; 347 347 $parts['dsn'] = $dsn; 348 348 349 349 $e = explode(';', $e[1]); 350 350 foreach ($e as $string) { 351 list($key, $value) = explode('=', $string); 352 $parts[$key] = $value; 353 } 354 351 if ($string) { 352 $e2 = explode('=', $string); 353 354 if (isset($e2[0]) && isset($e2[1])) { 355 list($key, $value) = $e2; 356 $parts[$key] = $value; 357 } 358 } 359 } 360 355 361 return $parts; 356 362 } … … 361 367 * @param string $dsn 362 368 * @return array Parsed contents of DSN 369 * @todo package:dbal 363 370 */ 364 371 public function parseDsn($dsn) 365 372 { 366 367 368 //fix linux sqlite dsn so that it will parse correctly 369 $dsn = str_replace("///", "/", $dsn); 373 // fix sqlite dsn so that it will parse correctly 374 $dsn = str_replace("////", "/", $dsn); 375 $dsn = str_replace("///c:/", "//c:/", $dsn); 370 376 371 377 // silence any warnings … … 402 408 403 409 break; 404 410 405 411 case 'mssql': 406 412 case 'dblib': … … 414 420 throw new Doctrine_Manager_Exception('No hostname set in data source name'); 415 421 } 416 422 417 423 if (isset(self::$driverMap[$parts['scheme']])) { 418 424 $parts['scheme'] = self::$driverMap[$parts['scheme']]; … … 422 428 . $parts['host'] . (isset($parts['port']) ? ':' . $parts['port']:null) . ';dbname=' 423 429 . $parts['database']; 424 430 425 431 break; 426 432 … … 443 449 throw new Doctrine_Manager_Exception('No hostname set in data source name'); 444 450 } 445 451 446 452 if (isset(self::$driverMap[$parts['scheme']])) { 447 453 $parts['scheme'] = self::$driverMap[$parts['scheme']]; … … 451 457 . $parts['host'] . (isset($parts['port']) ? ';port=' . $parts['port']:null) . ';dbname=' 452 458 . $parts['database']; 453 459 454 460 break; 455 461 default: 456 462 throw new Doctrine_Manager_Exception('Unknown driver '.$parts['scheme']); 457 463 } 458 459 464 460 465 return $parts; … … 687 692 } 688 693 return $this->_connections[$i]; 694 } 695 696 /** 697 * createDatabases 698 * 699 * Creates databases for connections 700 * 701 * @param string $specifiedConnections Array of connections you wish to create the database for 702 * @return void 703 * @todo package:dbal 704 */ 705 public function createDatabases($specifiedConnections = array()) 706 { 707 if ( ! is_array($specifiedConnections)) { 708 $specifiedConnections = (array) $specifiedConnections; 709 } 710 711 $results = array(); 712 713 foreach ($this as $name => $connection) { 714 if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 715 continue; 716 } 717 718 $results[$name] = $connection->createDatabase(); 719 } 720 721 return $results; 722 } 723 724 /** 725 * dropDatabases 726 * 727 * Drops databases for connections 728 * 729 * @param string $specifiedConnections Array of connections you wish to drop the database for 730 * @return void 731 * @todo package:dbal 732 */ 733 public function dropDatabases($specifiedConnections = array()) 734 { 735 if ( ! is_array($specifiedConnections)) { 736 $specifiedConnections = (array) $specifiedConnections; 737 } 738 739 $results = array(); 740 741 foreach ($this as $name => $connection) { 742 if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 743 continue; 744 } 745 746 $results[$name] = $connection->dropDatabase(); 747 } 748 749 return $results; 689 750 } 690 751 -
branches/0.10/lib/Doctrine/Query.php
r3789 r3791 1175 1175 // what about composite keys? 1176 1176 $idColumnName = $table->getColumnName($table->getIdentifier()); 1177 switch (strtolower($this->_conn->get Name())) {1177 switch (strtolower($this->_conn->getDriverName())) { 1178 1178 case 'mysql': 1179 1179 // mysql doesn't support LIMIT in subqueries -
branches/0.10/lib/Doctrine/Query/Tokenizer.php
r3313 r3791 378 378 } 379 379 } 380 $term[$i - 1] = array($term[$i - 1], ''); 380 381 if (isset($term[$i - 1])) { 382 $term[$i - 1] = array($term[$i - 1], ''); 383 } 381 384 382 385 return $term; -
branches/0.10/lib/Doctrine/Task/CreateDb.php
r3130 r3791 40 40 $results = Doctrine::createDatabases(); 41 41 42 foreach ($results as $ dbName => $bool) {43 $msg = $ bool ? 'Successfully created database named: "' . $dbName . '"':'Could not create database named: "' .$dbName . '"';42 foreach ($results as $name => $result) { 43 $msg = $result instanceof Exception ? 'Could not create database for connection: "' .$name . '." Failed with exception: ' . $result->getMessage():$result; 44 44 45 45 $this->notify($msg); -
branches/0.10/lib/Doctrine/Task/DropDb.php
r3679 r3791 51 51 $results = Doctrine::dropDatabases(); 52 52 53 foreach ($results as $ dbName => $bool) {54 $msg = $ bool ? 'Successfully dropped database named: "' . $dbName . '"':'Could not drop database named: "' .$dbName . '"';53 foreach ($results as $name => $result) { 54 $msg = $result instanceof Exception ? 'Could not drop database for connection: "' .$name . '." Failed with exception: ' . $result->getMessage():$result; 55 55 56 56 $this->notify($msg); -
branches/0.10/tests/Export/SqliteTestCase.php
r2963 r3791 33 33 class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase 34 34 { 35 public function testCreateDatabaseDoesNotExecuteSql ()35 public function testCreateDatabaseDoesNotExecuteSqlAndCreatesSqliteFile() 36 36 { 37 try { 38 $this->export->createDatabase('db'); 39 $this->fail(); 40 } catch(Doctrine_Export_Exception $e) { 41 $this->pass(); 42 } 37 $this->export->createDatabase('sqlite.db'); 38 39 $this->assertTrue(file_exists('sqlite.db')); 43 40 } 44 public function testDropDatabaseDoesNotExecuteSql ()41 public function testDropDatabaseDoesNotExecuteSqlAndDeletesSqliteFile() 45 42 { 46 try { 47 $this->export->dropDatabase('db'); 48 $this->fail(); 49 } catch(Doctrine_Export_Exception $e) { 50 $this->pass(); 51 } 43 $this->export->dropDatabase('sqlite.db'); 44 45 $this->assertFalse(file_exists('sqlite.db')); 52 46 } 53 47 public function testCreateTableSupportsAutoincPks() -
branches/0.10/tests/ManagerTestCase.php
r3071 r3791 66 66 // It expects only // since it thinks it is parsing a url 67 67 // The problem after that is that the dns is not valid when being passed to PDO 68 $sqlite = 'sqlite:/// full/unix/path/to/file.db';69 $sqlitewin = 'sqlite:// c:/full/windows/path/to/file.db';68 $sqlite = 'sqlite:////full/unix/path/to/file.db'; 69 $sqlitewin = 'sqlite:///c:/full/windows/path/to/file.db'; 70 70 71 71 $manager = Doctrine_Manager::getInstance(); -
branches/0.10/tests/TreeStructureTestCase.php
r2353 r3791 104 104 $o4->save(); 105 105 106 $o1->Children;107 106 $this->assertFalse(isset($o1->Parent)); 107 $this->assertTrue(isset($o2->Parent)); 108 $this->assertTrue($o2->Parent === $o1); 109 $this->assertFalse(isset($o4->Parent)); 110 108 111 $this->assertTrue(count($o1->Children) == 2); 109 112 $this->assertTrue(count($o1->get('Children')) == 2); 110 113 111 $this->assertTrue(isset($o2->Parent));112 $this->assertTrue($o2->Parent === $o1);113 114 114 $this->assertTrue(count($o4->Children) == 0); 115 $this->assertFalse(isset($o4->Parent));116 115 } 117 116 public function testTreeStructureFetchingWorksWithDql() -
branches/0.10/tools/sandbox/config.php.dist
r3415 r3791 43 43 define('YAML_SCHEMA_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'schema'); 44 44 define('DB_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'sandbox.db'); 45 define('DSN', 'sqlite: ' . DB_PATH);45 define('DSN', 'sqlite:///' . DB_PATH); 46 46 47 47 require_once(DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php'); … … 49 49 spl_autoload_register(array('Doctrine', 'autoload')); 50 50 51 $pdo = new PDO(DSN); 52 Doctrine_Manager::connection($pdo, 'sandbox'); 51 Doctrine_Manager::connection(DSN, 'sandbox'); 53 52 54 Doctrine_Manager::getInstance()->setAttribute( Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);53 Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');