Changeset 527
- Timestamp:
- 04/14/07 21:30:40 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/stubDatabaseConnectionPool.php
r400 r527 32 32 */ 33 33 protected static $connectionData = array(); 34 34 35 35 /** 36 36 * returns a connection … … 65 65 return self::$connections[$id]; 66 66 } 67 67 68 68 /** 69 69 * adds connection data to the list of known connection data … … 75 75 self::$connectionData[$connectionData->getId()] = $connectionData; 76 76 } 77 77 78 78 /** 79 79 * checks whether connection data for a given id is available … … 86 86 return isset(self::$connectionData[$id]); 87 87 } 88 88 89 89 /** 90 90 * returns the connection data for a given id … … 101 101 return null; 102 102 } 103 103 104 /** 105 * returns a list of all ids of all connection data objects in the pool 106 * 107 * @return array<string> 108 */ 109 public static function getConnectionDataIds() 110 { 111 return array_keys(self::$connectionData); 112 } 113 104 114 /** 105 115 * removes the connection data with the given id … … 111 121 if (isset(self::$connectionData[$id]) == true) { 112 122 self::$connectionData[$id] = null; 123 unset(self::$connectionData[$id]); 113 124 } 114 125 } 115 126 116 127 /** 117 128 * closes the connection with the given id … … 128 139 } 129 140 } 130 141 131 142 /** 132 143 * sets a connection for the given id trunk/src/test/php/net/stubbles/rdbms/stubDatabaseConnectionPoolTestCase.php
r174 r527 25 25 stubDatabaseConnectionPool::removeConnectionData(); 26 26 } 27 27 28 28 /** 29 29 * clean test environment … … 33 33 stubDatabaseConnectionPool::removeConnectionData(); 34 34 } 35 35 36 36 /** 37 37 * check that setting/getting the connection data works as expected … … 41 41 $this->assertFalse(stubDatabaseConnectionPool::hasConnectionData()); 42 42 $this->assertNull(stubDatabaseConnectionPool::getConnectionData()); 43 $this->assertEqual(stubDatabaseConnectionPool::getConnectionDataIds(), array()); 43 44 $connectionData = new stubDatabaseConnectionData(); 44 45 stubDatabaseConnectionPool::addConnectionData($connectionData); 45 46 $this->assertTrue(stubDatabaseConnectionPool::hasConnectionData()); 46 47 $this->assertReference(stubDatabaseConnectionPool::getConnectionData(), $connectionData); 48 $this->assertEqual(stubDatabaseConnectionPool::getConnectionDataIds(), array(stubDatabaseConnectionData::DEFAULT_ID)); 47 49 $this->assertFalse(stubDatabaseConnectionPool::hasConnectionData('foo')); 48 50 $this->assertNull(stubDatabaseConnectionPool::getConnectionData('foo')); 49 51 stubDatabaseConnectionPool::removeConnectionData(); 50 52 $this->assertFalse(stubDatabaseConnectionPool::hasConnectionData()); 53 $this->assertEqual(stubDatabaseConnectionPool::getConnectionDataIds(), array()); 51 54 } 52 55 53 56 /** 54 57 * assert that getting a connection without a saved connection and without … … 60 63 stubDatabaseConnectionPool::getConnection(); 61 64 } 62 65 63 66 /** 64 67 * assert that getting a connection without a saved connection and with an … … 73 76 stubDatabaseConnectionPool::getConnection(); 74 77 } 75 78 76 79 /** 77 80 * assert that getting a connection without a saved connection but with … … 86 89 $this->assertIsA($connection, 'MockstubDatabaseConnection'); 87 90 } 88 91 89 92 /** 90 93 * assert that getting a connection with a saved connection delivers the … … 100 103 $this->assertReference($connection, $connectionTest); 101 104 } 102 105 103 106 /** 104 107 * assert that a getting a closed connection without connection data
