Skip to content

Commit

Permalink
Merge pull request #1847 from nickvergessen/ticket/11995
Browse files Browse the repository at this point in the history
Ticket/11995 Fix Revert of config.remove migration
  • Loading branch information
EXreaction committed Nov 2, 2013
2 parents 8a78699 + e8a3028 commit 4d6c722
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 63 deletions.
4 changes: 4 additions & 0 deletions phpBB/phpbb/db/migration/tool/config.php
Expand Up @@ -130,6 +130,10 @@ public function reverse()

case 'remove':
$call = 'add';
if (sizeof($arguments) == 1)
{
$arguments[] = '';
}
break;

case 'update_if_equals':
Expand Down
91 changes: 28 additions & 63 deletions tests/dbal/migrator_tool_config_test.php
Expand Up @@ -20,102 +20,67 @@ public function setup()

public function test_add()
{
try
{
$this->tool->add('foo', 'bar');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->tool->add('foo', 'bar');
$this->assertEquals('bar', $this->config['foo']);
}

public function test_add_twice()
{
$this->tool->add('foo', 'bar');
$this->assertEquals('bar', $this->config['foo']);

try
{
$this->tool->add('foo', 'bar');
$this->fail('Exception not thrown');
}
catch (Exception $e) {}
$this->tool->add('foo', 'bar2');
$this->assertEquals('bar', $this->config['foo']);
}

public function test_update()
{
$this->config->set('foo', 'bar');
try
{
$this->tool->update('foo', 'bar2');
}
catch (Exception $e)
{
$this->fail($e);
}

$this->tool->update('foo', 'bar2');
$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->tool->update_if_equals('', 'foo', 'bar2');
$this->assertEquals('bar', $this->config['foo']);

try
{
$this->tool->update_if_equals('bar', 'foo', 'bar2');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->tool->update_if_equals('bar', 'foo', 'bar2');
$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->tool->remove('foo');
$this->assertFalse(isset($this->config['foo']));
}

public function test_reverse()
public function test_reverse_add()
{
$this->config->set('foo', 'bar');

try
{
$this->tool->reverse('add', 'foo');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->tool->reverse('add', 'foo');
$this->assertFalse(isset($this->config['foo']));
}

public function test_reverse_remove()
{
$this->config->delete('foo');

$this->tool->reverse('remove', 'foo');
$this->assertEquals('', $this->config['foo']);
}

public function test_reverse_update_if_equals()
{
$this->config->set('foo', 'bar');

try
{
$this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
$this->assertEquals('test', $this->config['foo']);
}
}

0 comments on commit 4d6c722

Please sign in to comment.