public function testRemoveAllSettings() { $settings = array('TheOnlyGroup' => array('Existing1' => true), 'TheSecondOnlyGroup' => array('Existing1' => true)); $comments = array(); $configuration = new ezcConfiguration($settings, $comments); $configuration->removeAllSettings(); $this->assertEquals(false, $configuration->hasGroup('TheOnlyGroup')); $this->assertEquals(false, $configuration->hasGroup('TheSecondOnlyGroup')); $this->assertSame(true, $this->readAttribute($configuration, 'isModified')); }
public function testIntegerRanges64Bit() { if (PHP_INT_SIZE !== 8) { $this->markTestSkipped("Only for 64 bit machines"); } $backend = new ezcConfigurationIniReader('Configuration/tests/files/int-range.ini'); $return = $backend->load(); $settings = array('int32' => array('InRange1' => -51, 'InRange2' => 59, 'InRangeJust0' => -2147483647, 'InRangeJust1' => -2147483648, 'InRangeJust2' => 2147483647, 'OutRangeJust1' => -2147483649, 'OutRangeJust2' => 2147483648, 'OutRange1' => -21474836480, 'OutRange2' => 21474836480), 'int64' => array('InRange1' => -51, 'InRange2' => 59, 'InRangeJust0' => -9223372036854775807, 'InRangeJust1' => (int) '-9223372036854775808', 'InRangeJust2' => 9223372036854775807, 'OutRangeJust1' => '-9223372036854775809', 'OutRangeJust2' => '9223372036854775808', 'OutRange1' => '-92233720368547758080', 'OutRange2' => '92233720368547758080')); $comments = array(); $expected = new ezcConfiguration($settings, $comments); $this->assertSame($expected->getAllSettings(), $return->getAllSettings()); $this->assertSame(-9223372036854775807, $expected->getSetting('int64', 'InRangeJust0')); $this->assertSame('-9223372036854775809', $expected->getStringSetting('int64', 'OutRangeJust1')); try { $this->assertSame('-9223372036854775809', $expected->getNumberSetting('int64', 'OutRangeJust1')); } catch (ezcConfigurationSettingWrongTypeException $e) { self::assertSame("The expected type for the setting 'int64', 'OutRangeJust1' is 'double or integer'. The setting was of type 'string'.", $e->getMessage()); } }
* with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * @package Configuration * @subpackage Examples */ require 'autoload.php'; // A small example which creates an INI file from scratch // // If something goes wrong (file writing or setting access) it will catch // the exception and show the problem. try { $conf = new ezcConfiguration(); $conf->setSetting('db', 'title', "This is the title"); $conf->setSettings('db', array("host", "user", "password"), array('localhost', 'dr', '42')); $ini = new ezcConfigurationIniWriter(dirname(__FILE__) . '/defaults.ini', $conf); $conf = $ini->save(); print "INI file defaults.ini was successfully created\n"; } catch (Exception $e) { print "Caught exception while reading INI\n"; print $e->getMessage() . "(" . $db->getCode() . ")\n"; print $e->getTraceAsString() . "\n"; }