Changeset 525
- Timestamp:
- 04/14/07 20:47:38 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/util/stubRegistry.php
r358 r525 60 60 61 61 /** 62 * removes a value from the registry 63 * 64 * @param string $key key where the value is stored under 65 */ 66 public function remove($key) 67 { 68 if (isset(self::$registry[$key]) == true) { 69 unset(self::$registry[$key]); 70 } 71 } 72 73 /** 74 * removes a value from the config 75 * 76 * @param string $key key where the value is stored under 77 */ 78 public function removeConfig($key) 79 { 80 if (isset(self::$config[$key]) == true) { 81 unset(self::$config[$key]); 82 } 83 } 84 85 /** 62 86 * check if a value exists under the given key 63 87 * … … 116 140 return $default; 117 141 } 142 143 /** 144 * returns all registry values 145 * 146 * @return array<string,mixed> 147 */ 148 public static function getKeys() 149 { 150 return array_keys(self::$registry); 151 } 152 153 /** 154 * returns all configuration values 155 * 156 * @return array<string,mixed> 157 */ 158 public static function getConfigKeys() 159 { 160 return array_keys(self::$config); 161 } 118 162 } 119 163 ?> trunk/src/test/php/net/stubbles/ipo/request/filters/stubFloatFilterTestCase.php
r360 r525 47 47 $this->mockStubValidatorMax = new MockStubValidator(); 48 48 $this->mockStubRequestValueErrorFactory->setReturnValue('create', new stubRequestValueError('foo', array('en_EN' => 'Something wrent wrong.'))); 49 } 50 51 /** 52 * clean up test environment 53 */ 54 public function tearDown() 55 { 56 stubRegistry::removeConfig('net.stubbles.number.decimals'); 49 57 } 50 58 … … 134 142 $floatFilter->execute(11); 135 143 } 144 136 145 /** 137 146 * assure that the correct value depending on $decimal_places is returned trunk/src/test/php/net/stubbles/util/stubRegistryTestCase.php
r358 r525 24 24 $this->assertEqual(stubRegistry::get('test', 'foo'), 'foo'); 25 25 $this->assertFalse(stubRegistry::has('test')); 26 $this->assertEqual(stubRegistry::getKeys(), array()); 26 27 stubRegistry::set('test', 'test'); 27 28 $this->assertTrue(stubRegistry::has('test')); … … 32 33 $regTest = stubRegistry::get('test'); 33 34 $this->assertReference($regTest, $test); 35 $this->assertEqual(stubRegistry::getKeys(), array('test')); 36 stubRegistry::remove('test'); 37 $this->assertNull(stubRegistry::get('test')); 38 $this->assertFalse(stubRegistry::has('test')); 39 $this->assertEqual(stubRegistry::getKeys(), array()); 34 40 } 35 41 … … 42 48 $this->assertEqual(stubRegistry::getConfig('test', 'foo'), 'foo'); 43 49 $this->assertFalse(stubRegistry::hasConfig('test')); 50 $this->assertEqual(stubRegistry::getConfigKeys(), array()); 44 51 stubRegistry::setConfig('test', 'test'); 45 52 $this->assertTrue(stubRegistry::hasConfig('test')); … … 50 57 $regTest = stubRegistry::getConfig('test'); 51 58 $this->assertReference($regTest, $test); 59 $this->assertEqual(stubRegistry::getConfigKeys(), array('test')); 60 stubRegistry::removeConfig('test'); 61 $this->assertNull(stubRegistry::getConfig('test')); 62 $this->assertFalse(stubRegistry::hasConfig('test')); 63 $this->assertEqual(stubRegistry::getConfigKeys(), array()); 52 64 } 53 65 }
