mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 20:13:22 +01:00
98 lines
1.7 KiB
PHP
98 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
* @package testing
|
|
* @copyright (c) 2011 phpBB Group
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
*
|
|
*/
|
|
|
|
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/config.php';
|
|
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php';
|
|
|
|
class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
|
|
{
|
|
public function setup()
|
|
{
|
|
$this->config = new phpbb_config(array());
|
|
|
|
$this->tool = new phpbb_db_migration_tool_config($this->config);
|
|
|
|
parent::setup();
|
|
}
|
|
|
|
public function test_add()
|
|
{
|
|
try
|
|
{
|
|
$this->tool->add('foo', 'bar');
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->fail($e);
|
|
}
|
|
$this->assertEquals('bar', $this->config['foo']);
|
|
|
|
try
|
|
{
|
|
$this->tool->add('foo', 'bar');
|
|
$this->fail('Exception not thrown');
|
|
}
|
|
catch (Exception $e) {}
|
|
}
|
|
|
|
public function test_update()
|
|
{
|
|
$this->config->set('foo', 'bar');
|
|
try
|
|
{
|
|
$this->tool->update('foo', 'bar2');
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->fail($e);
|
|
}
|
|
$this->assertEquals('bar2', $this->config['foo']);
|
|
}
|
|
|
|
public function test_update_if_equals()
|
|
{
|
|
$this->config->set('foo', 'bar');
|
|
|
|
try
|
|
{
|
|
$this->tool->update_if_equals('', 'foo', 'bar2');
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->fail($e);
|
|
}
|
|
$this->assertEquals('bar', $this->config['foo']);
|
|
|
|
try
|
|
{
|
|
$this->tool->update_if_equals('bar', 'foo', 'bar2');
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->fail($e);
|
|
}
|
|
$this->assertEquals('bar2', $this->config['foo']);
|
|
}
|
|
|
|
public function test_remove()
|
|
{
|
|
$this->config->set('foo', 'bar');
|
|
|
|
try
|
|
{
|
|
$this->tool->remove('foo');
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->fail($e);
|
|
}
|
|
$this->assertFalse(isset($this->config['foo']));
|
|
}
|
|
}
|